How can (x axis) labels of different heights be horizontally aligned? Here is an example:
nms <- c(expression(A), expression(B), expression(C),
expression(D[1]), expression(E^1), expression(F))
boxplot(count ~ spray, data=InsectSprays, names=nms)
The label "E" is nicely aligned with A,B,C and F, but D_1 isn't. How can D_1 be aligned with the other labels as well?
You can plot manually the axis using mtext
for example.
## reset defalt names
boxplot(count ~ spray, data=InsectSprays,names=NA)
## adjustemnt vectors , see that only d_1 has an adj !=0
adj=c(0,0,0,0.2,0,0)
## loop over expressions and plot them one by one
for(s in seq_along(nms))
mtext(nms[s], side=1, line=1,at=s,padj=adj[s])
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