diff --git a/src/Plots.jl b/src/Plots.jl index 971813a3..04e853d1 100644 --- a/src/Plots.jl +++ b/src/Plots.jl @@ -69,6 +69,7 @@ export default, with, twinx, + twiny, pie, pie!, diff --git a/src/layouts.jl b/src/layouts.jl index 6f0548de..9187d782 100644 --- a/src/layouts.jl +++ b/src/layouts.jl @@ -681,3 +681,16 @@ function twinx(sp::Subplot) end twinx(plt::Plot = current()) = twinx(plt[1]) + +function twiny(sp::Subplot) + sp[:top_margin] = max(sp[:top_margin], 20px) + plot!(sp.plt, inset = (sp[:subplot_index], bbox(0,0,1,1))) + twinsp = sp.plt.subplots[end] + twinsp[:xaxis][:mirror] = true + twinsp[:background_color_inside] = Plots.RGBA{Float64}(0,0,0,0) + link_axes!(sp[:yaxis], twinsp[:yaxis]) + twinsp +end + +twiny(plt::Plot = current()) = twiny(plt[1]) +