Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

axes3d.py error when using lines3d and surface3d demos #3898

Closed
jmccormac01 opened this issue Dec 7, 2014 · 13 comments
Closed

axes3d.py error when using lines3d and surface3d demos #3898

jmccormac01 opened this issue Dec 7, 2014 · 13 comments

Comments

@jmccormac01
Copy link

Hi, I recently grabbed the 1.5.x version of matplotlib from github and get some errors when using the 3d plotting demos on the matplotlib website. See below for an output. I am running python 2.7.8_2 from homebrew. I get the same error for both demo scripts. Has something changed in 1.5.x such that the demos are calling things differently?

The plotting window appears but shows nothing inside, accept for a line along the x axis at z=0. See image attached.

Cheers
James

Mac OS X 10.10.1 Yosemite

James@Jamess-MBP> python -i lines3d_demo.py
Traceback (most recent call last):
  File "/usr/local/Cellar/python/2.7.8_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-1.5.x-py2.7-macosx-10.10-x86_64.egg/matplotlib/artist.py", line 59, in draw_wrapper
    draw(artist, renderer, *args, **kwargs)
  File "/usr/local/Cellar/python/2.7.8_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-1.5.x-py2.7-macosx-10.10-x86_64.egg/matplotlib/figure.py", line 1090, in draw
    func(*args)
  File "/usr/local/Cellar/python/2.7.8_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mpl_toolkits/mplot3d/axes3d.py", line 273, in draw
    ax.draw(renderer)
  File "/usr/local/Cellar/python/2.7.8_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mpl_toolkits/mplot3d/axis3d.py", line 264, in draw
    self.axes.transAxes.transform(peparray[0:2, 0]))
ValueError: Expected 2-dimensional array, got 1

after a few seconds with the figure open this appears:

/usr/local/Cellar/python/2.7.8_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mpl_toolkits/mplot3d/axes3d.py:1094: FutureWarning: comparison to `None` will result in an elementwise object comparison in the future.
  if self.button_pressed in self._rotate_btn:

screen shot 2014-12-07 at 11 00 06

[TAC edited formatting]

@WeatherGod
Copy link
Member

This might be related to a recent change. Thoughts, @mdboom?

On Sun, Dec 7, 2014 at 5:57 AM, James McCormac notifications@github.com
wrote:

Hi, I recently grabbed the 1.5.x version of matplotlib from github and get
some errors when using the 3d plotting demos on the matplotlib website. See
below for an output. I am running python 2.7.8_2 from homebrew. I get the
same error for both demo scripts.

Has something changed in 1.5.x such that the demos are calling things
differently?

Cheers
James

James@Jamess-MBP> python -i lines3d_demo.py
Traceback (most recent call last):
File
"/usr/local/Cellar/python/2.7.8_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-1.5.x-py2.7-macosx-10.10-x86_64.egg/matplotlib/artist.py",
line 59, in draw_wrapper
draw(artist, renderer, _args, *_kwargs)
File
"/usr/local/Cellar/python/2.7.8_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-1.5.x-py2.7-macosx-10.10-x86_64.egg/matplotlib/figure.py",
line 1090, in draw
func(*args)
File
"/usr/local/Cellar/python/2.7.8_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mpl_toolkits/mplot3d/axes3d.py",
line 273, in draw
ax.draw(renderer)
File
"/usr/local/Cellar/python/2.7.8_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mpl_toolkits/mplot3d/axis3d.py",
line 264, in draw
self.axes.transAxes.transform(peparray[0:2, 0]))
ValueError: Expected 2-dimensional array, got 1


Reply to this email directly or view it on GitHub
#3898.

@edonyzpc
Copy link

I got the a problem which is similar. On Mac OSX10.10.2, brew python 2.7.9 and installing matplotlib with pip. When I plotting 3d, I got the problem.

#--------------- plot3d function define in file plotData.py-----------------#
 def plot3d(x,y,J):                                                                                                                    
      fig = plt.figure(2)
      ax = Ax3(fig)
      ax.plot_surface(x,y,J,rstride=5,cstride=5,cmap=cm.summer_r)
      plt.show()
#-------------- call the plot3d() and plot the 3d figure ------------------#                                                               
print('Visualizing J(theta_0, theta_1) ...\n')
theta_0 = np.array([np.linspace(-10,10,num=100)])
theta_1 = np.array([np.linspace(-1,4,num=100)])
J_theta = np.array(np.empty((100,100)))
for i in range(100):
    for j in range(100):
        J_theta[i,j] = compC(x,y,[[theta_0[0,i]],[theta_1[0,j]]])
from plotData import plot3d
plot3d(theta_0,theta_1.T,J_theta)
#------------ end of the code ------------#

My 3d-figure can be plotted. There is a warning that upset me for my cursor put into the plotting area it will occur.

#------------ the warning error -------------#
Visualizing J(theta_0, theta_1) ...

