[R] Categorical bubble plot

Ben Bolker bbolker at gmail.com
Fri Apr 15 15:19:25 CEST 2011


On 04/15/2011 01:13 AM, Jurgens de Bruin wrote:
> Thanks for the reply...
> 
> with reproducible I am believe you require a dataset?

  yes -- but you can make one up if you like.  e.g.


dd <- expand.grid(drugclass=LETTERS[1:5],
   plant=c("cactus","sequoia","mistletoe"))
set.seed(101)
dd$fitvalue <- runif(nrow(dd))

library(ggplot2)
ggplot(dd,aes(x=drugclass,y=plant,colour=fitvalue,size=fitvalue))+
  geom_point()

  By the way, I think you could represent your data much more
clearly this way: the "Cleveland hierarchy" says that it's easier
to assess quantitative values plotted along a common scale than via
size or colour ...

ggplot(dd,aes(x=drugclass,y=fitvalue,colour=plant))+
  geom_point()+geom_line(aes(group=plant))



> The size of the bubbles will be related to the fitvalues.
> 
> 
> 
> On 14 April 2011 17:57, Ben Bolker <bbolker at gmail.com
> <mailto:bbolker at gmail.com>> wrote:
> 
>     Jurgens de Bruin <debruinjj <at> gmail.com <http://gmail.com>> writes:
> 
>     >
>     > Hi,
>     >
>     > I do not have much R experience just the basics, so please excuse
>     > any obvious questions.
>     >
>     > I would like to create bubble plot that have Categorical data on
>     the x and y
>     > axis and then the diameter if the bubble the value related to x and y.
>     >  Attached to the email is a pic of what I would like to do.
>     >
> 
>      A reproducible example would be great.
> 
>     something along the lines of
> 
>     library(ggplot2)
>     ggplot(mydata,aes(x=drugclass,y=plant,colour=fitvalue,size=?))+geom_point()
> 
>      it's not clear from your description what determines the size.
>      From a labeling point of view, switching x and y might be useful.
> 
>     ______________________________________________
>     R-help at r-project.org <mailto: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.
> 
> 
> 
> 
> -- 
> Regards/Groete/Mit freundlichen Grüßen/recuerdos/meilleures salutations/
> distinti saluti/siong/duì yú/привет
> 
> Jurgens de Bruin



More information about the R-help mailing list