Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R plot: Print text on margin in top left corner

Tags:

plot

r

I have the following basic code to plot a grid.

grid <- expand.grid( pi=seq(50, 95, 5) / 100, mu2=seq(5, .5, -.5) )
pi <- seq(44, 100, .5) / 100
par( mai=c(.05, .05, .05, .05), oma=c(2.9, 2.9, 0, 0) ) # Make room for label
plot( grid, cex=.5, xlab="", ylab="", cex.axis=.7 )

How can I plot a text label such as "(A)" in the top left corner as indicated by the red circle?

Edit: The "(A)" should be printed in regular, i.e., horizontal, reading direction; not vertically along with the y-axis.

enter image description here

like image 692
Chris Avatar asked Jan 20 '26 00:01

Chris


1 Answers

You can use mtext to place text outside of the margins:

##Look at the help page for further details    
mtext("A", 2, adj=1, line=2)

##To rotate "A", try
mtext("A", 2, adj=5, las=1, padj=-22)

to get:

enter image description here

like image 136
csgillespie Avatar answered Jan 22 '26 21:01

csgillespie



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!