From 342f9c60b2369f985a415f21955c14f5fefe2e92 Mon Sep 17 00:00:00 2001 From: Thomas Breloff Date: Fri, 19 Aug 2016 09:59:50 -0400 Subject: [PATCH] improved twinx --- src/layouts.jl | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/layouts.jl b/src/layouts.jl index a55689c3..5ed8c660 100644 --- a/src/layouts.jl +++ b/src/layouts.jl @@ -718,16 +718,12 @@ end "Adds a new, empty subplot overlayed on top of `sp`, with a mirrored y-axis and linked x-axis." function twinx(sp::Subplot) sp[:right_margin] = max(sp[:right_margin], 30px) - idx = length(sp.plt.subplots) + 1 - plot!( - sp.plt, - ymirror = true, - xlink = [sp], - inset = (sp[:subplot_index], bbox(0,0,1,1)), - bg_inside = nothing, - subplot = idx - ) - sp.plt[idx] + plot!(sp.plt, inset = (sp[:subplot_index], bbox(0,0,1,1))) + twinsp = sp.plt.subplots[end] + twinsp[:yaxis][:mirror] = true + twinsp[:background_color_inside] = RGBA{Float64}(0,0,0,0) + link_axes!(sp[:xaxis], twinsp[:xaxis]) + twinsp end twinx(plt::Plot = current()) = twinx(plt[1])