Skip to content

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

Closed

Description

@jmccormac01

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]

Activity

  1. WeatherGod commented on Dec 7, 2014

    @WeatherGod
    Member

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

    On Sun, Dec 7, 2014 at 5:57 AM, James McCormac [email protected]
    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.

  2. edonyzpc commented on Jan 29, 2015

    @edonyzpc

    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:
  3. WeatherGod commented on Jan 29, 2015

    @WeatherGod
    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 [email protected] 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)
    .

  4. mdboom commented on Jan 29, 2015

    @mdboom
    Member

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

  5. edonyzpc commented on Jan 30, 2015

    @edonyzpc

    @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()
  6. jenshnielsen commented on Jan 30, 2015

    @jenshnielsen
    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()
  7. added this to the milestone on Jan 30, 2015
  8. chebee7i commented on Jun 13, 2015

    @chebee7i
    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'.

  9. tacaswell commented on Jun 13, 2015

    @tacaswell
    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.

  10. chebee7i commented on Jun 13, 2015

    @chebee7i
    Contributor

    Fixed it for me as well. Thanks!

  11. efiring commented on Jun 13, 2015

    @efiring
    Member

    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.

  12. tacaswell commented on Jun 13, 2015

    @tacaswell
    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.

  13. jmccormac01 commented on Sep 13, 2015

    @jmccormac01
    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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions