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

Anna Zakrisson Braeunlich anna.zakrisson at su.se
Wed Sep 18 07:52:33 CEST 2013


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

><((((º>`•. . • `•. .• `•. . ><((((º>`•. . • `•. .• `•. .><((((º>`•. . • `•. .• `•. .><((((º>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: Annadata_2007_9_ISO_long.txt
URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20130918/df5256cf/attachment.txt>


More information about the R-help mailing list