View source: R/ScalePreviousPlot.R
| ScalePreviousPlot | R Documentation | 
Return a list with the limits of the previous plot, the center, the range, and the position of label on this axe.
ScalePreviousPlot(x = NULL, y = NULL)
| x | The position in x as relative position | 
| y | The position in y as relative position | 
ScalePreviousPlot returns the scale of the previous plot
A list with xlim and ylim
Marc Girondot marc.girondot@gmail.com
Other plot and barplot functions: 
barplot_errbar(),
plot_add(),
plot_errbar(),
show_name()
## Not run: 
par(xaxs="i", yaxs="i")
plot(x=1:100, y=sin(1:100), type="l", bty="n", xlim=c(1,200), xlab="x", ylab="y")
xlim= ScalePreviousPlot()$xlim[1:2]
ylim= ScalePreviousPlot()$ylim[1:2]
par(xaxs="r", yaxs="i")
plot(x=1:100, y=sin(1:100), type="l", bty="n", xlim=c(1,200), xlab="x", ylab="y")
xlim= ScalePreviousPlot()$xlim[1:2]
ylim= ScalePreviousPlot()$ylim[1:2]
# Here is an example of the use of the label output
plot(x=1:100, y=sin(1:100), type="l", bty="n", xlim=c(1,200), xlab="", ylab="")
text(x=ScalePreviousPlot()$xlim["label"], y=ScalePreviousPlot()$ylim["center"], 
  xpd=TRUE, "Legend for Y axes", pos=3, srt=90)
text(x=ScalePreviousPlot()$xlim["center"], y=ScalePreviousPlot()$ylim["label"], 
  xpd=TRUE, "Legend for X axes", pos=1)
Example to plot legend always in the same place
layout(1:2)
plot(x=1:100, y=sin(1:100), type="l", bty="n", xlim=c(1,200), xlab="", ylab="")
text(x=ScalePreviousPlot(x=0.95, y=0.05)$x, 
     y=ScalePreviousPlot(x=0.95, y=0.05)$y, 
     labels="A", cex=2)
plot(x=0:1, y=0:1, type="p", bty="n")
text(x=ScalePreviousPlot(x=0.95, y=0.05)$x, 
     y=ScalePreviousPlot(x=0.95, y=0.05)$y, 
     labels="B", cex=2)
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.