2

I have recently discovered this visualization of the connection between obesity and hunger by JESS3: http://jess3.com/obesity-and-hunger-infographic/

As I like the information/space ratio I have tried to come up with a similar graph in R (i.e. a polar plot with scatter points in the center, and at the end of the center, a stacked barchart starts with a new axis from 0 to x. However, I did not find a way to implement the stacking of different polarplot versions in plotrix or ggplot2.

To illustrate, how in a very basic version, the two individual graphs should look like, I created a simple example with the mtcars package:

library(plotrix)

##load mtcars as example dataset
d.raw <- mtcars

## draw inner polar plot with scatter plot for mpg

polar.plot(d.raw$mpg, clockwise=TRUE, rp.type="s", start=90)

#### draw additional polar plot (which should be added outside of first plot in the end) as stacked bar chart with hp and a fictitious added column with random values between 1 and 100% 

##come up with percentages and multiply the with hp bar to get a random stacked bar of hp and this
d.raw$fict <- sample(100,32)*0.01
d.raw$hpshare <- d.raw$fict*d.raw$hp

## draw plot (first the hp and then add on top a second layer with the share of hp)
polar.plot(d.raw$hp, clockwise=TRUE, rp.type="r", lwd=5, line.col=2, start=90, radial.lim=c(0,350))
par(new=T)
polar.plot(d.raw$hpshare, clockwise=TRUE, rp.type="r", lwd=5, line.col=4, start=90, radial.lim=c(0,350))

Is it possible, and if so, how can I achieve that a new axis starts and the bars are added outside of the scatterplot?

Thank you very much in advance, all hints are very much appreciated!

Jilber Urbina
  • 58,147
  • 10
  • 114
  • 138
Carsten
  • 23
  • 3

1 Answers1

3

May this ugly hack inspire you, but seriously stick to js + photoshop for these kind of high-end/creative graphics.

library(reshape2)
library(ggplot2)
cake = data.frame(y = -1*abs(rnorm(100)), x = runif(100,-5, 5), g = sample(1:4, 100, replace = T))
pie = data.frame(x = runif(100, -5, 5), g = sample(1:4, 100, replace = T))

ggplot() + geom_bar(data = pie, aes(x, fill = factor(g)), position = "stack") +
  geom_point(data = cake, aes(x,y, color = factor(g))) + geom_text(aes(x=-0.5,y=2), label = "Cake is pie", angle = 110) + coord_polar()

enter image description here

Vlo
  • 3,168
  • 13
  • 27