I know, 3D Barcharts are a sin. But i´m asked to do them and as a trade-off i suggested to only make a border with a slightly darker color than the bar´s on the top and the right side of the bar. Like that, the bars would have some kind of "shadow" (urgh) but at least you still would be able to compare them.
Is there any way to do this?
ggplot(diamonds, aes(clarity)) + geom_bar()
As you already said - 3D barcharts are "bad". You can't do it directly in ggplot2 but here is a possible workaround for this.
First, make new data frame that contains levels of clarity and corresponding count for each level.
Then in
ggplot()
call use new data frame andclarity
as x values andV1
(counts) as y values and addgeom_blank()
- this will make x axis with levels we need. Then addgeom_rect()
to produce shading for bars - herexmin
andxmax
values are madeas.numeric()
fromclarity
and constant is added - forxmin
constant should be less than half of bars width andxmax
constant larger than half of bars width.ymin
is 0 andymax
isV1
(counts) plus some constant. Finally addgeom_bar(stat="identity")
above this shadow to plot actually barplot.Another possibility, using two sets of
geom_bar
. The first set, the green ones, are made slightly higher and offset to the right. I borrow the data from @Didzis Elferts.