Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

plotyy

Plotting Two y-Axes


Description

Line plot with y-axes on both left and right side.

Usage

plotyy(x1, y1, x2, y2, gridp = TRUE, box.col = "grey",
                       type = "l", lwd = 1, lty = 1,
                       xlab = "x", ylab = "y", main = "",
                       col.y1 = "navy", col.y2 = "maroon", ...)

Arguments

x1, x2

x-coordinates for the curves

y1, y2

the y-values, with ordinates y1 left, y2 right.

gridp

logical; shall a grid be plotted.

box.col

color of surrounding box.

type

type of the curves, line or points (for both data).

lwd

line width (for both data).

lty

line type (for both data).

xlab, ylab

text below and on the left.

main

main title of the plot.

col.y1, col.y2

colors to be used for the lines or points.

...

additional plotting parameters.

Details

Plots y1 versus x1 with y-axis labeling on the left and plots y2 versus x2 with y-axis labeling on the right.

The x-values should not be too far appart. To exclude certain points, use NA values. Both curves will be line or point plots, and have the same line type and width.

Value

Generates a graph, no return values.

See Also

plotrix::twoord.plot

Examples

## Not run: 
x  <- seq(0, 20, by = 0.01)
y1 <- 200*exp(-0.05*x)*sin(x)
y2 <- 0.8*exp(-0.5*x)*sin(10*x)

plotyy(x, y1, x, y2, main = "Two-ordinates Plot")

## End(Not run)

pracma

Practical Numerical Math Functions

v2.3.3
GPL (>= 3)
Authors
Hans W. Borchers [aut, cre]
Initial release
2021-01-22

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.