中不断出现
我希望在R中生成条形图,每个条形图有一种颜色,但在同一条形图中有多种颜色的阴影。例如,我尝试过:
barplot(c(2:6), ylim=c(1,10), col="blue", space=3)
这给了我蓝色的条形图,但我希望顶部区域看起来比底部区域稍微浅一点的蓝色。
我也试过:
barplot(c(2:6), ylim=c(1,10), col="blue", space=3,density=40)
但这不是我所希望的,因为它再次在整个图
这来自https://stats.stackexchange.com/questions/17460/what-is-the-best-way-to-visualize-a-single-numeric-variable-as-a-heatmap
我只是刚刚发现了这个,但我认为这可能有用。
require(fields)
plot(1:10, rep(1,10), ylim=c(0,10))
colorbar.plot( 2, 4, 800*density(rgamma(100, shape=2))$y)
colorbar.plot( 2, 5, 800*density(rexp(100))$y)
colorbar.plot( 2, 6, 800*density(rnorm(100))$y)
colorbar.plot( 2, 7, 800*density(rlnorm(100))$y)
text(6,4, "Gamma")
text(6,5, "Exponential")
text(6,6, "Normal")
text(6,7, "LogNormal")
你的意思是这样的吗?
barplot(c(2:6), ylim=c(1,10), col="blue", space=3, density=seq(60, 100, 10))
或
barplot(c(2:6), ylim=c(1,10), col=blues9[2:6], space=3)