Abline and lines() over boxplot.
I want to draw abline() and lines() over several bin boxplots but when I do the lines act as if all of the data is in the first boxplot. X is on a scale from 0 to 1. If I use add=TRUE the boxplot just draws a line twoards the right. Could I use roll/apply for quartiles and plot that as a line? This is the code that works for me so far:
png(file = paste ("MADM",VClab,VClaby,purpose,"8.png", sep = " ", collapse = NULL),width = 1400, height = 900 )
plot(VC2,VecBuf4, xlab = VClab, ylab = VClaby)
lad.D3 <- lad(VecBuf4 ~ VC2)
abline(a=median(VecBuf4),b=0)
print(median(VC2))
print(mean(VC2))
abline(lad.D3)
lines(lowess(VC2,VecBuf4, f = .2, iter = 9), col="red")
lines(locfit( VecBuf4~VC2), col="green")
lines(lowess(VC2,VecBuf4, f = .9, iter = 9), col="purple")
lines(locfit.robust( VecBuf4~lp(VC2)), col="yellow")
lm.D10 <- lm(VecBuf4 ~ VecBufQuant)
abline(lm.D10,col = "blue")
mtext(purpose)#, side = 3, line = 0, outer = TRUE)
dev.off()
Posted Feb 16, 2017, 10:26 PM UTC · edited
34