Skip to content

bar plot colors

6 messages · Winkel, David, Hadley Wickham, Jim Lemon +1 more

#
What are you trying to achieve with such a plot?  A stacked bar chart
only allows easy comparisons of cumulative totals (eg. cost 1, or cost
1 + 2, or cost 1 + 2 + 3) and it will be very difficult to compare
individual cost types or components within a type.  You might want to
think about a series of line plots instead.

Hadley
#
Winkel, David wrote:
Hi David,
This is a real challenge:

heights<-matrix(sample(10:70,54),ncol=3)
bar.colors<-rep(rep(2:7,each=3),3)
bar.densities<-rep(10,54)
bar.angles<-matrix(rep(rep(c(45,90,135),6),3),ncol=3)
barplot(heights,col=bar.colors)
barplot(heights,angle=bar.angles,add=TRUE,density=bar.densities)

Jim
#
I think you're going to find that barchart with that
many values in a bar is going to be pretty well
uninterpretable.  

Jim Lemon gives the desired barchart but it is very
difficult to read.  

Stealing his code to create the same matrix I'd
suggest may be looking at a dotchart.  I'm not sure if
this is even close to an optimal solution but I do
think it's a bit better than a barchart approach
======================================================
heights<-matrix(sample(10:70,54),ncol=3)
bar.colors<-rep(rep(2:7,each=3),3)
cost.types <- c("Direct", "Indirec", "Induced")
colnames(heights) <-  c("A", "B", "C")
rownames(heights) <- c(rep(cost.types, 6))

dotchart(heights, col=bar.colors, pch=16, cex=.6)

=======================================================
--- "Winkel, David" <WinkelD at BATTELLE.ORG> wrote:

            
#
John Kane wrote:
Very nice John, but it does look like someone dropped the M&Ms.
Jim
#
--- Jim Lemon <jim at bitwrit.com.au> wrote:

            
======================================================
=======================================================
Please I'm Canadian, we have Smarties. Much nicer than
M&Ms :)  

It is a bit garish but I didn't see a fast way to turn
off the colours on the axis though from the Help it
looks possible.



[[replacing trailing spam]]