I'd like to draw thick angled lines in R without changing the border width. Here's an example where the border width is also changed:
barplot(c(3,4,5),col="red")
par(lwd=8)
barplot(c(3,4,5),col="blue",density=5,angle=45,add=T)
par(lwd=1)

Here's an attempt at doing the same thing but removing the borders, however the blue then bleeds into the background, which doesn't look good either. I need to have a thin black border.:
barplot(c(3,4,5),col="red")
par(lwd=8)
barplot(c(3,4,5),col="blue",density=5,angle=45,border=NA,add=T)
par(lwd=1)

Any other ideas? (without using ggplot)
You could use ablineclip of plotrix package
graphics.off()
x = c(3, 4, 5)
w = 2
b = barplot(x, col = "red", width = w)
par(lwd = 8)
library(plotrix)
for(i in seq_along(b)){
for (p in seq(-(b[i] + w/2), x[i], 0.25)) {
ablineclip(a = p, b = pi/8, x1 = b[i] - w/2,
x2 = b[i] + w/2, col = "blue", y1 = 0, y2 = x[i])
}
}

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With