[yt-svn] commit/yt: 8 new changesets
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Thu Jan 5 10:49:20 PST 2017
8 new commits in yt:
https://bitbucket.org/yt_analysis/yt/commits/732cfd77fa1e/
Changeset: 732cfd77fa1e
Branch: yt
User: ngoldbaum
Date: 2016-12-19 20:22:07+00:00
Summary: Ensure ticks are drawn at the top and right on mpl 2.0
This matches the appearance of plots under mpl 1.5.3
Affected #: 1 file
diff -r 3b3b2900d417d4574e977175b883f7e3375dd1a7 -r 732cfd77fa1e0397a335dfe393812e380771b386 yt/visualization/base_plot_types.py
--- a/yt/visualization/base_plot_types.py
+++ b/yt/visualization/base_plot_types.py
@@ -98,7 +98,9 @@
self.manager = canvas_classes[1](self.canvas, 1)
for which in ['major', 'minor']:
for axis in 'xy':
- self.axes.tick_params(which=which, axis=axis, direction='in')
+ self.axes.tick_params(
+ which=which, axis=axis, direction='in', top=True, right=True
+ )
def _set_canvas(self):
self.interactivity = get_interactivity()
https://bitbucket.org/yt_analysis/yt/commits/d52dd1405b78/
Changeset: d52dd1405b78
Branch: yt
User: ngoldbaum
Date: 2016-12-19 20:22:14+00:00
Summary: two fixes for matplotlib 2.0
Affected #: 2 files
diff -r 732cfd77fa1e0397a335dfe393812e380771b386 -r d52dd1405b78f218477a13df0e86b88637c9b6a1 yt/visualization/base_plot_types.py
--- a/yt/visualization/base_plot_types.py
+++ b/yt/visualization/base_plot_types.py
@@ -13,8 +13,12 @@
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
+import matplotlib
+import numpy as np
+
+from distutils.version import LooseVersion
from io import BytesIO
-import matplotlib
+
from yt.funcs import \
get_image_suffix, \
mylog, \
@@ -22,7 +26,7 @@
get_brewer_cmap, \
matplotlib_style_context, \
get_interactivity
-import numpy as np
+
backend_dict = {'GTK': ['backend_gtk', 'FigureCanvasGTK',
'FigureManagerGTK'],
@@ -213,8 +217,14 @@
aspect=aspect, vmax=self.zmax, cmap=cmap,
interpolation='nearest')
if (cbnorm == 'symlog'):
- formatter = matplotlib.ticker.LogFormatterMathtext()
- self.cb = self.figure.colorbar(self.image, self.cax, format=formatter)
+ if LooseVersion(matplotlib.__version__) < LooseVersion("2.0.0"):
+ formatter_kwargs = {}
+ else:
+ formatter_kwargs = dict(linthresh=cblinthresh)
+ formatter = matplotlib.ticker.LogFormatterMathtext(
+ **formatter_kwargs)
+ self.cb = self.figure.colorbar(
+ self.image, self.cax, format=formatter)
yticks = list(-10**np.arange(np.floor(np.log10(-data.min())),\
np.rint(np.log10(cblinthresh))-1, -1)) + [0] + \
list(10**np.arange(np.rint(np.log10(cblinthresh)),\
diff -r 732cfd77fa1e0397a335dfe393812e380771b386 -r d52dd1405b78f218477a13df0e86b88637c9b6a1 yt/visualization/plot_container.py
--- a/yt/visualization/plot_container.py
+++ b/yt/visualization/plot_container.py
@@ -23,6 +23,7 @@
import matplotlib
import os
+from distutils.version import LooseVersion
from collections import defaultdict
from functools import wraps
@@ -315,7 +316,10 @@
if isinstance(cmap, string_types):
cmap = yt_colormaps[cmap]
color = cmap(0)
- self.plots[actual_field].axes.set_axis_bgcolor(color)
+ if LooseVersion(matplotlib.__version__) < LooseVersion("2.0.0"):
+ self.plots[actual_field].axes.set_axis_bgcolor(color)
+ else:
+ self.plots[actual_field].axes.set_facecolor(color)
return self
@invalidate_plot
https://bitbucket.org/yt_analysis/yt/commits/b7bb0b8fc6a5/
Changeset: b7bb0b8fc6a5
Branch: yt
User: ngoldbaum
Date: 2016-12-19 18:45:50+00:00
Summary: update test that uses deprecated functionality in mpl 2.0
Affected #: 1 file
diff -r d52dd1405b78f218477a13df0e86b88637c9b6a1 -r b7bb0b8fc6a5b12a116511c62d62f7b9f8788b36 yt/visualization/tests/test_plotwindow.py
--- a/yt/visualization/tests/test_plotwindow.py
+++ b/yt/visualization/tests/test_plotwindow.py
@@ -13,12 +13,16 @@
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
import itertools
+import matplotlib
import numpy as np
import os
-import tempfile
import shutil
+import tempfile
import unittest
+
+from distutils.version import LooseVersion
from nose.tools import assert_true
+
from yt.extern.parameterized import parameterized, param
from yt.testing import \
fake_random_ds, assert_equal, assert_rel_equal, assert_array_equal, \
@@ -503,7 +507,10 @@
for field in ['density', ('gas', 'density')]:
plot.set_background_color(field, 'red')
ax = plot.plots[field].axes
- assert_equal(ax.get_axis_bgcolor(), 'red')
+ if LooseVersion(matplotlib.__version__) < LooseVersion('2.0.0'):
+ assert_equal(ax.get_axis_bgcolor(), 'red')
+ else:
+ assert_equal(ax.get_facecolor(), (1.0, 0.0, 0.0, 1.0))
def test_set_unit():
ds = fake_random_ds(32, fields=('temperature',), units=('K',))
https://bitbucket.org/yt_analysis/yt/commits/d8a80d9bab22/
Changeset: d8a80d9bab22
Branch: yt
User: ngoldbaum
Date: 2016-12-19 18:46:07+00:00
Summary: adapt to mpl deprecating the 'spectral' colormap
Affected #: 1 file
diff -r b7bb0b8fc6a5b12a116511c62d62f7b9f8788b36 -r d8a80d9bab22943d3154f65a55e12ee345b950ee yt/visualization/volume_rendering/transfer_function_helper.py
--- a/yt/visualization/volume_rendering/transfer_function_helper.py
+++ b/yt/visualization/volume_rendering/transfer_function_helper.py
@@ -14,12 +14,16 @@
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
+import matplotlib
+import numpy as np
+
+from distutils.version import LooseVersion
+
from yt.funcs import mylog
from yt.data_objects.profiles import create_profile
from yt.visualization.volume_rendering.transfer_functions import \
ColorTransferFunction
from yt.extern.six import BytesIO
-import numpy as np
class TransferFunctionHelper(object):
@@ -138,7 +142,11 @@
transfer function to produce a natural contrast ratio.
"""
- self.tf.add_layers(10, colormap='spectral')
+ if LooseVersion(matplotlib.__version__) < LooseVersion('2.0.0'):
+ colormap_name = 'spectral'
+ else:
+ colormap_name = 'nipy_spectral'
+ self.tf.add_layers(10, colormap=colormap_name)
factor = self.tf.funcs[-1].y.size / self.tf.funcs[-1].y.sum()
self.tf.funcs[-1].y *= 2*factor
https://bitbucket.org/yt_analysis/yt/commits/d4152604c9c9/
Changeset: d4152604c9c9
Branch: yt
User: ngoldbaum
Date: 2016-12-19 18:50:00+00:00
Summary: Remove unnecessary calls to axes.hold()
Affected #: 1 file
diff -r d8a80d9bab22943d3154f65a55e12ee345b950ee -r d4152604c9c9d5fcd5a33c4d8dba765907bd6859 yt/visualization/plot_modifications.py
--- a/yt/visualization/plot_modifications.py
+++ b/yt/visualization/plot_modifications.py
@@ -391,7 +391,6 @@
y0, y1 = plot.ylim
xx0, xx1 = plot._axes.get_xlim()
yy0, yy1 = plot._axes.get_ylim()
- plot._axes.hold(True)
# See the note about rows/columns in the pixelizer for more information
# on why we choose the bounds we do
nx = plot.image._A.shape[1] / self.factor
@@ -433,7 +432,6 @@
plot._axes.quiver(X,Y, pixX, pixY, scale=self.scale, scale_units=self.scale_units)
plot._axes.set_xlim(xx0,xx1)
plot._axes.set_ylim(yy0,yy1)
- plot._axes.hold(False)
class ContourCallback(PlotCallback):
"""
@@ -481,8 +479,6 @@
xx0, xx1 = plot._axes.get_xlim()
yy0, yy1 = plot._axes.get_ylim()
- plot._axes.hold(True)
-
# See the note about rows/columns in the pixelizer for more information
# on why we choose the bounds we do
numPoints_x = plot.image._A.shape[1]
@@ -558,7 +554,6 @@
cset = plot._axes.contour(xi,yi,zi,self.ncont, **self.plot_args)
plot._axes.set_xlim(xx0,xx1)
plot._axes.set_ylim(yy0,yy1)
- plot._axes.hold(False)
if self.label:
plot._axes.clabel(cset, **self.text_args)
@@ -675,7 +670,6 @@
grid_collection = matplotlib.collections.PolyCollection(
verts, facecolors="none", edgecolors=edgecolors,
linewidth=self.linewidth)
- plot._axes.hold(True)
plot._axes.add_collection(grid_collection)
if self.draw_ids:
@@ -688,7 +682,6 @@
left_edge_x[i] + (2 * (xx1 - xx0) / xpix),
left_edge_y[i] + (2 * (yy1 - yy0) / ypix),
"%d" % block_ids[i], clip_on=True)
- plot._axes.hold(False)
class StreamlineCallback(PlotCallback):
"""
@@ -719,7 +712,6 @@
y0, y1 = plot.ylim
xx0, xx1 = plot._axes.get_xlim()
yy0, yy1 = plot._axes.get_ylim()
- plot._axes.hold(True)
# See the note about rows/columns in the pixelizer for more information
# on why we choose the bounds we do
nx = plot.image._A.shape[1] / self.factor
@@ -751,7 +743,6 @@
plot._axes.streamplot(**streamplot_args)
plot._axes.set_xlim(xx0,xx1)
plot._axes.set_ylim(yy0,yy1)
- plot._axes.hold(False)
class LinePlotCallback(PlotCallback):
"""
@@ -829,12 +820,10 @@
coord_system=self.coord_system)
xx0, xx1 = plot._axes.get_xlim()
yy0, yy1 = plot._axes.get_ylim()
- plot._axes.hold(True)
plot._axes.plot([p1[0], p2[0]], [p1[1], p2[1]], transform=self.transform,
**self.plot_args)
plot._axes.set_xlim(xx0,xx1)
plot._axes.set_ylim(yy0,yy1)
- plot._axes.hold(False)
class ImageLineCallback(LinePlotCallback):
"""
@@ -884,7 +873,6 @@
y0, y1 = plot.ylim
xx0, xx1 = plot._axes.get_xlim()
yy0, yy1 = plot._axes.get_ylim()
- plot._axes.hold(True)
nx = plot.image._A.shape[1] / self.factor
ny = plot.image._A.shape[0] / self.factor
indices = np.argsort(plot.data['dx'])[::-1]
@@ -916,7 +904,6 @@
plot._axes.quiver(X,Y, pixX, pixY, scale=self.scale, scale_units=self.scale_units)
plot._axes.set_xlim(xx0,xx1)
plot._axes.set_ylim(yy0,yy1)
- plot._axes.hold(False)
class ClumpContourCallback(PlotCallback):
"""
@@ -939,8 +926,6 @@
extent = [xx0,xx1,yy0,yy1]
- plot._axes.hold(True)
-
ax = plot.data.axis
px_index = plot.data.ds.coordinates.x_axis[ax]
py_index = plot.data.ds.coordinates.y_axis[ax]
@@ -967,7 +952,6 @@
buff = np.maximum(temp, buff)
self.rv = plot._axes.contour(buff, np.unique(buff),
extent=extent, **self.plot_args)
- plot._axes.hold(False)
class ArrowCallback(PlotCallback):
"""
@@ -1106,7 +1090,6 @@
if dx == dy == 0:
warnings.warn("The arrow has zero length. Not annotating.")
return
- plot._axes.hold(True)
plot._axes.arrow(x-dx, y-dy, dx, dy, width=self.width,
head_width=self.head_width,
head_length=self.head_length,
@@ -1114,7 +1097,6 @@
length_includes_head=True, **self.plot_args)
plot._axes.set_xlim(xx0,xx1)
plot._axes.set_ylim(yy0,yy1)
- plot._axes.hold(False)
class MarkerAnnotateCallback(PlotCallback):
"""
@@ -1185,12 +1167,10 @@
coord_system=self.coord_system)
xx0, xx1 = plot._axes.get_xlim()
yy0, yy1 = plot._axes.get_ylim()
- plot._axes.hold(True)
plot._axes.scatter(x, y, marker = self.marker,
transform=self.transform, **self.plot_args)
plot._axes.set_xlim(xx0,xx1)
plot._axes.set_ylim(yy0,yy1)
- plot._axes.hold(False)
class SphereCallback(PlotCallback):
"""
@@ -1283,7 +1263,6 @@
**self.circle_args)
xx0, xx1 = plot._axes.get_xlim()
yy0, yy1 = plot._axes.get_ylim()
- plot._axes.hold(True)
plot._axes.add_patch(cir)
if self.text is not None:
@@ -1293,7 +1272,6 @@
plot._axes.set_xlim(xx0,xx1)
plot._axes.set_ylim(yy0,yy1)
- plot._axes.hold(False)
class TextLabelCallback(PlotCallback):
@@ -1386,13 +1364,11 @@
# consistent with other text labels in this figure
xx0, xx1 = plot._axes.get_xlim()
yy0, yy1 = plot._axes.get_ylim()
- plot._axes.hold(True)
label = plot._axes.text(x, y, self.text, transform=self.transform,
bbox=self.inset_box_args, **kwargs)
self._set_font_properties(plot, [label], **kwargs)
plot._axes.set_xlim(xx0,xx1)
plot._axes.set_ylim(yy0,yy1)
- plot._axes.hold(False)
class PointAnnotateCallback(TextLabelCallback):
"""
@@ -1489,7 +1465,6 @@
field_x = "particle_position_%s" % axis_names[xax]
field_y = "particle_position_%s" % axis_names[yax]
field_z = "particle_position_%s" % axis_names[data.axis]
- plot._axes.hold(True)
# Set up scales for pixel size and original data
pixel_scale = self.pixel_scale(plot)[0]
@@ -1527,7 +1502,6 @@
plot._axes.set_xlim(xx0,xx1)
plot._axes.set_ylim(yy0,yy1)
- plot._axes.hold(False)
if self.annotate_field:
annotate_dat = halo_data[self.annotate_field]
@@ -1606,7 +1580,6 @@
if self.minimum_mass is not None:
gg &= (reg[pt, "particle_mass"] >= self.minimum_mass)
if gg.sum() == 0: return
- plot._axes.hold(True)
px, py = self.convert_to_plot(plot,
[np.array(particle_x[gg][::self.stride]),
np.array(particle_y[gg][::self.stride])])
@@ -1614,7 +1587,6 @@
s=self.p_size, c=self.color,alpha=self.alpha)
plot._axes.set_xlim(xx0,xx1)
plot._axes.set_ylim(yy0,yy1)
- plot._axes.hold(False)
def _enforce_periodic(self,
particle_x,
@@ -1770,7 +1742,6 @@
self.vertices = triangle_vertices
def __call__(self, plot):
- plot._axes.hold(True)
ax = plot.data.axis
xax = plot.data.ds.coordinates.x_axis[ax]
yax = plot.data.ds.coordinates.y_axis[ax]
@@ -1792,7 +1763,6 @@
# create line collection and add it to the plot
lc = matplotlib.collections.LineCollection(l_cy, **self.plot_args)
plot._axes.add_collection(lc)
- plot._axes.hold(False)
class TimestampCallback(PlotCallback):
"""
@@ -2419,7 +2389,6 @@
bounds = [x0,x1,y0,y1]
extent = [xx0,xx1,yy0,yy1]
- plot._axes.hold(True)
# We are feeding this size into the pixelizer, where it will properly
# set it in reverse order
nx = plot.image._A.shape[1]
@@ -2462,7 +2431,6 @@
lic_data_rgba[...,3] = lic_data_clip_rescale * self.alpha
plot._axes.imshow(lic_data_rgba, extent=extent, cmap=self.cmap,
origin='lower')
- plot._axes.hold(False)
return plot
@@ -2511,7 +2479,6 @@
y0, y1 = plot.ylim
xx0, xx1 = plot._axes.get_xlim()
yy0, yy1 = plot._axes.get_ylim()
- plot._axes.hold(True)
nx = plot.image._A.shape[1]
ny = plot.image._A.shape[0]
aspect = float((y1 - y0) / (x1 - x0))
@@ -2551,4 +2518,3 @@
alpha=self.alpha)
plot._axes.set_xlim(xx0, xx1)
plot._axes.set_ylim(yy0, yy1)
- plot._axes.hold(False)
https://bitbucket.org/yt_analysis/yt/commits/7bfce8ad75d0/
Changeset: 7bfce8ad75d0
Branch: yt
User: ngoldbaum
Date: 2016-12-19 18:56:06+00:00
Summary: Explicitly use integer division in a few places in the plot callbacks
Affected #: 1 file
diff -r d4152604c9c9d5fcd5a33c4d8dba765907bd6859 -r 7bfce8ad75d033ccc092265caed6ebd3fe7c20d5 yt/visualization/plot_modifications.py
--- a/yt/visualization/plot_modifications.py
+++ b/yt/visualization/plot_modifications.py
@@ -393,8 +393,8 @@
yy0, yy1 = plot._axes.get_ylim()
# See the note about rows/columns in the pixelizer for more information
# on why we choose the bounds we do
- nx = plot.image._A.shape[1] / self.factor
- ny = plot.image._A.shape[0] / self.factor
+ nx = plot.image._A.shape[1] // self.factor
+ ny = plot.image._A.shape[0] // self.factor
# periodicity
ax = plot.data.axis
ds = plot.data.ds
@@ -714,8 +714,8 @@
yy0, yy1 = plot._axes.get_ylim()
# See the note about rows/columns in the pixelizer for more information
# on why we choose the bounds we do
- nx = plot.image._A.shape[1] / self.factor
- ny = plot.image._A.shape[0] / self.factor
+ nx = plot.image._A.shape[1] // self.factor
+ ny = plot.image._A.shape[0] // self.factor
pixX = np.zeros((ny, nx), dtype="f8")
pixY = np.zeros((ny, nx), dtype="f8")
pixelize_cartesian(pixX, plot.data['px'], plot.data['py'],
@@ -873,8 +873,8 @@
y0, y1 = plot.ylim
xx0, xx1 = plot._axes.get_xlim()
yy0, yy1 = plot._axes.get_ylim()
- nx = plot.image._A.shape[1] / self.factor
- ny = plot.image._A.shape[0] / self.factor
+ nx = plot.image._A.shape[1] // self.factor
+ ny = plot.image._A.shape[0] // self.factor
indices = np.argsort(plot.data['dx'])[::-1]
pixX = np.zeros((ny, nx), dtype="f8")
https://bitbucket.org/yt_analysis/yt/commits/eb5665df73e4/
Changeset: eb5665df73e4
Branch: yt
User: ngoldbaum
Date: 2016-12-19 19:59:20+00:00
Summary: explicitly use integer division in gaussian beam FRB filter
Affected #: 1 file
diff -r 7bfce8ad75d033ccc092265caed6ebd3fe7c20d5 -r eb5665df73e4f472b2f3060f0a4052b6b98d5a4f yt/visualization/fixed_resolution_filters.py
--- a/yt/visualization/fixed_resolution_filters.py
+++ b/yt/visualization/fixed_resolution_filters.py
@@ -64,7 +64,7 @@
def apply(self, buff):
from yt.utilities.on_demand_imports import _scipy
- hnbeam = self.nbeam / 2
+ hnbeam = self.nbeam // 2
sigma = self.sigma
l = np.linspace(-hnbeam, hnbeam, num=self.nbeam + 1)
https://bitbucket.org/yt_analysis/yt/commits/045a34d130b3/
Changeset: 045a34d130b3
Branch: yt
User: jzuhone
Date: 2017-01-05 18:48:53+00:00
Summary: Merged in ngoldbaum/yt (pull request #2467)
Fixes for matplotlib 2.0
Affected #: 6 files
diff -r b0b136647960a492e5a0f4180c8e4d77c3d2f0f1 -r 045a34d130b36022990a2c70eb8caede8db5932a yt/visualization/base_plot_types.py
--- a/yt/visualization/base_plot_types.py
+++ b/yt/visualization/base_plot_types.py
@@ -13,8 +13,12 @@
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
+import matplotlib
+import numpy as np
+
+from distutils.version import LooseVersion
from io import BytesIO
-import matplotlib
+
from yt.funcs import \
get_image_suffix, \
mylog, \
@@ -22,7 +26,7 @@
get_brewer_cmap, \
matplotlib_style_context, \
get_interactivity
-import numpy as np
+
backend_dict = {'GTK': ['backend_gtk', 'FigureCanvasGTK',
'FigureManagerGTK'],
@@ -98,7 +102,9 @@
self.manager = canvas_classes[1](self.canvas, 1)
for which in ['major', 'minor']:
for axis in 'xy':
- self.axes.tick_params(which=which, axis=axis, direction='in')
+ self.axes.tick_params(
+ which=which, axis=axis, direction='in', top=True, right=True
+ )
def _set_canvas(self):
self.interactivity = get_interactivity()
@@ -211,8 +217,14 @@
aspect=aspect, vmax=self.zmax, cmap=cmap,
interpolation='nearest')
if (cbnorm == 'symlog'):
- formatter = matplotlib.ticker.LogFormatterMathtext()
- self.cb = self.figure.colorbar(self.image, self.cax, format=formatter)
+ if LooseVersion(matplotlib.__version__) < LooseVersion("2.0.0"):
+ formatter_kwargs = {}
+ else:
+ formatter_kwargs = dict(linthresh=cblinthresh)
+ formatter = matplotlib.ticker.LogFormatterMathtext(
+ **formatter_kwargs)
+ self.cb = self.figure.colorbar(
+ self.image, self.cax, format=formatter)
yticks = list(-10**np.arange(np.floor(np.log10(-data.min())),\
np.rint(np.log10(cblinthresh))-1, -1)) + [0] + \
list(10**np.arange(np.rint(np.log10(cblinthresh)),\
diff -r b0b136647960a492e5a0f4180c8e4d77c3d2f0f1 -r 045a34d130b36022990a2c70eb8caede8db5932a yt/visualization/fixed_resolution_filters.py
--- a/yt/visualization/fixed_resolution_filters.py
+++ b/yt/visualization/fixed_resolution_filters.py
@@ -64,7 +64,7 @@
def apply(self, buff):
from yt.utilities.on_demand_imports import _scipy
- hnbeam = self.nbeam / 2
+ hnbeam = self.nbeam // 2
sigma = self.sigma
l = np.linspace(-hnbeam, hnbeam, num=self.nbeam + 1)
diff -r b0b136647960a492e5a0f4180c8e4d77c3d2f0f1 -r 045a34d130b36022990a2c70eb8caede8db5932a yt/visualization/plot_container.py
--- a/yt/visualization/plot_container.py
+++ b/yt/visualization/plot_container.py
@@ -23,6 +23,7 @@
import matplotlib
import os
+from distutils.version import LooseVersion
from collections import defaultdict
from functools import wraps
@@ -315,7 +316,10 @@
if isinstance(cmap, string_types):
cmap = yt_colormaps[cmap]
color = cmap(0)
- self.plots[actual_field].axes.set_axis_bgcolor(color)
+ if LooseVersion(matplotlib.__version__) < LooseVersion("2.0.0"):
+ self.plots[actual_field].axes.set_axis_bgcolor(color)
+ else:
+ self.plots[actual_field].axes.set_facecolor(color)
return self
@invalidate_plot
diff -r b0b136647960a492e5a0f4180c8e4d77c3d2f0f1 -r 045a34d130b36022990a2c70eb8caede8db5932a yt/visualization/plot_modifications.py
--- a/yt/visualization/plot_modifications.py
+++ b/yt/visualization/plot_modifications.py
@@ -391,11 +391,10 @@
y0, y1 = plot.ylim
xx0, xx1 = plot._axes.get_xlim()
yy0, yy1 = plot._axes.get_ylim()
- plot._axes.hold(True)
# See the note about rows/columns in the pixelizer for more information
# on why we choose the bounds we do
- nx = plot.image._A.shape[1] / self.factor
- ny = plot.image._A.shape[0] / self.factor
+ nx = plot.image._A.shape[1] // self.factor
+ ny = plot.image._A.shape[0] // self.factor
# periodicity
ax = plot.data.axis
ds = plot.data.ds
@@ -433,7 +432,6 @@
plot._axes.quiver(X,Y, pixX, pixY, scale=self.scale, scale_units=self.scale_units)
plot._axes.set_xlim(xx0,xx1)
plot._axes.set_ylim(yy0,yy1)
- plot._axes.hold(False)
class ContourCallback(PlotCallback):
"""
@@ -481,8 +479,6 @@
xx0, xx1 = plot._axes.get_xlim()
yy0, yy1 = plot._axes.get_ylim()
- plot._axes.hold(True)
-
# See the note about rows/columns in the pixelizer for more information
# on why we choose the bounds we do
numPoints_x = plot.image._A.shape[1]
@@ -558,7 +554,6 @@
cset = plot._axes.contour(xi,yi,zi,self.ncont, **self.plot_args)
plot._axes.set_xlim(xx0,xx1)
plot._axes.set_ylim(yy0,yy1)
- plot._axes.hold(False)
if self.label:
plot._axes.clabel(cset, **self.text_args)
@@ -675,7 +670,6 @@
grid_collection = matplotlib.collections.PolyCollection(
verts, facecolors="none", edgecolors=edgecolors,
linewidth=self.linewidth)
- plot._axes.hold(True)
plot._axes.add_collection(grid_collection)
if self.draw_ids:
@@ -688,7 +682,6 @@
left_edge_x[i] + (2 * (xx1 - xx0) / xpix),
left_edge_y[i] + (2 * (yy1 - yy0) / ypix),
"%d" % block_ids[i], clip_on=True)
- plot._axes.hold(False)
class StreamlineCallback(PlotCallback):
"""
@@ -719,11 +712,10 @@
y0, y1 = plot.ylim
xx0, xx1 = plot._axes.get_xlim()
yy0, yy1 = plot._axes.get_ylim()
- plot._axes.hold(True)
# See the note about rows/columns in the pixelizer for more information
# on why we choose the bounds we do
- nx = plot.image._A.shape[1] / self.factor
- ny = plot.image._A.shape[0] / self.factor
+ nx = plot.image._A.shape[1] // self.factor
+ ny = plot.image._A.shape[0] // self.factor
pixX = np.zeros((ny, nx), dtype="f8")
pixY = np.zeros((ny, nx), dtype="f8")
pixelize_cartesian(pixX, plot.data['px'], plot.data['py'],
@@ -751,7 +743,6 @@
plot._axes.streamplot(**streamplot_args)
plot._axes.set_xlim(xx0,xx1)
plot._axes.set_ylim(yy0,yy1)
- plot._axes.hold(False)
class LinePlotCallback(PlotCallback):
"""
@@ -829,12 +820,10 @@
coord_system=self.coord_system)
xx0, xx1 = plot._axes.get_xlim()
yy0, yy1 = plot._axes.get_ylim()
- plot._axes.hold(True)
plot._axes.plot([p1[0], p2[0]], [p1[1], p2[1]], transform=self.transform,
**self.plot_args)
plot._axes.set_xlim(xx0,xx1)
plot._axes.set_ylim(yy0,yy1)
- plot._axes.hold(False)
class ImageLineCallback(LinePlotCallback):
"""
@@ -884,9 +873,8 @@
y0, y1 = plot.ylim
xx0, xx1 = plot._axes.get_xlim()
yy0, yy1 = plot._axes.get_ylim()
- plot._axes.hold(True)
- nx = plot.image._A.shape[1] / self.factor
- ny = plot.image._A.shape[0] / self.factor
+ nx = plot.image._A.shape[1] // self.factor
+ ny = plot.image._A.shape[0] // self.factor
indices = np.argsort(plot.data['dx'])[::-1]
pixX = np.zeros((ny, nx), dtype="f8")
@@ -916,7 +904,6 @@
plot._axes.quiver(X,Y, pixX, pixY, scale=self.scale, scale_units=self.scale_units)
plot._axes.set_xlim(xx0,xx1)
plot._axes.set_ylim(yy0,yy1)
- plot._axes.hold(False)
class ClumpContourCallback(PlotCallback):
"""
@@ -939,8 +926,6 @@
extent = [xx0,xx1,yy0,yy1]
- plot._axes.hold(True)
-
ax = plot.data.axis
px_index = plot.data.ds.coordinates.x_axis[ax]
py_index = plot.data.ds.coordinates.y_axis[ax]
@@ -967,7 +952,6 @@
buff = np.maximum(temp, buff)
self.rv = plot._axes.contour(buff, np.unique(buff),
extent=extent, **self.plot_args)
- plot._axes.hold(False)
class ArrowCallback(PlotCallback):
"""
@@ -1106,7 +1090,6 @@
if dx == dy == 0:
warnings.warn("The arrow has zero length. Not annotating.")
return
- plot._axes.hold(True)
plot._axes.arrow(x-dx, y-dy, dx, dy, width=self.width,
head_width=self.head_width,
head_length=self.head_length,
@@ -1114,7 +1097,6 @@
length_includes_head=True, **self.plot_args)
plot._axes.set_xlim(xx0,xx1)
plot._axes.set_ylim(yy0,yy1)
- plot._axes.hold(False)
class MarkerAnnotateCallback(PlotCallback):
"""
@@ -1185,12 +1167,10 @@
coord_system=self.coord_system)
xx0, xx1 = plot._axes.get_xlim()
yy0, yy1 = plot._axes.get_ylim()
- plot._axes.hold(True)
plot._axes.scatter(x, y, marker = self.marker,
transform=self.transform, **self.plot_args)
plot._axes.set_xlim(xx0,xx1)
plot._axes.set_ylim(yy0,yy1)
- plot._axes.hold(False)
class SphereCallback(PlotCallback):
"""
@@ -1283,7 +1263,6 @@
**self.circle_args)
xx0, xx1 = plot._axes.get_xlim()
yy0, yy1 = plot._axes.get_ylim()
- plot._axes.hold(True)
plot._axes.add_patch(cir)
if self.text is not None:
@@ -1293,7 +1272,6 @@
plot._axes.set_xlim(xx0,xx1)
plot._axes.set_ylim(yy0,yy1)
- plot._axes.hold(False)
class TextLabelCallback(PlotCallback):
@@ -1386,13 +1364,11 @@
# consistent with other text labels in this figure
xx0, xx1 = plot._axes.get_xlim()
yy0, yy1 = plot._axes.get_ylim()
- plot._axes.hold(True)
label = plot._axes.text(x, y, self.text, transform=self.transform,
bbox=self.inset_box_args, **kwargs)
self._set_font_properties(plot, [label], **kwargs)
plot._axes.set_xlim(xx0,xx1)
plot._axes.set_ylim(yy0,yy1)
- plot._axes.hold(False)
class PointAnnotateCallback(TextLabelCallback):
"""
@@ -1489,7 +1465,6 @@
field_x = "particle_position_%s" % axis_names[xax]
field_y = "particle_position_%s" % axis_names[yax]
field_z = "particle_position_%s" % axis_names[data.axis]
- plot._axes.hold(True)
# Set up scales for pixel size and original data
pixel_scale = self.pixel_scale(plot)[0]
@@ -1527,7 +1502,6 @@
plot._axes.set_xlim(xx0,xx1)
plot._axes.set_ylim(yy0,yy1)
- plot._axes.hold(False)
if self.annotate_field:
annotate_dat = halo_data[self.annotate_field]
@@ -1606,7 +1580,6 @@
if self.minimum_mass is not None:
gg &= (reg[pt, "particle_mass"] >= self.minimum_mass)
if gg.sum() == 0: return
- plot._axes.hold(True)
px, py = self.convert_to_plot(plot,
[np.array(particle_x[gg][::self.stride]),
np.array(particle_y[gg][::self.stride])])
@@ -1614,7 +1587,6 @@
s=self.p_size, c=self.color,alpha=self.alpha)
plot._axes.set_xlim(xx0,xx1)
plot._axes.set_ylim(yy0,yy1)
- plot._axes.hold(False)
def _enforce_periodic(self,
particle_x,
@@ -1770,7 +1742,6 @@
self.vertices = triangle_vertices
def __call__(self, plot):
- plot._axes.hold(True)
ax = plot.data.axis
xax = plot.data.ds.coordinates.x_axis[ax]
yax = plot.data.ds.coordinates.y_axis[ax]
@@ -1792,7 +1763,6 @@
# create line collection and add it to the plot
lc = matplotlib.collections.LineCollection(l_cy, **self.plot_args)
plot._axes.add_collection(lc)
- plot._axes.hold(False)
class TimestampCallback(PlotCallback):
"""
@@ -2419,7 +2389,6 @@
bounds = [x0,x1,y0,y1]
extent = [xx0,xx1,yy0,yy1]
- plot._axes.hold(True)
# We are feeding this size into the pixelizer, where it will properly
# set it in reverse order
nx = plot.image._A.shape[1]
@@ -2462,7 +2431,6 @@
lic_data_rgba[...,3] = lic_data_clip_rescale * self.alpha
plot._axes.imshow(lic_data_rgba, extent=extent, cmap=self.cmap,
origin='lower')
- plot._axes.hold(False)
return plot
@@ -2511,7 +2479,6 @@
y0, y1 = plot.ylim
xx0, xx1 = plot._axes.get_xlim()
yy0, yy1 = plot._axes.get_ylim()
- plot._axes.hold(True)
nx = plot.image._A.shape[1]
ny = plot.image._A.shape[0]
aspect = float((y1 - y0) / (x1 - x0))
@@ -2551,4 +2518,3 @@
alpha=self.alpha)
plot._axes.set_xlim(xx0, xx1)
plot._axes.set_ylim(yy0, yy1)
- plot._axes.hold(False)
diff -r b0b136647960a492e5a0f4180c8e4d77c3d2f0f1 -r 045a34d130b36022990a2c70eb8caede8db5932a yt/visualization/tests/test_plotwindow.py
--- a/yt/visualization/tests/test_plotwindow.py
+++ b/yt/visualization/tests/test_plotwindow.py
@@ -13,12 +13,16 @@
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
import itertools
+import matplotlib
import numpy as np
import os
-import tempfile
import shutil
+import tempfile
import unittest
+
+from distutils.version import LooseVersion
from nose.tools import assert_true
+
from yt.extern.parameterized import parameterized, param
from yt.testing import \
fake_random_ds, assert_equal, assert_rel_equal, assert_array_equal, \
@@ -503,7 +507,10 @@
for field in ['density', ('gas', 'density')]:
plot.set_background_color(field, 'red')
ax = plot.plots[field].axes
- assert_equal(ax.get_axis_bgcolor(), 'red')
+ if LooseVersion(matplotlib.__version__) < LooseVersion('2.0.0'):
+ assert_equal(ax.get_axis_bgcolor(), 'red')
+ else:
+ assert_equal(ax.get_facecolor(), (1.0, 0.0, 0.0, 1.0))
def test_set_unit():
ds = fake_random_ds(32, fields=('temperature',), units=('K',))
diff -r b0b136647960a492e5a0f4180c8e4d77c3d2f0f1 -r 045a34d130b36022990a2c70eb8caede8db5932a yt/visualization/volume_rendering/transfer_function_helper.py
--- a/yt/visualization/volume_rendering/transfer_function_helper.py
+++ b/yt/visualization/volume_rendering/transfer_function_helper.py
@@ -14,12 +14,16 @@
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
+import matplotlib
+import numpy as np
+
+from distutils.version import LooseVersion
+
from yt.funcs import mylog
from yt.data_objects.profiles import create_profile
from yt.visualization.volume_rendering.transfer_functions import \
ColorTransferFunction
from yt.extern.six import BytesIO
-import numpy as np
class TransferFunctionHelper(object):
@@ -138,7 +142,11 @@
transfer function to produce a natural contrast ratio.
"""
- self.tf.add_layers(10, colormap='spectral')
+ if LooseVersion(matplotlib.__version__) < LooseVersion('2.0.0'):
+ colormap_name = 'spectral'
+ else:
+ colormap_name = 'nipy_spectral'
+ self.tf.add_layers(10, colormap=colormap_name)
factor = self.tf.funcs[-1].y.size / self.tf.funcs[-1].y.sum()
self.tf.funcs[-1].y *= 2*factor
Repository URL: https://bitbucket.org/yt_analysis/yt/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the yt-svn
mailing list