R ggplot2-带边框的几何图形条=NA
我正在尝试使用R ggplot2-带边框的几何图形条=NA,r,ggplot2,dplyr,R,Ggplot2,Dplyr,我正在尝试使用ggplot2生成堆叠图,但无法去除条间的白色细线 使用basebarplot函数,使用参数border=NA可以得到我想要的(右图) 然而,我无法用ggplot2使这些边界消失 library(ggplot2) library(dplyr) library(broom) library(reshape2) df %>% melt() %>% ggplot(aes(Var2, value, fill = factor(Var1))) + geom_ba
ggplot2
生成堆叠图,但无法去除条间的白色细线
使用basebarplot
函数,使用参数border=NA
可以得到我想要的(右图)
然而,我无法用ggplot2
使这些边界消失
library(ggplot2)
library(dplyr)
library(broom)
library(reshape2)
df %>% melt() %>% ggplot(aes(Var2, value, fill = factor(Var1))) +
geom_bar(stat = 'identity', width=0.9) +
scale_fill_manual(values = c('orange', 'khaki')) + theme_minimal()
有什么想法吗
我不想要geom_区域
解决方案
geom_area(stat = 'identity', position = "stack")
数据
几何图形栏
层中的宽度
设置为0.9
。如果将其设置为1.0
,条形图将填充空间,边框将消失
df %>% melt() %>% ggplot(aes(Var2, value, fill = factor(Var1))) +
geom_bar(stat = 'identity', width = 1) +
scale_fill_manual(values = c('orange', 'khaki')) + theme_minimal()
宽度条宽。默认情况下,设置为数据分辨率的90%
sq = round( sort(rnorm(100, 50, 10)))
df = matrix(0, 2, 100)
df[1, ] = sq
df[2, ] = 100 - sq
df %>% melt() %>% ggplot(aes(Var2, value, fill = factor(Var1))) +
geom_bar(stat = 'identity', width = 1) +
scale_fill_manual(values = c('orange', 'khaki')) + theme_minimal()