[R] Visualize quartiles of plot line
hadley wickham
h.wickham at gmail.com
Sun Jun 17 10:51:58 CEST 2007
On 6/17/07, Arne Brutschy <abr-r-project at xylon.de> wrote:
> Hi,
>
> h> How about quantile regression? Have a look at
> h> http://had.co.nz/ggplot2/stat_quantile.html for some examples of
> h> what that might look like.
> I tried the ggplot2 package, it seems to be quite powerful. But
> documentation is only partially available, so I'm having some problems
> creating the graphs at all.
>
> First of all, where can I find the diamonds and dsmall data? I cannot
> recreate the samples given in the documentation.
The diamonds dataset is available from the ggplot2 package, and the
dsmall dataset is usually created as needed - dsmall <-
diamonds[sample(1:nrow(diamonds), 1000), ]
> I'm currently using a simple smoother to display the tendency of the
> data and it's stderr. For some reason, it works only for simple
> colors:
>
> p <- ggplot(data, aes(x=Problemsize, y=Fitness)) +
> geom_smooth(fill=alpha("blue", 0.2), colour="darkblue", size=2)
>
> This does only display a line, not the surrounding stderr. When I
> change the fill atrribute to "blue" or "grey80" without the alpha, the
> stderr gets displayed.
As I said in the other email, this is a known restriction of the
windows graphics device.
> Additionally, I want to display three different models by this, each
> with a differen curve/stderr fill color. How do I do that? I tried so
> set color=Model, which yields only a single line.
It's hard to know without know more about the structure of your
dataset. Including colour=factor(Model) in the aes statement may do
what you need.
> On another plot, I want to use a single model to be displayed with
> points colored by a gradient depending on a third property:
>
> p <- ggplot(data, aes(x=Problemsize, y=Fitness), color=DeltaConfig) +
> geom_smooth(size=1, color="black", fill="grey80")+
> geom_point(size=0.5)+
> scale_colour_gradient(limits=c(0,10), low="red", high="white")
>
> This does not work, I think the connection between goem_point and
> DeltaConfig is not there. But when I try to set
>
> geom_point(size=0.5, color=DeltaConfig)+
Colour needs to be inside the aes function - you are mapping colour to
the DeltaConfig variable, not setting colour to a fixed variable.
> it complains about an unknown DeltaConfig object.
>
> Hmm, I guess I don't fully understand this 'grammar of graphics'
> thing. But documentation is quite inconsistent. :( And, the coloring
> thing seems to be a bug. BTW, I'm using R 2.5.0 on windows.
You might want to read the introductory chapters in the ggplot book,
available from http://had.co.nz/ggplot2, which will give you more of a
background. Please let me know places where you think the
documentation is inconsistent so I can try and make them better.
Hadley
More information about the R-help
mailing list