From 0db60348aa507cdbb9bfdf5cd93f0cbf64d5a881 Mon Sep 17 00:00:00 2001 From: Daniel Schwabeneder Date: Wed, 21 Feb 2018 17:03:23 +0100 Subject: [PATCH] reduce pyplot colorbar size for z values with very small or big absolute values --- src/backends/pyplot.jl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/backends/pyplot.jl b/src/backends/pyplot.jl index f3823e0a..b496dbb2 100644 --- a/src/backends/pyplot.jl +++ b/src/backends/pyplot.jl @@ -1295,7 +1295,8 @@ function _update_plot_object(plt::Plot{PyPlotBackend}) if haskey(sp.attr, :cbar_ax) cbw = sp.attr[:cbar_width] # this is the bounding box of just the colors of the colorbar (not labels) - has_toplabel = sp[:zaxis][:extrema].emax >= 1e7 + ex = sp[:zaxis][:extrema] + has_toplabel = !(1e-7 < max(abs(ex.emax), abs(ex.emin)) < 1e7) cb_bbox = BoundingBox(right(sp.bbox)-cbw+1mm, top(sp.bbox) + (has_toplabel ? 4mm : 2mm), _cbar_width-1mm, height(sp.bbox) - (has_toplabel ? 6mm : 4mm)) pcts = bbox_to_pcts(cb_bbox, figw, figh) sp.attr[:cbar_ax][:set_position](pcts)