Learn R Programming

pracma (version 0.9.6)

plotyy: Plotting Two y-Axes

Description

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

Usage

plotyy(x, y1, y2, grid = TRUE, box.col = "grey",
                  type = "l", lwd = 1, lty = 1,
                  col.y1 = "navy", col.y2 = "maroon", ...)

Arguments

x
the common x-coordinates for both curves
y1, y2
the y-values, with ordinates y1 left, y2 right.
grid
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).
col.y1, col.y2
colors to be used for the lines or points.
...
additional plotting parameters.

Value

  • Generates a graph, no return values.

Details

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

The x-values are common for the moment. To exclude certain points, use NA values. Both curves will be line or point plots, and have the same line type and width.

See Also

plotrix::twoord.plot

Examples

Run this code
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, y2, main = "Double y-Axis")

Run the code above in your browser using DataLab