plot(runif(2), runif(2), type='n', xaxt = 'n', yaxt = 'n', xlab='', ylab='', log='y')
points(par('usr')[1], 10^par('usr')[3], pch=20, xpd=NA)
I can plot at the bottom-left corner of the plot region. How to get the y-coordinate in the middle between the bottom of the figure region and the bottom of the plot region?
CodePudding user response:
set.seed(42)
plot(runif(2), runif(2), type='n', xaxt = 'n', yaxt = 'n', xlab='', ylab='', log='y')
points(mean(par('usr')[1:2]), 10^par('usr')[3], pch=20, xpd=NA)
Or perhaps you want
points(mean(par('usr')[1:2]), 10^(par('usr')[3]/.875), pch=20, xpd=TRUE)
CodePudding user response:
It's difficult to tell from your description where you want the point to be. From my reading of your question, I assumed you meant this:
plot(runif(2), runif(2), type='n', xaxt = 'n', yaxt = 'n', xlab='', ylab='', log='y')
points(par('usr')[1], 10^par('usr')[3], pch=20, xpd=NA)
plot_height_ins <- dev.size()[2] - sum(par('mai')[c(1, 3)] par('omi')[c(1, 3)])
y_per_in <- diff(par('usr')[3:4]) / plot_height_ins
half_margin <- y_per_in * (par('mai')[1] par('omi')[1]) / 2
points(mean(par('usr')[1:2]), 10^(par('usr')[3] - half_margin), xpd = NA)