Shared axes (twin)

Source code Author Update time

using Plots
gr()

twinx (shared x axis) and twiny (shared y axis) example usage.

kw = (; lab = "", title_loc = :left)
x = π:0.1:2π
plot(x, sin.(x), xaxis = "common X label", yaxis = "Y label 1", color = :red, title = "twinx"; kw...)
pl = plot!(twinx(), x, 2 * cos.(x), yaxis = "Y label 2"; kw...)
plot(x, cos.(x), xaxis = "X label 1", yaxis = "common Y label", color = :red, title = "twiny"; kw...)
pr = plot!(twiny(), 2x, cos.(2x), xaxis = "X label 2"; kw...)
plot(pl, pr)

This page was generated using DemoCards.jl and Literate.jl.

This documentation is not for the latest stable release, but for either the development version or an older release.
Click here to go to the documentation for the latest stable release.