Suppose I have a dataset like:
case before after
1 -1 2.3
2 1.2 2.9
3 3 1
4 2 -1.5
(etc.; N=20 cases)
I would like to produce a plot with N vertical bars (possibly touching, or
possibly separated with a little space, whichever looks better). The
horizontal axis runs from 1 to N, and the vertical axis runs over the range
of the data (from -3 to +3, in fact). Each vertical bar would go from
min(before,after) to max(before,after) for the row (case) it represents.
Then, if after > before, I would leave the bar unshaded, but if before >
after, I would shade in the bar.
Does anyone see an easy way to accomplish this, short of writing a function
to plot all the lines individually? And even if I did that, how could I
accomplish the shading?
(Actually, I have multiple sets of these, and would like to put an array of
such plots on a single page, but I think I can accomplish that part.)
Thanks for any help.
Dave Parkhurst
|