I’m trying to produce barplot in which the width and height of the bars both convey information: the height is the number of hours spent on a task, the widths respectively indicate the perceived aptitude and importance associated with the task. I’ve managed to produce this monstrosity:
It’s functional but horrible. I would really like to place the bars alongside one another (rather than overlaying them), so that each activity is represented by two touching bars of the same height (=time spent) but different widths and colors. I’ve been trying to to pass a width argument to this plot:
but setting ‘aes(width = widthVariable)’ gives me overlapping bars (similar to the first image) and the following warning message:
“position_dodge requires non-overlapping x intervals”.
Is there a way of grouping my bars by activity, displaying them adjacently and varying their widths?
Here’s a bit of the df I’m using:
molten = data.frame(Activity = rep(c('Administration','Working with Colleagues','Use of Social Media','Leadership Role'),2), variable = c(rep('Importance',4),rep('Competence',4)), value = rep(c(3.02,1.71,2.39,3.32),2), width = c(3.48,3.52,4.01,2.98, 3.85,2.34,4.87,3.81))
The second plot is this:
ggplot(molten, aes(x=Activity, y=value, fill=variable)) + geom_bar(stat='identity',position = 'dodge')
and the first in something like this:
ggplot(molten, aes(x=Activity, y=value, fill=variable)) + geom_bar(stat='identity',aes(width = width/10))
Although I actually made it using slightly simpler dataframe, which I melt()-ed into the one above.