[英]ggplot2 - geom_bar with border = NA
我正在嘗試使用ggplot2
生成堆積圖, ggplot2
無法消除條形圖之間的白色細線。
使用基本的barplot
函數時,使用border = NA
參數可以得到所需的信息(右圖)
barplot(df, border = NA, space = 0, col = c('orange', 'khaki'), main = '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_area
解決方案
geom_area(stat = 'identity', position = "stack")
sq = round( sort(rnorm(100, 50, 10)))
df = matrix(0, 2, 100)
df[1, ] = sq
df[2, ] = 100 - sq
geom_bar
層中的width
設置為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%。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.