r - How to create black and white transparent overlapping histograms using ggplot2? -
i used ggplot2 create 2 transparent overlapping histograms.
test = data.frame(condition = rep(c("a", "b"), each = 500), value = rep(-1, 1000)) test[1:500,]$value = rnorm(500) test[501:1000,]$value = rnorm(500) + 2 fig = ggplot(test, aes(x = value, fill = condition)) + #scale_fill_grey() + geom_histogram(position = "identity", alpha = .5) fig
the resulting plot looks great, it's in color. need grayscale or black/white plot.
using "scale_fill_grey()" results in plot transparency difficult "read".
ideally, black/white plot uses texture instead of color, instance, cross hatching: "///" 1 condition, "\\\" other condition, resulting in "xxx" when bars overlap. possible?
how (no texturing still)?
fig = ggplot(test, aes(x = value, fill = condition)) + geom_histogram(position = "identity", alpha = .8) + scale_fill_manual(values=c("grey20", "grey60")) + theme_bw() fig
Comments
Post a Comment