Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to control axis label position parallel to axis

Tags:

plot

r

The axis labels for plots in R default to the center of their respective axis. I would like to move the axis labels to the ends of the axes so that the horizontal "x" label is at the far right and the vertical "y" label is at the far top. What are some recommended ways to do this? Can one use mtext in a clever way?

like image 703
BMS Avatar asked Dec 12 '25 19:12

BMS


1 Answers

Using mtext and playing with adj parameter:

plot(0,ann=FALSE)
mtext('right',side=1,line=2,adj=1,col='red',cex=2)
mtext('top',side=2,line=2,adj=1,col='blue',cex=2)

enter image description here

like image 91
agstudy Avatar answered Dec 14 '25 12:12

agstudy



Donate For Us

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