improved twinx

This commit is contained in:
Thomas Breloff 2016-08-19 09:59:50 -04:00
parent e13070cd6d
commit 342f9c60b2

View File

@ -718,16 +718,12 @@ end
"Adds a new, empty subplot overlayed on top of `sp`, with a mirrored y-axis and linked x-axis." "Adds a new, empty subplot overlayed on top of `sp`, with a mirrored y-axis and linked x-axis."
function twinx(sp::Subplot) function twinx(sp::Subplot)
sp[:right_margin] = max(sp[:right_margin], 30px) sp[:right_margin] = max(sp[:right_margin], 30px)
idx = length(sp.plt.subplots) + 1 plot!(sp.plt, inset = (sp[:subplot_index], bbox(0,0,1,1)))
plot!( twinsp = sp.plt.subplots[end]
sp.plt, twinsp[:yaxis][:mirror] = true
ymirror = true, twinsp[:background_color_inside] = RGBA{Float64}(0,0,0,0)
xlink = [sp], link_axes!(sp[:xaxis], twinsp[:xaxis])
inset = (sp[:subplot_index], bbox(0,0,1,1)), twinsp
bg_inside = nothing,
subplot = idx
)
sp.plt[idx]
end end
twinx(plt::Plot = current()) = twinx(plt[1]) twinx(plt::Plot = current()) = twinx(plt[1])