From 0d3e72e9091b07d8a66ee43705e92de00e99271d Mon Sep 17 00:00:00 2001 From: Misha Mikhasenko Date: Wed, 2 Jun 2021 13:49:45 +0200 Subject: [PATCH 1/2] Add `twiny()` --- src/layouts.jl | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/layouts.jl b/src/layouts.jl index ff4d0041..42e4bc52 100644 --- a/src/layouts.jl +++ b/src/layouts.jl @@ -785,3 +785,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]) + From e83c6e66b03be627557c2c53aaef628ea5f9b805 Mon Sep 17 00:00:00 2001 From: Misha Mikhasenko Date: Wed, 2 Jun 2021 14:00:45 +0200 Subject: [PATCH 2/2] add the export of twiny --- src/Plots.jl | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Plots.jl b/src/Plots.jl index e7a71878..38d4d04a 100644 --- a/src/Plots.jl +++ b/src/Plots.jl @@ -43,6 +43,7 @@ export default, with, twinx, + twiny, pie, pie!,