Essentially:
I want to draw a bar-graph that shows the aggregated value of two table columns, which I have managed to do using:
err.bar <- ggplot(ss.data, aes(x=pop, y=obs+proc)) err.bar <- err.bar + geom_bar(position="stack", stat = "identity") err.bar
I want to shade, not necessarily color, the two parts of the aggregated bars.
Finally I want to color the bars by grouping them according to species (i.e., by species E & C as indicated on the x-axis labels on the Excel graph)
The data I am using is similar to:
- pop E1 E2 E3 E4 E5 E6 E7 C1 C2 C3 C4
- obs 0.0027 0.0018 0.0464 0.0095 0.0034 0.0117 0.017 0.1178 0.0449 0.039 0.0903
- proc 0.0319 0.0196 0.0511 0.0143 0.0048 0.0078 0.0396 0.1662 0.074 0.1681 0.1358
Here is a solution that gets you most of what you want. But please note that ggplot is not designed to allow separate 'shade' and 'color' parameters in a single plot. Instead, I have shaded your
obs
andproc
categories using grey fill colors, and I have grouped the species into facets (instead of coloring them differently).