Width of shading lines in barplot

Viewed 1509

I created a barplot with the following script in R:

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

Is there a way to adjust the width of the shading lines? I`d like to have them thicker in order to get the same appeareance of the shaded part in 1985-89 and 2017.

1 Answers

You can adjust the width of shading using 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

Related