From 5e0f06d3a4081185e4a0e05a80a6495fde0acef1 Mon Sep 17 00:00:00 2001
From: Michael Wimmer <wimmer@lorentz.leidenuniv.nl>
Date: Wed, 17 Sep 2014 15:42:02 +0200
Subject: [PATCH] fix plotting for matplotlib >= 1.4.0 (3D still does not work
 for 1.4.0, but for 1.4.x)

---
 kwant/plotter.py | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/kwant/plotter.py b/kwant/plotter.py
index 88cb7256..5937fb3a 100644
--- a/kwant/plotter.py
+++ b/kwant/plotter.py
@@ -42,6 +42,12 @@ 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',
@@ -91,8 +97,9 @@ if mpl_enabled:
             self.reflen = reflen
             self._linewidths_orig = nparray_if_array(self.get_linewidths())
 
-            self._transforms = [matplotlib.transforms.Affine2D().scale(x) for x
-                                in sizes]
+            self._transforms = np.array([
+                matplotlib.transforms.Affine2D().scale(x).get_matrix() for x
+                in sizes])
 
         def get_transforms(self):
             return self._transforms
@@ -213,8 +220,8 @@ if mpl_enabled:
                 self._edgecolors_orig = nparray_if_array(self.get_edgecolors())
 
                 Affine2D = matplotlib.transforms.Affine2D
-                self._orig_transforms = np.array([Affine2D().scale(x) for x in
-                                                  sizes], dtype='object')
+                self._orig_transforms = np.array([
+                    Affine2D().scale(x).get_matrix() for x in sizes])
                 self._transforms = self._orig_transforms
 
             def set_array(self, array):
-- 
GitLab