Re: [R] Question about ggplot2 and stat_smooth

22 views
Skip to first unread message

Dennis Murphy

unread,
Oct 3, 2011, 2:16:16 PM10/3/11
to Thomas Adams, R-help forum, ggplot2
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: ggp...@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...@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...@noaa.gov
>
> VOICE:  937-383-0528
> FAX:    937-383-0033
>
> ______________________________________________
> R-h...@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.
>

Adam_L...@keybank.com

unread,
Oct 3, 2011, 3:10:36 PM10/3/11
to Dennis Murphy, ggplot2
Hi Dennis,

Don't want to confuse the issue, but want to let you know the code below produced for me different sized bands, whether I use, "stat_smooth," or, "geom_smooth."



Adam Loveland
1Key

--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example:
http://gist.github.com/270442

To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+u...@googlegroups.com
More options:
http://groups.google.com/group/ggplot2

This communication may contain privileged and/or confidential information. It is intended solely for the use of the addressee. If you are not the intended recipient, you are strictly prohibited from disclosing, copying, distributing or using any of this information. If you received this communication in error, please contact the sender immediately and destroy the material in its entirety, whether electronic or hard copy. This communication may contain nonpublic personal information about consumers subject to the restrictions of the Gramm-Leach-Bliley Act. You may not directly or indirectly reuse or redisclose such information for any purpose other than to provide the services for which you are receiving the information. 127 Public Square, Cleveland, OH 44114


If you prefer not to receive future e-mail offers for products or services from Key
send an e-mail to mailto:DNERe...@key.com with 'No Promotional E-mails' in the SUBJECT line.

Dennis Murphy

unread,
Oct 3, 2011, 3:25:29 PM10/3/11
to ggplot2
After a short exchange with Adam, it appears that the code does seem
to work on at least some systems, but not on mine. To that end...

> sessionInfo()
R version 2.13.1 (2011-07-08)
Platform: x86_64-pc-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages:
[1] grid stats graphics grDevices utils datasets methods
[8] base

other attached packages:
[1] gridExtra_0.8 ggplot2_0.8.9 proto_0.3-9.2 reshape_0.8.4 plyr_1.6

loaded via a namespace (and not attached):
[1] tools_2.13.1

I also tried it in the unstable version 2.14.0 on the same platform with no joy.

Dennis

Reply all
Reply to author
Forward
0 new messages