Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Horizontal colorbar support #237

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions pyPlots/plot_colormap3dslice.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
):
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down