My take on polar bar (a.k.a. consultant’s) charts

[This article was first published on gRaphics!, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here)
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

Once upon a time, when I was working at Johnson & Johnson (pharma branch), I was surrounded by a bunch of programmers working to develop (among other things) a nifty piece of software for internal use. Part of it was later released as freeware, called Vlaaivis. The main idea was to visualize each the compound’s many data at once, with each property being represented by a slice within the pie. For each property, ti was possible to define an ideal value, or range, and values above or below that one would show up as incomplete slices of two shades of the same color… This way, the fuller the pie the better, or more ‘dieal’, the compound under exam would be.
You may find it still at its home,

As I moved on to different things, I still remembered this as a good way of visualising multifactorial data, especially when comparing several candidates (compounds, in my case). Inspired by a post on LearnR, I decided to start reimplementing something similar in R for use within our own group.

The most significant change from the LearnR post is that I added in a ‘facets_grid()’ call to the ggplot, so as to split the polar bar chart in the different compounds. Thanks to the faceting, all compounds are plotted on the same ‘space’ and are therefore immediately comparable.

The other, minor, change I made was to create the dataframe as a matrix, which is the way we usually store such kind of data, and use ‘melt’, from the package ‘reshape’, to convert it into a form suitable for plotting as bar chart (polar or not). I left in the comments an option for reading in the data from a text file…

Here’s the dummy template I came up with:

And here’s my output:

If, as I described previously, the bars were some kind of normalised score, such as the recently suggested druglikeness score, then the fuller the pie, the better looking the compound would be for a medicinal chemist.

I omitted the legend, since the variable names (a-e) is present in each plot (does anyone know how can I get rid of the 0.5 legend key? it comes from the alpha definition in the ggplot).

Two major things left to do:

  1. I would like to plot the compound in order of ‘fullness’ – a sort/order snippet is there in the code, and the new ordering survives the melting of the matrix – however, ggplot seems to rearrange the data according to some internal order… (Thanks to Christoph for fixing this)
  2. Right now, the code isn’t suitable for too many compounds, since the facets_grid() will arrange them horizontally. I would be grateful if someone were to let me know how to automatically arrange them in a grid of a given maximum number of columns… I know how to do that when I explicitly create each plot, but then I loose the ease of comparison which comes from all compounds being plotted on the same scale… ( Thanks to Christoph for fixing this too)

I’ll update this text and the code as I improve the visualization.

If you don’t feel like messing around with code, you can always try and build a similar plot using deduceR:

Hope one or more of you find this useful!

To leave a comment for the author, please follow the link and comment on their blog: gRaphics!. offers daily e-mail updates about R news and tutorials about learning R and many other topics. Click here if you're looking to post or find an R/data-science job.
Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

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)