[R] ggplot2: changing shapes facet_grid - special case.

Ista Zahn istazahn at gmail.com
Wed Sep 18 15:38:58 CEST 2013


Hi Anna,

It's not clear to me what you are trying to do. If you want different
shapes for different organisms then you should map organism to shape,
e.g.,

    geom_point(data = Summisodata11, aes(y = mean, shape=organism))

Is that what you are looking for? If not please restate the question.

Best,
Ista

On Wed, Sep 18, 2013 at 1:52 AM, Anna Zakrisson Braeunlich
<anna.zakrisson at su.se> wrote:
> Hi,
>
> I want to change my geom.point shapes in facet grid. I have tried all sorts of solutions, but for some reason none seem to work. Something overrides the "normal" codes. I am stuck.
> I have attached the data to the mail.
> I want organism to have different shapes and then add a legend to the plot.
> thank you for your help!
>
> Code:
>
>   Anaalldata <- read.table(file = "Annadata_2007_9_ISO_long.txt", header = TRUE, dec = ".")
>   str(Anaalldata)
>   names(Anaalldata)
>   library(hexbin)
>   library(grid)
>   library(ggplot2)
>   Anaalldata <- within(Anaalldata, fweek <- factor(week))
>   Anaalldata <- within(Anaalldata, fyear <- factor(year))
>   Anaalldata <- na.exclude(Anaalldata)
>   names(Anaalldata)
>
>   Summisodata11 <- ddply(Anaalldata, .(station, organism), summarise, mean = mean(deltancy),
>                         sd = sd(deltancy))
>
>   p <- ggplot(Anaalldata, aes(station, organism))+
>
>     geom_errorbar(data = Summisodata11, aes(ymin = mean - sd, y = mean,
>                                        ymax = mean + sd),
>                   size = 1, width = 0.1, color = "black")+
>     geom_point(data = Summisodata11, aes(y = mean))+
>                scale_shape(solid = F)+
>     theme_bw() +
>     theme(strip.background = element_blank())+
>     xlab("Station") +
>     ylab(expression(paste("",delta^{15}, "N")))+
>     scale_y_continuous(limits=c(-3, 14),    # Set y range
>                        breaks=-4:15*2) +
>     geom_hline(yintercept=0, linetype=3) + #draws dotted line at 0
>     theme(strip.text.x = element_text(size = 20, colour="black", family="serif", angle=00)) +
>     theme(strip.text.y = element_text(size = 20, colour="black", family="serif", angle=00)) +
>     theme(axis.text.x = element_text(size = 20, colour="black", family="serif", angle=00)) +
>     theme(axis.text.y = element_text(size = 17, colour="black", family="serif", angle=00)) +
>     theme(axis.title.x = element_text(size=20, colour="black", family="serif", angle=00))+
>     theme(axis.title.y = element_text(size=20, colour="black", family="serif", angle=90))+
>     facet_wrap( ~ year)
> p
>
> Anna Zakrisson Braeunlich
> PhD student
>
> Department of Ecology, Environment and Plant Sciences
> Stockholm University
> Svante Arrheniusv. 21A
> SE-106 91 Stockholm
> Sweden/Sverige
>
> Lives in Berlin.
> For paper mail:
> Katzbachstr. 21
> D-10965, Berlin - Kreuzberg
> Germany/Deutschland
>
> E-mail: anna.zakrisson at su.se
> Tel work: +49-(0)3091541281
> Mobile: +49-(0)15777374888
> LinkedIn: http://se.linkedin.com/pub/anna-zakrisson-braeunlich/33/5a2/51b
>
>><((((º>`•. . • `•. .• `•. . ><((((º>`•. . • `•. .• `•. .><((((º>`•. . • `•. .• `•. .><((((º>
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>



More information about the R-help mailing list