I'm trying to use mplot3d to plot something 3D. I have Mac OSX. However I get this error:
ax = fig.gca(projection = '3d')
File "/usr/local/lib/python2.7/site-packages/matplotlib/figure.py", line 1368, in gca
return self.add_subplot(1, 1, 1, **kwargs)
File "/usr/local/lib/python2.7/site-packages/matplotlib/figure.py", line 1020, in add_subplot
a = subplot_class_factory(projection_class)(self, *args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/matplotlib/axes/_subplots.py", line 73, in __init__
self._axes_class.__init__(self, fig, self.figbox, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mpl_toolkits/mplot3d/axes3d.py", line 91, in __init__
*args, **kwargs)
File "/usr/local/lib/python2.7/site-packages/matplotlib/axes/_base.py", line 551, in __init__
self.cla()
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mpl_toolkits/mplot3d/axes3d.py", line 1045, in cla
Axes.cla(self)
File "/usr/local/lib/python2.7/site-packages/matplotlib/axes/_base.py", line 1062, in cla
self.grid(False) # Disable grid on init to use rcParameter
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mpl_toolkits/mplot3d/axes3d.py", line 1256, in grid
self._draw_grid = maxes._string_to_bool(b)
AttributeError: 'module' object has no attribute '_string_to_bool'
I searched this problem here and tried a bunch of solutions. I am using matplotlib 2.0.0:
- removing mplot3d (located in /usr/local/lib/python2.7/site-packages/mpl_toolkits) and reinstalling/upgrading with: pip install --upgrade 'matplotlib[mplot3d]'
- Adding this line to /usr/lib/pymodules/python2.7/mpl_toolkits/mplot3d/axes3d.py : from matplotlib.cbook import _string_to_bool
Both of these don't work and I am still getting the same error. Any suggestions? Thanks!