2017-09-25 111 views
1

我创建了R中的以下脚本barplot:阴影的宽度线barplot

bars <- c(229, 158) 
shading.lines <- c(83, 83) 
years <- c("1985-89", "2017") 
cols1 <- c("indianred4","green4") 
cols2 <- c("green4","indianred4") 
barplot(bars,names.arg=years,col=cols1) 
barplot(shading.lines,names.arg=NA,col=cols2,density=11,add=T) 

enter image description here

是否有办法来调整阴影线的宽度是多少?我想要一份,让他们更厚,以获得阴影部分的相同appeareance在1985-89和2017年

+0

请阅读关于[如何提出一个好问题](http://stackoverflow.com/help/how-to-ask)以及如何给出[可重现的示例]的信息(http://stackoverflow.com/questions/5963269 /如何对化妆一个伟大-R-重复性,例如/ 5963610)。这会让其他人更容易帮助你。 – Jaap

+0

@ Jaap:对不起,我在创建此问题时意外关闭了该选项卡。然后显然,它被发布到stackoverflow。这不是我的目标,我将在编辑时再次发布。 – yenats

回答

1

可以使用par(lwd=...)调整阴影的宽度:

bars <- c(229, 158) 
shading.lines <- c(83, 83) 
years <- c("1985-89", "2017") 
cols1 <- c("indianred4","green4") 
cols2 <- c("green4","indianred4") 
barplot(bars,names.arg=years,col=cols1) 
# Set width of shading 
par(lwd=5) 
barplot(shading.lines,names.arg=NA,col=cols2,density=11,add=T) 
# Set width of shading to the default value 
par(lwd=1) 

enter image description here