/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mpl_toolkits/mplot3d/axes3d.py:1094: FutureWarning: comparison to `None` will result in an elementwise object comparison in the future.
  if self.button_pressed in self._rotate_btn:

@WeatherGod
Copy link
Member

That warning is something different, but it is something I need to fix soon.

On Thu, Jan 29, 2015 at 12:31 PM, edony notifications@github.com wrote:

I got the a problem which is similar. On Mac OSX10.10.2, brew python 2.7.9
and installing matplotlib with pip. When I plotting 3d, I got the problem.

#--------------- plot3d function define in file plotData.py-----------------#
def plot3d(x,y,J):
fig = plt.figure(2)
ax = Ax3(fig)
ax.plot_surface(x,y,J,rstride=5,cstride=5,cmap=cm.summer_r)
plt.show()#-------------- call the plot3d() and plot the 3d figure ------------------# print('Visualizing J(theta_0, theta_1) ...\n')
theta_0 = np.array([np.linspace(-10,10,num=100)])
theta_1 = np.array([np.linspace(-1,4,num=100)])
J_theta = np.array(np.empty((100,100)))for i in range(100):
for j in range(100):
J_theta[i,j] = compC(x,y,[[theta_0[0,i]],[theta_1[0,j]]])from plotData import plot3d
plot3d(theta_0,theta_1.T,J_theta)#------------ end of the code ------------#

My 3d-figure can be plotted. There is a warning that upset me for my
cursor put into the plotting area it will occur.

#------------ the warning error -------------#
Visualizing J(theta_0, theta_1) ...
/usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/mpl_toolkits/mplot3d/axes3d.py:1094: FutureWarning: comparison to None will result in an elementwise object comparison in the future.
if self.button_pressed in self._rotate_btn:


Reply to this email directly or view it on GitHub
#3898 (comment)
.

@mdboom
Copy link
Member

mdboom commented Jan 29, 2015

Hmm... I can't reproduce. Is this still an issue?

@jenshnielsen
Copy link
Member

The example should work in current master see http://matplotlib.org/devdocs/examples/mplot3d/lines3d_demo.html

@edonyzpc
Copy link

@jenshnielsen
Is there any differences between the usage of my code and the example's?

#--------------- my way to plot 3d-figure-----------------#
from maplotlib import cm
from mpl_toolkits.mplot3d.axes3d import Axes3D as Ax3
 def plot3d(x,y,J):                                                                                                                    
      fig = plt.figure(2)
      ax = Ax3(fig)
      ax.plot_surface(x,y,J,rstride=5,cstride=5,cmap=cm.summer_r)
      plt.show()

@jenshnielsen
Copy link
Member

@Edonym I was refering to the original issue. That issue is caused by the ValueError above and is not related to the warning which is harmless at this stage. It just means that we have to fix the code to work with future versions of Numpy

If you don't want the warning to show you can use a warning filter with a context manager around the plot to suppress the warning. See https://docs.python.org/2/library/warnings.html

def plot3d(x,y,J):
    with warnings.catch_warnings():
        warnings.filterwarnings("ignore", category=FutureWarning)
        fig = plt.figure(2)
        ax = Ax3(fig)
        ax.plot_surface(x,y,J,rstride=5,cstride=5,cmap=cm.summer_r)
        plt.show()

@tacaswell tacaswell added this to the unassigned milestone Jan 30, 2015
@chebee7i
Copy link
Contributor

I'm getting this same error on the dev version of matplotlib (presently fdf1bb5). The test case is to run:

http://matplotlib.org/1.4.3/examples/mplot3d/scatter3d_demo.html

As far as I can tell, none of the mplot3d examples work and the entire toolkit is unusable. My numpy version is '1.10.0.dev0+d770034'.

@tacaswell
Copy link
Member

I was getting very similar errors in #4506

I ended up running a full bisect from v1.4.3 to master and in the end could not reproduce it with a clean install.

I suspect I was having these issues due to crossed source installs,

git clean -xfd
python setup.py develop

seems to be what fixed it for me.

@chebee7i
Copy link
Contributor

Fixed it for me as well. Thanks!

@efiring
Copy link
Member

efiring commented Jun 13, 2015

It looks to me like this can be closed; if anyone disagrees, feel free to reopen it, with an explanation of what the current problem is.

@efiring efiring closed this as completed Jun 13, 2015
@tacaswell
Copy link
Member

Given the very very strange things (func(..) works, a = func(..) does not) I was seeing in #4506 I am a it worried that there is something is going really sidways pretty far down, but I could believe that it is stale binaries from the cxx refactor.

@jmccormac01
Copy link
Author

Hi Guys,
Sorry for the extreme tardiness in replying. This morning I finally got back around to looking at this. I was able to fix this problem by removing everything matplotlib related and reinstalling. Everything looks ok now and the 3D plots are working fine.

Cheers
James

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants