[R] qplot of ggplot package how to plot different size according to the values and not to the weights?
hadley wickham
h.wickham at gmail.com
Fri Oct 27 14:23:37 CEST 2006
On 10/27/06, Stefan Grosse <singularitaet at gmx.net> wrote:
> I have the following Data structure
>
> $ step45 : Factor w/ 2 levels
> $ obserror : num 6.2 6.2 5.6 6.6 6.6 ...
> $ Mon : num 2.2 2.0 1.0 3.2 2.0 ...
> $ inc.comp : num 4 5 2 5 5 5 5 5 4 4 ...
>
> all I wanted to do is plotting Mon against obserror, the colors should
> be by step45 and the size of the symbol should be according to inc.comp
> so I did this:
>
> qplot(obserror,Mon,data=obscomp,col=inc.comp,col=step45)
I think you mean
> qplot(obserror,Mon,data=obscomp, size=inc.comp,col=step45)
> unfortunately the size of the is something I do not want it to be, the
> legend for inc.comp says: 4, 2.25, 1 ,0.25 , 0 I suppose this are weights?
I think there are two things here that are confusing you (both my fault)
* the size aesthetic actually modifies the area (ie. sqrt(size)) of
the points, because that is better perceptually
* the legend isn't very good
But it is mapping the inc.comp to the size of the variable.
> I needed the as.factor otherwise the plot is again different. But that
> did not work with size. OK I thought this is a second best solution but
> unfortunately the symbols are to small. But setting a size = 3 which I
> thout adds a constant size everywhere (somehow expectedly) did add a
> third legend "3" with 3.61, 3.42, ...
qplot currently doesn't have any way to set an aesthetic to a fixed
value (it can't tell that you're specifying an aesthetic value not a
data value). You can do this in two steps though
p <- qplot(wt, mpg, data=mtcars, type=NULL, shape=cyl)
ggpoint(p, size=3)
> Another thing what I like to complain about is that qplot is using only
> half of the windows graphics device space (especially wen adding this
> size =3) which is not only ugly but a waste of space...
That sounds like a bug. Could you please provide a reproducible example?
Thanks,
Hadley
More information about the R-help
mailing list