您可以使用
禁用黑色边框
geom_bar(...,colour = "NA")
然后需要重新绘制它们。
根据需要调整width
和+/- 0.5
,以适当地间隔条形图。
library(dplyr)
library(ggplot2)
x <- iris %>%
group_by(Species) %>%
summarise(m=mean(Sepal.Length)) %>%
mutate(Species.x = as.integer(as.factor(Species))) %>% ungroup
y <- bind_rows(
x %>%
mutate(
Species.x = Species.x - 0.5,y = 0
),x %>%
mutate(
Species.x = Species.x - 0.5,y = m
),x %>%
mutate(
Species.x = Species.x + 0.5,y = 0
)
)
ggplot(x,aes(Species.x,m)) +
geom_col(aes( fill=Species),colour=NA,width=1) +
geom_path(data=y,aes(y=y,group=Species),color='black') +
scale_x_continuous(breaks=x$Species.x,labels=x$Species)
本文链接:https://www.f2er.com/3117706.html