如何去除ggplot2柱状图(Bar Plot)中的内部线条?
解决无内部线条柱状图的问题
你代码里的color = 'red'是给柱状图加了红色边框线条,这就是你看到的那些“内部线条”(实际是柱子的轮廓线)。要去掉这些线条,两种简单方法:
方法1:删掉color参数
直接移除color = 'red',ggplot默认不会显示边框:
library(ggplot2) ggplot(data = Datoshoja1, aes(x = `AreaName`, y = `1990.0`)) + geom_bar(stat="identity", fill = 'darkred') + labs(title= 'Inmigrantes en EEUU año 1990', x = '', y = 'Cantidad de inmigrantes')
方法2:设置color = NA
如果想保留参数结构,把color设为NA就能隐藏边框:
library(ggplot2) ggplot(data = Datoshoja1, aes(x = `AreaName`, y = `1990.0`)) + geom_bar(stat="identity", color = NA, fill = 'darkred') + labs(title= 'Inmigrantes en EEUU año 1990', x = '', y = 'Cantidad de inmigrantes')
两种方法都能让柱状图没有额外的轮廓线条,达到你要的无内部线条效果。
内容的提问来源于stack exchange,提问作者Arie Goldstein
相关产品推荐
相关产品推荐

