On 01/06/2021 19:15, Manuel Spínola wrote:
Thank you very much Edzer.

What about the labels of the stripes?

If I try to change the labels, they come out as NA

r <- read_stars(system.file("external/test.grd", package="raster"))

s1 <- c(r, r*2)

s2 <- merge(s1)

n <- c("raster 01", "raster 02")

ggplot() +
    geom_stars(data = s2) +
    facet_wrap(~attributes, labeller = labeller(attributes = n)) +
    coord_equal()


s3 = st_set_dimensions(s2, "attributes",
  values = c("label_A", "label_B"))
ggplot() + geom_stars(data = s3) +
  facet_wrap(~attributes) + coord_equal()


El mar, 1 jun 2021 a las 10:54, Edzer Pebesma (<edzer.pebe...@uni-muenster.de <mailto:edzer.pebe...@uni-muenster.de>>) escribió:



    On 01/06/2021 18:43, Manuel Spínola wrote:
     > Dear list members,
     >
     > I am trying to use facet_wrap with geom_stars but I don't know how to
     > specify the variable argument in the facet_wrap function (I know
    is not
     > "band"), and also, how to change the labels of the strip names?
     >
     > r <- read_stars(system.file("external/test.grd", package="raster"))
     >
     > s1 <- c(r, r*2)
     >
     > ggplot() +
     >    geom_stars(data = s1) +
     >    coord_equal() +
     >    facet_wrap(~ band)
     >

    Try:

    ggplot() +
        geom_stars(data = merge(s1)) + f
        facet_wrap(~attributes) +
        coord_equal()


    c() binds attributes, merge() merges them into a dimension.
-- Edzer Pebesma
    Institute for Geoinformatics
    Heisenbergstrasse 2, 48151 Muenster, Germany
    Phone: +49 251 8333081

    _______________________________________________
    R-sig-Geo mailing list
    R-sig-Geo@r-project.org <mailto:R-sig-Geo@r-project.org>
    https://stat.ethz.ch/mailman/listinfo/r-sig-geo
    <https://stat.ethz.ch/mailman/listinfo/r-sig-geo>



--
*Manuel Spínola, Ph.D.*
Instituto Internacional en Conservación y Manejo de Vida Silvestre
Universidad Nacional
Apartado 1350-3000
Heredia
COSTA RICA
mspin...@una.cr <mailto:mspin...@una.ac.cr>
mspinol...@gmail.com <mailto:mspinol...@gmail.com>
Teléfono: (506) 8706 - 4662
Personal website: Lobito de río <https://sites.google.com/site/lobitoderio/>
Institutional website: ICOMVIS <http://www.icomvis.una.ac.cr/>

--
Edzer Pebesma
Institute for Geoinformatics
Heisenbergstrasse 2, 48151 Muenster, Germany
Phone: +49 251 8333081

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to