I am using a Mac with HighSierra, python 2.7 and Ipython 5.5.0
When using any type of projection (such as aitoff, polar, hammer, or so) in pyplot, I can't show or save the figure except if it is empty. Even if I only try to add the grid, I already have problems (of course, also with the data).
plt.figure(figsize=(8,4.2))
plt.subplot( projection="aitoff")
plt.title("Aitoff projection")
plt.grid(True)
plt.show()
Will return:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs)
53 def draw_wrapper(artist, renderer, *args, **kwargs):
54 before(artist, renderer)
---> 55 draw(artist, renderer, *args, **kwargs)
56 after(artist, renderer)
57
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/figure.pyc in draw(self, renderer)
1032 dsu.sort(key=itemgetter(0))
1033 for zorder, a, func, args in dsu:
-> 1034 func(*args)
1035
1036 renderer.close_group('figure')
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs)
53 def draw_wrapper(artist, renderer, *args, **kwargs):
54 before(artist, renderer)
---> 55 draw(artist, renderer, *args, **kwargs)
56 after(artist, renderer)
57
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/axes.pyc in draw(self, renderer, inframe)
2084
2085 for zorder, a in dsu:
-> 2086 a.draw(renderer)
2087
2088 renderer.close_group('axes')
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs)
53 def draw_wrapper(artist, renderer, *args, **kwargs):
54 before(artist, renderer)
---> 55 draw(artist, renderer, *args, **kwargs)
56 after(artist, renderer)
57
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/axis.pyc in draw(self, renderer, *args, **kwargs)
1094
1095 for tick in ticks_to_draw:
-> 1096 tick.draw(renderer)
1097
1098 # scale up the axis label box to also find the neighbors, not
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs)
53 def draw_wrapper(artist, renderer, *args, **kwargs):
54 before(artist, renderer)
---> 55 draw(artist, renderer, *args, **kwargs)
56 after(artist, renderer)
57
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/axis.pyc in draw(self, renderer)
232 if midPoint:
233 if self.gridOn:
--> 234 self.gridline.draw(renderer)
235 if self.tick1On:
236 self.tick1line.draw(renderer)
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/artist.pyc in draw_wrapper(artist, renderer, *args, **kwargs)
53 def draw_wrapper(artist, renderer, *args, **kwargs):
54 before(artist, renderer)
---> 55 draw(artist, renderer, *args, **kwargs)
56 after(artist, renderer)
57
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/lines.pyc in draw(self, renderer)
548 funcname = self._lineStyles.get(self._linestyle, '_draw_nothing')
549 if funcname != '_draw_nothing':
--> 550 tpath, affine = transf_path.get_transformed_path_and_affine()
551 if len(tpath.vertices):
552 self._lineFunc = getattr(self, funcname)
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/transforms.pyc in get_transformed_path_and_affine(self)
2560 the path necessary to complete the transformation.
2561 """
-> 2562 self._revalidate()
2563 return self._transformed_path, self.get_affine()
2564
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/transforms.pyc in _revalidate(self)
2537 or self._transformed_path is None):
2538 self._transformed_path = \
-> 2539 self._transform.transform_path_non_affine(self._path)
2540 self._transformed_points = \
2541 Path(self._transform.transform_non_affine(self._path.vertices),
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/transforms.pyc in transform_path_non_affine(self, path)
2228 else:
2229 return self._b.transform_path_non_affine(
-> 2230 self._a.transform_path(path))
2231 transform_path_non_affine.__doc__ = Transform.transform_path_non_affine.__doc__
2232
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/transforms.pyc in transform_path_non_affine(self, path)
2225 return path
2226 elif not self._a.is_affine and self._b.is_affine:
-> 2227 return self._a.transform_path_non_affine(path)
2228 else:
2229 return self._b.transform_path_non_affine(
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/transforms.pyc in transform_path_non_affine(self, path)
2225 return path
2226 elif not self._a.is_affine and self._b.is_affine:
-> 2227 return self._a.transform_path_non_affine(path)
2228 else:
2229 return self._b.transform_path_non_affine(
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/projections/geo.pyc in transform_path_non_affine(self, path)
288 def transform_path_non_affine(self, path):
289 vertices = path.vertices
--> 290 ipath = path.interpolated(self._resolution)
291 return Path(self.transform(ipath.vertices), ipath.codes)
292 transform_path_non_affine.__doc__ = Transform.transform_path_non_affine.__doc__
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/path.pyc in interpolated(self, steps)
551 return self
552
--> 553 vertices = simple_linear_interpolation(self.vertices, steps)
554 codes = self.codes
555 if codes is not None:
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/matplotlib/cbook.pyc in simple_linear_interpolation(a, steps)
1709 new_shape = list(a.shape)
1710 new_shape[0] = new_length
-> 1711 result = np.zeros(new_shape, a.dtype)
1712
1713 result[0] = a[0]
TypeError: 'numpy.float64' object cannot be interpreted as an index
I have tried updating everything and also downgrading as suggested in some other posts for this numpy error in the end, and nothing is working.
I figured this out: solution is to install numpy 1.11.0, but since I had several installations in my computer, it wouldn't work. I had to delete the other versions (if installed via pip this can be done manually, just erase the files), or change environment in order to use the numpy version I wanted.