I'm interested in creating a graphic -like- this: c <- ggplot(mtcars, aes(qsec, wt)) c + geom_point() + stat_smooth(fill="blue", colour="darkblue", size=2, alpha = 0.2) but I need to show 2 sets of bands (with different shading) using 5%, 25%, 75%, 95% limits that I specify and where the heavy blue line is the median. I don't understand how to do this with ggplot2. What I am doing currently is to generate 'boxplots' (with 5%, 25%, 75%, 95% limits) at 6-hourly time steps (so I have a series of boxplots, which you can see by clicking on a map point: http://www.erh.noaa.gov/mmefs/index_test.php?Lat=38.2&Lon=-80.1&Zoom=5&Refresh=0&RFCOverlay=0&Model=NAEFS). Some who use our graphics would like to see something more like the ggplot2 with stat_smooth graphic. Help is much appreciated. Regards, Tom -- Thomas E Adams National Weather Service Ohio River Forecast Center 1901 South State Route 134 Wilmington, OH 45177 EMAIL: thomas.adams at noaa.gov VOICE: 937-383-0528 FAX: 937-383-0033
Hi: I would think that, at least in principle, this should work: a <- ggplot(mtcars, aes(qsec, wt)) a + geom_point() + stat_smooth(fill="blue", colour="darkblue", size=2, level = 0.9, alpha = 0.2) + stat_smooth(fill = 'blue', colour = 'darkblue', size = 2, level = 0.5, alpha = 0.4) but geom_smooth() doesn't seem to react to different values of level. I get the same bands on geom_smooth() if I use level = 0.95, 0.75 or 0.5. Since I make it a policy not to invoke the B word, I'll let others who know more about the code comment on it. BTW, ggplot2 related questions tend to get faster responses on its list: ggplot2 at googlegroups.com. I've taken the liberty of forwarding there since most of the developers read that list more regularly than R-help. Dennis On Mon, Oct 3, 2011 at 10:24 AM, Thomas Adams <Thomas.Adams at noaa.gov> wrote:> ?I'm interested in creating a graphic -like- this: > > c <- ggplot(mtcars, aes(qsec, wt)) > c + geom_point() + stat_smooth(fill="blue", colour="darkblue", size=2, alpha > = 0.2) > > but I need to show 2 sets of bands (with different shading) using 5%, 25%, > 75%, 95% limits that I specify and where the heavy blue line is the median. > I don't understand how to do this with ggplot2. What I am doing currently is > to generate 'boxplots' (with 5%, 25%, 75%, 95% limits) at 6-hourly time > steps (so I have a series of boxplots, which you can see by clicking on a > map point: > http://www.erh.noaa.gov/mmefs/index_test.php?Lat=38.2&Lon=-80.1&Zoom=5&Refresh=0&RFCOverlay=0&Model=NAEFS). > Some who use our graphics would like to see something more like the ggplot2 > with stat_smooth graphic. > > Help is much appreciated. > > Regards, > Tom > > -- > Thomas E Adams > National Weather Service > Ohio River Forecast Center > 1901 South State Route 134 > Wilmington, OH 45177 > > EMAIL: ?thomas.adams at noaa.gov > > VOICE: ?937-383-0528 > FAX: ? ?937-383-0033 > > ______________________________________________ > 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. >
Hi, Try some like this: c <- ggplot(mtcars, aes(qsec, mpg, colour=factor(cyl))) c + stat_smooth(aes(group=cyl))+stat_smooth(aes(fill=factor(cyl)))+geom_point() Andr?s AM 2011/10/3, Thomas Adams <Thomas.Adams at noaa.gov>:> I'm interested in creating a graphic -like- this: > > c <- ggplot(mtcars, aes(qsec, wt)) > c + geom_point() + stat_smooth(fill="blue", colour="darkblue", size=2, > alpha = 0.2) > > but I need to show 2 sets of bands (with different shading) using 5%, > 25%, 75%, 95% limits that I specify and where the heavy blue line is the > median. I don't understand how to do this with ggplot2. What I am doing > currently is to generate 'boxplots' (with 5%, 25%, 75%, 95% limits) at > 6-hourly time steps (so I have a series of boxplots, which you can see > by clicking on a map point: > http://www.erh.noaa.gov/mmefs/index_test.php?Lat=38.2&Lon=-80.1&Zoom=5&Refresh=0&RFCOverlay=0&Model=NAEFS). > Some who use our graphics would like to see something more like the > ggplot2 with stat_smooth graphic. > > Help is much appreciated. > > Regards, > Tom > > -- > Thomas E Adams > National Weather Service > Ohio River Forecast Center > 1901 South State Route 134 > Wilmington, OH 45177 > > EMAIL: thomas.adams at noaa.gov > > VOICE: 937-383-0528 > FAX: 937-383-0033 > > ______________________________________________ > 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. >
Andr?s, Thank you for your help, but that does not capture what I'm looking for. I need to be able to control the shaded bound limits and they need to be coincident. Tom On 10/3/11 3:37 PM, Andr?s Arag?n wrote:> Hi, > Try some like this: > > c<- ggplot(mtcars, aes(qsec, mpg, colour=factor(cyl))) > c + stat_smooth(aes(group=cyl))+stat_smooth(aes(fill=factor(cyl)))+geom_point() > > > Andr?s AM > > > > 2011/10/3, Thomas Adams<Thomas.Adams at noaa.gov>: >> I'm interested in creating a graphic -like- this: >> >> c<- ggplot(mtcars, aes(qsec, wt)) >> c + geom_point() + stat_smooth(fill="blue", colour="darkblue", size=2, >> alpha = 0.2) >> >> but I need to show 2 sets of bands (with different shading) using 5%, >> 25%, 75%, 95% limits that I specify and where the heavy blue line is the >> median. I don't understand how to do this with ggplot2. What I am doing >> currently is to generate 'boxplots' (with 5%, 25%, 75%, 95% limits) at >> 6-hourly time steps (so I have a series of boxplots, which you can see >> by clicking on a map point: >> http://www.erh.noaa.gov/mmefs/index_test.php?Lat=38.2&Lon=-80.1&Zoom=5&Refresh=0&RFCOverlay=0&Model=NAEFS). >> Some who use our graphics would like to see something more like the >> ggplot2 with stat_smooth graphic. >> >> Help is much appreciated. >> >> Regards, >> Tom >> >> -- >> Thomas E Adams >> National Weather Service >> Ohio River Forecast Center >> 1901 South State Route 134 >> Wilmington, OH 45177 >> >> EMAIL: thomas.adams at noaa.gov >> >> VOICE: 937-383-0528 >> FAX: 937-383-0033 >> >> ______________________________________________ >> 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. >>-- Thomas E Adams National Weather Service Ohio River Forecast Center 1901 South State Route 134 Wilmington, OH 45177 EMAIL: thomas.adams at noaa.gov VOICE: 937-383-0528 FAX: 937-383-0033
On Mon, Oct 3, 2011 at 12:24 PM, Thomas Adams <Thomas.Adams at noaa.gov> wrote:> ?I'm interested in creating a graphic -like- this: > > c <- ggplot(mtcars, aes(qsec, wt)) > c + geom_point() + stat_smooth(fill="blue", colour="darkblue", size=2, alpha > = 0.2) > > but I need to show 2 sets of bands (with different shading) using 5%, 25%, > 75%, 95% limits that I specify and where the heavy blue line is the median. > I don't understand how to do this with ggplot2.Exactly what sort of limits do you want? It sounds like maybe you are looking for smoothed quantile regression. Hadley -- Assistant Professor / Dobelman Family Junior Chair Department of Statistics / Rice University http://had.co.nz/
Maybe Matching Threads
- is it possible to map 2 plots(c and d) in a single output plot?
- Exponential Smoothing for ggplot2's stat_smooth()
- ggplot2: modifying line width and background fill color for stat_smooth()
- ggplot: problem with fill option in stat_smooth()
- ggplot: stat_smooth() and nls method