在 R ggplot 中,有没有办法创建没有填充颜色和条形之间垂直边界的直方图?
In R ggplot, is there a way to create histograms with no filling colors and vertical borders between bars?
如下图直方图:
(来源:cern.ch)
也许 geom_step
library('ggplot2')
set.seed(1)
x <- unlist(Map(rpois, 20, 4:1 * 5))
qplot(seq_along(x), x, geom = 'step')
一种不太令人满意的方法,在没有颜色的白色填充图下使用黑色柱状图的分层。
set.seed(12)
x <- rpois(1000, 30)
bw <- 2
col <- 'black'
ggplot(data.frame(x), aes(x=x)) +
geom_histogram(binwidth=bw, color = col, fill=col, size=2) +
geom_histogram(binwidth=bw, fill='white') +
theme_bw()
如下图直方图:
(来源:cern.ch)
也许 geom_step
library('ggplot2')
set.seed(1)
x <- unlist(Map(rpois, 20, 4:1 * 5))
qplot(seq_along(x), x, geom = 'step')
一种不太令人满意的方法,在没有颜色的白色填充图下使用黑色柱状图的分层。
set.seed(12)
x <- rpois(1000, 30)
bw <- 2
col <- 'black'
ggplot(data.frame(x), aes(x=x)) +
geom_histogram(binwidth=bw, color = col, fill=col, size=2) +
geom_histogram(binwidth=bw, fill='white') +
theme_bw()