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

adapt to new colorbar behavior in mpl 3.0. fixes #2099 #2101

Merged
merged 3 commits into from Nov 26, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Binary file not shown.
Binary file modified answer-store/py36_phase_plots/py36_phase_plots
Binary file not shown.
2 changes: 1 addition & 1 deletion tests/tests.yaml
Expand Up @@ -47,7 +47,7 @@ answer_tests:
local_owls_002:
- yt/frontends/owls/tests/test_outputs.py

local_pw_025:
local_pw_026:
- yt/visualization/tests/test_plotwindow.py:test_attributes
- yt/visualization/tests/test_plotwindow.py:test_attributes_wt
- yt/visualization/tests/test_particle_plot.py:test_particle_projection_answers
Expand Down
18 changes: 13 additions & 5 deletions yt/visualization/profile_plotter.py
Expand Up @@ -49,6 +49,8 @@
matplotlib_style_context, \
iterable

MPL_VERSION = LooseVersion(matplotlib.__version__)

def get_canvas(name):
from . import _mpl_imports as mpl
suffix = get_image_suffix(name)
Expand Down Expand Up @@ -1089,7 +1091,7 @@ def _setup_plots(self):

color = self._background_color[f]

if LooseVersion(matplotlib.__version__) < LooseVersion("2.0.0"):
if MPL_VERSION < LooseVersion("2.0.0"):
self.plots[f].axes.set_axis_bgcolor(color)
else:
self.plots[f].axes.set_facecolor(color)
Expand Down Expand Up @@ -1117,10 +1119,16 @@ def _setup_plots(self):
if self._cbar_minorticks[f] is True:
if self._field_transform[f] == linear_transform:
self.plots[f].cax.minorticks_on()
else:
vmin = np.float64( self.plots[f].cb.norm.vmin )
vmax = np.float64( self.plots[f].cb.norm.vmax )
mticks = self.plots[f].image.norm( get_log_minorticks(vmin, vmax) )
elif MPL_VERSION < LooseVersion("3.0.0"):
cphyc marked this conversation as resolved.
Show resolved Hide resolved
# before matplotlib 3 log-scaled colorbars internally used
# a linear scale going from zero to one and did not draw
# minor ticks. Since we want minor ticks, calculate
# where the minor ticks should go in this linear scale
# and add them manually.
vmin = np.float64(self.plots[f].cb.norm.vmin)
vmax = np.float64(self.plots[f].cb.norm.vmax)
mticks = self.plots[f].image.norm(
get_log_minorticks(vmin, vmax))
self.plots[f].cax.yaxis.set_ticks(mticks, minor=True)
else:
self.plots[f].cax.minorticks_off()
Expand Down