Learn R Programming

HelpersMG (version 3.6)

ScalePreviousPlot: Return the scale of the previous plot

Description

Return a list with the limits of the previous plot, the center, the range, and the position of label on this axe.

Usage

ScalePreviousPlot()

Arguments

Value

A list with xlim and ylim

Details

ScalePreviousPlot returns the scale of the previous plot

See Also

Other plot and barplot functions: barplot_errbar, plot_add, plot_errbar

Examples

Run this code
# 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)
# }

Run the code above in your browser using DataLab