From d42ad06c3baad90b43094bd550141a9180c0feaf Mon Sep 17 00:00:00 2001 From: lkotipal Date: Wed, 22 May 2024 16:28:04 +0300 Subject: [PATCH] Horizontal colorbar support --- pyPlots/plot_colormap3dslice.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/pyPlots/plot_colormap3dslice.py b/pyPlots/plot_colormap3dslice.py index 439508f9..2e80bea5 100644 --- a/pyPlots/plot_colormap3dslice.py +++ b/pyPlots/plot_colormap3dslice.py @@ -69,6 +69,7 @@ def plot_colormap3dslice(filename=None, vectors=None, vectordensity=100, vectorcolormap='gray', vectorsize=1.0, streamlines=None, streamlinedensity=1, streamlinecolor='white', streamlinethick=1.0, axes=None, cbaxes=None, + cb_horizontal=False, normal='y', cutpoint=0., cutpointre=None, useimshow=False, imshowinterp='none', ): @@ -190,6 +191,7 @@ def plot_colormap3dslice(filename=None, Note that the aspect ratio of the colormap is made equal in any case, hence the axes proportions may change if the box and axes size are not designed to match by the user :kword cbaxes: Provide the routine a set of axes for the colourbar. + :kword cb_horizontal: If true, use a horizontal colorbar (this will look stupid unless you specify cbaxes) :kword normal: Direction of the normal of the 2D cut through ('x', 'y', or 'z' or a vector) :kword cutpoint: Coordinate (in normal direction) through which the cut must pass [m] :kword cutpointre: Coordinate (in normal direction) through which the cut must pass [rE] @@ -1084,7 +1086,7 @@ def exprMA_cust(exprmaps, requestvariables=False): else: # Logarithmic plot norm = LogNorm(vmin=vminuse,vmax=vmaxuse) - ticks = LogLocator(base=10,subs=range(10)) # where to show labels + ticks = LogLocator(base=10,subs= (1.0, ) if cb_horizontal else range(10)) # where to show labels else: # Linear levels = MaxNLocator(nbins=255).tick_values(vminuse,vmaxuse) @@ -1365,10 +1367,10 @@ def exprMA_cust(exprmaps, requestvariables=False): # First draw colorbar if usesci: - cb = plt.colorbar(fig1, ticks=ticks, format=mtick.FuncFormatter(pt.plot.cbfmtsci), cax=cax, drawedges=False) + cb = plt.colorbar(fig1, ticks=ticks, format=mtick.FuncFormatter(pt.plot.cbfmtsci), cax=cax, drawedges=False, orientation='horizontal' if cb_horizontal else 'vertical') else: #cb = plt.colorbar(fig1, ticks=ticks, format=mtick.FormatStrFormatter('%4.2f'), cax=cax, drawedges=False) - cb = plt.colorbar(fig1, ticks=ticks, format=mtick.FuncFormatter(pt.plot.cbfmt), cax=cax, drawedges=False) + cb = plt.colorbar(fig1, ticks=ticks, format=mtick.FuncFormatter(pt.plot.cbfmt), cax=cax, drawedges=False, orientation='horizontal' if cb_horizontal else 'vertical') cb.outline.set_linewidth(thick) cb.ax.yaxis.set_ticks_position(cbdir) # Ensure minor tick marks are off