Stefan Grosse
2006-Oct-27 09:19 UTC
[R] qplot of ggplot package how to plot different size according to the values and not to the weights?
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) 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 got closer to what I want specify a different symbol instead of a different size: qplot(obserror,Mon,data=obscomp,shape=as.factor(inc.comp),col=step45) 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, ... (The color worked fine) Unfortunately the documentation of qplot is rather short ("FIXME")... So is there a kind of option to use for the size just the values and not the weights? Or a possibility to switch of "3" for legend plotting? 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... Stefan R-2.4.0 Windows XP Prof.
hadley wickham
2006-Oct-27 12:23 UTC
[R] qplot of ggplot package how to plot different size according to the values and not to the weights?
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
Stefan Grosse
2006-Oct-27 13:41 UTC
[R] qplot of ggplot package how to plot different size according to the values and not to the weights?
here an example with the car data qplot(drat,wt,data=mtcars,shape=as.factor(carb),col=am,size=3) it gets a bit better if one takes away the as.factor (but that of course changes other things) The picture is saved via metafile, screenshot did not work (mostly black whyever) I know its deleted for the list... Stefan -------------- next part -------------- A non-text attachment was scrubbed... Name: example.png Type: image/png Size: 7041 bytes Desc: not available Url : https://stat.ethz.ch/pipermail/r-help/attachments/20061027/be4a5ed5/attachment.png