# gRaphics! 2012-05-12 14:07:00

May 12, 2012
By

(This article was first published on gRaphics!, and kindly contributed to R-bloggers)

My own version of bubble plot (part 1)

During one of my projects, I found myself in need of visualizing more than 3 dimensions at once. Three-dimensional graphs are not a good solution, usually – they will need to be properly oriented, for a start, ad that’s tricky.
So, I started looking at bubble plots. The size of the bubble can show one property, as illustrated by the nice post at FlowingData – then you can show one more property defined by a color scale (continuous below, but nothing stops it from being categorical)
I decided to push it and have two properties: look at the example below – the redder the color, the higher the value on the property ApKUpt (or whatever you want). The greener, the higher ApVUpt. I moved the color legend to a square on the extreme right to achieve a better use of the available space.

I tried three colors but it turns out that it just doesn’t work. Even when your eyes don’t interpret every rgb triplet as a completely different color, the amount of redness, greeness or blueness is difficult to estimate. Also, it gets tricky to show the color grading in a legend… One has to resort to slices of the three-dimensional color space. See what I mean?
Of course, one can define an ad-hoc color scale, such as the one used below, vaguely inspired by the colors that Mathematica uses to paint its surfaces. Many thanks to my colleague Pär for teaching me how to define these kind of color scales, and much else.

Here follows the code for the one, two and three colors plot:

It’s messy and not at all clean – but it gets the job done. This routine is also dependent from several others which define colorscale and other accessory functions… feel free to drop me a line in the comments if you want the lot… Similar plots can be obtained with ggplot2 in much fewer lines, although right now I’m less expert at it so they’re much less customised.

R-bloggers.com offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

## Recent popular posts

Contact us if you wish to help support R-bloggers, and place your banner here.

# Never miss an update! Subscribe to R-bloggers to receive e-mails with the latest R posts.(You will not see this message again.)

Click here to close (This popup will not appear again)