[R] Categorical bubble plot

Ben Bolker bbolker at gmail.com
Tue May 3 15:43:58 CEST 2011


On 11-05-03 09:23 AM, Jurgens de Bruin wrote:
> So I have been playing with bubble plot and I was able to create bubble
> plot with relatively simple data. I am no having problems when I
> increase the complexity of my data. Below is a example of my data:
> 
> phytochemical    MainClass    FitValues
> Name                     A               0.5
>                              A                0.7
>                              A                0.8
>                              B                0.1
>                              B                0.4
>                              B                0.6 
> 
> Phytochemical in on the y-axis and MainClass on the x-axis and FitValues
> is the color and size of the bubble so each x-y has more than one
> FitValue. Will the following still Work?
> 
> bubble = ggplot2.ggplot(dataf) + \
>     ggplot2.aes_string(x='mainclass', y='phytochemcial',
> col='fitvalue',size='fitvalue') + \
>     ggplot2.geom_point()
> 
> This is done in rpy2 so it may not look like R.
> 

  I would expect so, although having the bubbles overlaid on each other
may make it hard to see the results clearly.  Did you try it and see
what happens?
  In general it is better if you can provide us with full/reproducible
examples so we don't have to speculate.
  You might want to set the points partly transparent (e.g.
ggplot2.geom_point(alpha=0.5)).
  However, at this point I would also consider changing the way you are
plotting the data.  As I may have said previously (or may have been
tempted but kept my mouth shut), colour and size are at the bottom of
the "Cleveland hierarchy" -- that is, it's very hard to to reliably
interpret quantitative information on the basis of size and colour.  A
dot chart of some form would probably convey the information more
accurately.

   Ben Bolker


> Thanks!!!
> 
> On 21 April 2011 09:49, Jurgens de Bruin <debruinjj at gmail.com
> <mailto:debruinjj at gmail.com>> wrote:
> 
>     Thanks for all the help!!! 
> 
> 
>     On 16 April 2011 08:32, Tal Galili <tal.galili at gmail.com
>     <mailto:tal.galili at gmail.com>> wrote:
> 
>         Hi Jurgens,
> 
>         In the following post I show how to use balloonplot from qplots
>         to do more or less what you ask:
>         http://www.r-statistics.com/2010/02/nutritional-supplements-efficacy-score-graphing-plots-of-current-studies-results-using-r/
> 
>         p.s: the code has a slight modification to it, so to handle
>         overlapping texts.  Dear Jim, I'd be happy if some of it might
>         be considered into the official release.
> 
>         Cheers,
>         Tal
> 
>         ----------------Contact
>         Details:-------------------------------------------------------
>         Contact me: Tal.Galili at gmail.com <mailto:Tal.Galili at gmail.com>
>         |  972-52-7275845
>         Read me: www.talgalili.com <http://www.talgalili.com> (Hebrew) |
>         www.biostatistics.co.il <http://www.biostatistics.co.il>
>         (Hebrew) | www.r-statistics.com <http://www.r-statistics.com>
>         (English)
>         ----------------------------------------------------------------------------------------------
> 
> 
> 
> 
>         On Fri, Apr 15, 2011 at 4:19 PM, Ben Bolker <bbolker at gmail.com
>         <mailto:bbolker at gmail.com>> wrote:
> 
>             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>
>             > <mailto:bbolker at gmail.com <mailto:bbolker at gmail.com>>> wrote:
>             >
>             >     Jurgens de Bruin <debruinjj <at> gmail.com
>             <http://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>
>             <mailto: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
> 
>             ______________________________________________
> 
>             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
> 
> 
> 
> 
> -- 
> 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