From 39f8547846a18067dbeb5179dcec070012873a4a Mon Sep 17 00:00:00 2001 From: Zhanibek Date: Mon, 25 May 2020 17:55:41 +0900 Subject: [PATCH] pyplot 3d color bar fixes --- src/backends/pyplot.jl | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/backends/pyplot.jl b/src/backends/pyplot.jl index bf305f17..75384b37 100644 --- a/src/backends/pyplot.jl +++ b/src/backends/pyplot.jl @@ -1396,6 +1396,14 @@ function _update_plot_object(plt::Plot{PyPlotBackend}) figw, figh = figw*px, figh*px pcts = bbox_to_pcts(sp.plotarea, figw, figh) ax."set_position"(pcts) + + if haskey(sp.attr, :cbar_ax) && RecipesPipeline.is3d(sp) # 2D plots are completely handled by axis dividers + cbw = sp.attr[:cbar_width] + # this is the bounding box of just the colors of the colorbar (not labels) + cb_bbox = BoundingBox(right(sp.bbox)-cbw - 2mm, top(sp.bbox) + 2mm, _cbar_width-1mm, height(sp.bbox) - 4mm) + pcts = bbox_to_pcts(cb_bbox, figw, figh) + sp.attr[:cbar_ax]."set_position"(pcts) + end end PyPlot.draw() end