Skip to content
Prev 198989 / 398506 Next

Stacked barplot: specifying individual bar hue/luminance

Hi all,

I'm trying to generate barplots from simple but long (~100000-row) data
files, in which each bar will comprise two stacked 'sub-bars'.  All the
upper sub-bars will have the same hue, and all the lower bars will,
likewise, have another uniform hue.  However, I wish to specify the
luminance (aka brightness) of each bar (i.e., each whole bar comprising two
sub-bars) separately, and I wish the plot to render without spaces between
successive bars. 

I've been trying to get this going in ggplot2.  Two problems arise: first,
I'm unable to eliminate the spaces between successive bars.  And second (and
more importantly), while I can vary transparency (i.e., alpha) of bars
singly, I'm not sophisticated enough with the grammar to know how to define
a color palette that lets me vary the luminance singly.  Can anyone suggest
how to do this, either in ggplot or in basic R (or some other package)?

Many thanks,

Nathan Pearson
nathaniel.pearson at gmail.com