[英]How to create black and white transparent overlapping histograms using ggplot2?
我用ggplot2創建了兩個透明的重疊直方圖。
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
結果情節看起來很棒,但它是彩色的。 我需要灰度或黑/白情節。
使用“scale_fill_grey()”會導致具有透明度的圖表非常難以“閱讀”。
理想情況下,我想要一個使用紋理而不是顏色的黑/白圖,例如,交叉影線:“///”表示一個條件,“\\\\\\”表示另一個條件,當條形圖產生“XXX”交疊。 這可能嗎?
怎么樣(沒有紋理)?
fig = ggplot(test, aes(x = value, fill = condition)) +
geom_histogram(position = "identity", alpha = .8) +
scale_fill_manual(values=c("grey20", "grey60")) + theme_bw()
fig
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.