From 1717777e8b218fc83ac72f67e2654c5a7b778f22 Mon Sep 17 00:00:00 2001 From: Darwin Darakananda Date: Wed, 4 Oct 2017 08:17:15 -0700 Subject: [PATCH] use existing colorbar axis if it already exists (for PyPlot) --- src/backends/pyplot.jl | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/backends/pyplot.jl b/src/backends/pyplot.jl index ea0ba6c7..a395ad07 100644 --- a/src/backends/pyplot.jl +++ b/src/backends/pyplot.jl @@ -1000,7 +1000,14 @@ function _before_layout_calcs(plt::Plot{PyPlotBackend}) # create and store the colorbar object (handle) and the axis that it is drawn on. # note: the colorbar axis is positioned independently from the subplot axis fig = plt.o - cbax = fig[:add_axes]([0.8,0.1,0.03,0.8], label = string(gensym())) + + if haskey(fig, :cbar_ax) + cbax = fig[:cbar_ax] + cbar[:clear]() + else + cbax = fig[:add_axes]([0.8,0.1,0.03,0.8], label = string(gensym())) + end + cb = fig[:colorbar](handle; cax = cbax, kw...) cb[:set_label](sp[:colorbar_title]) sp.attr[:cbar_handle] = cb