Commit 34ba7fc6 authored by Christoph Groth's avatar Christoph Groth
Browse files

provide alternative code path for pre-1.4 matplotlib

See also commit 5e0f06d3.
parent 8ed9b47b
......@@ -42,18 +42,30 @@ except ImportError:
"functions will work.", RuntimeWarning)
mpl_enabled = False
if mpl_enabled and matplotlib.__version__ == "1.4.0":
warnings.warn("matplotlib 1.4.0 has a bug that makes 3D plotting unusable "
"(2D plotting is not affected). Please consider using a "
"different version of matplotlib.", RuntimeWarning)
from . import system, builder, physics
__all__ = ['plot', 'map', 'bands', 'sys_leads_sites', 'sys_leads_hoppings',
'sys_leads_pos', 'sys_leads_hopping_pos', 'mask_interpolate']
# TODO: Remove the following once we depend on matplotlib >= 1.4.1.
def matplotlib_chores():
global pre_1_4_matplotlib
ver = matplotlib.__version__
if ver == "1.4.0":
warnings.warn("Matplotlib 1.4.0 has a bug that makes 3D plotting "
"unusable (2D plotting is not affected). Please "
"consider using a different version of matplotlib.",
RuntimeWarning)
pre_1_4_matplotlib = [int(x) for x in ver.split('.')[:2]] < [1, 4]
if mpl_enabled:
matplotlib_chores()
# Collections that allow for symbols and linewiths to be given in data space
# (not for general use, only implement what's needed for plotter)
def isarray(var):
......@@ -97,9 +109,13 @@ if mpl_enabled:
self.reflen = reflen
self._linewidths_orig = nparray_if_array(self.get_linewidths())
self._transforms = np.array([
matplotlib.transforms.Affine2D().scale(x).get_matrix() for x
in sizes])
if pre_1_4_matplotlib:
self._transforms = [matplotlib.transforms.Affine2D().scale(x)
for x in sizes]
else:
self._transforms = np.array(
[matplotlib.transforms.Affine2D().scale(x).get_matrix()
for x in sizes])
def get_transforms(self):
return self._transforms
......@@ -220,8 +236,12 @@ if mpl_enabled:
self._edgecolors_orig = nparray_if_array(self.get_edgecolors())
Affine2D = matplotlib.transforms.Affine2D
self._orig_transforms = np.array([
Affine2D().scale(x).get_matrix() for x in sizes])
if pre_1_4_matplotlib:
self._orig_transforms = np.array(
[Affine2D().scale(x) for x in sizes], dtype='object')
else:
self._orig_transforms = np.array(
[Affine2D().scale(x).get_matrix() for x in sizes])
self._transforms = self._orig_transforms
def set_array(self, array):
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment