[R] ggplot2 different Y axis scales

Jeff Newmiller jdnewmil at dcn.davis.CA.us
Sat Nov 7 00:28:10 CET 2015

Read the help for facet_grid, in particular about the scale parameter. I don't think you can individually control it though. 
Jeff Newmiller                        The     .....       .....  Go Live...
DCN:<jdnewmil at dcn.davis.ca.us>        Basics: ##.#.       ##.#.  Live Go...
                                      Live:   OO#.. Dead: OO#..  Playing
Research Engineer (Solar/Batteries            O.O#.       #.O#.  with
/Software/Embedded Controllers)               .OO#.       .OO#.  rocks...1k
Sent from my phone. Please excuse my brevity.

On November 6, 2015 2:04:54 PM PST, David Doyle <kydaviddoyle at gmail.com> wrote:
>Hello Everyone,
>I'm using the following code to plot sulfate concentrations vs. time
>several groundwater wells at one time.  Normally I need the scales to
>be the same but in the case of sulfate I need to use a different scale
>each well.  This is because some of my wells have very high / wide
>(MW04 ranges from 4 - 3,000) where some have very small ranges (MW06
>from 13 - 34).
>Is there a way that I can  have qqplot2 automatically scale each well
>or a
>way I could enter a scale range.?  For example I would like MW04 to
>have a
>Y axis scale from 0 - 3,000 and MW06 to have a Y axis scale from 0 - 40
>I am using
>RStudio version 0.99.484
>R i386 3.2.2
>ggplott2 ver 1.0.1
>in a Windows 7 environment.
>Thank you for your time
>David Doyle
>SS <-read.csv("http://doylesdartden.com/Stats/SS.csv", sep=",")
>#Sets whic are detections and nondetects
>SS$Detections <- ifelse(SS$D_Sulfate==1, "Detected", "NonDetect")
>#does the plot
>p <- ggplot(data = SS, aes(x=Year, y=Sulfate, col=Detections)) +
>  geom_point(aes(shape=Detections))  +
>  ##sets the colors
>  scale_colour_manual(values=c("black","red")) +
>  #location of the legend
>  theme(legend.position=c("none")) +
>  #sets the line color, type and size
>  geom_line(colour="black", linetype="dotted", size=0.5) +
>  ylab("Sulfate (mg/L)") +
>  ##Graph title
>  ggtitle("Figure 6-30
>          Sandstone Sulfate Time Series")
>## does the graph using the Well IDs as the different wells.
>p + facet_grid(Well ~ .)
>	[[alternative HTML version deleted]]
>R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see
>PLEASE do read the posting guide
>and provide commented, minimal, self-contained, reproducible code.

More information about the R-help mailing list