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

Spyder is not displaying Matplotlib 3d plots in its Python consoles #2402

Closed
s0r2637 opened this issue May 4, 2015 · 7 comments
Closed

Spyder is not displaying Matplotlib 3d plots in its Python consoles #2402

s0r2637 opened this issue May 4, 2015 · 7 comments

Comments

@s0r2637
Copy link

s0r2637 commented May 4, 2015

I tried the following set of commands in the Spyder-2.3.4 console and it doesn't display a 3d plot. It works fine when I run it outside Sypder-2.3.4. Your help is highly appreciated.

import numpy
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

# Set up grid and test data
nx, ny = 256, 1024
x = range(nx)
y = range(ny)

data = numpy.random.random((nx, ny))

hf = plt.figure()
ha = hf.add_subplot(111, projection='3d')

X, Y = numpy.meshgrid(y, x)  # `plot_surface` expects `x` and `y` data to be 2D
ha.plot_surface(X, Y, data)

plt.show()
@ccordoba12
Copy link
Member

What console are you using? Python or IPython?

@s0r2637
Copy link
Author

s0r2637 commented May 4, 2015

Python.

Srini
On May 4, 2015 6:15 PM, "Carlos Cordoba" notifications@github.com wrote:

What console are you using? Python or IPython?


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

@ccordoba12
Copy link
Member

For next time, please the Report bug menu entry, under the Help menu :-)

Are you using Python 2 or Python 3?

@s0r2637
Copy link
Author

s0r2637 commented May 4, 2015

Sure. I will do that. I am using Python 2.7

Srini
On May 4, 2015 6:31 PM, "Carlos Cordoba" notifications@github.com wrote:

For next time, please the Report bug menu entry, under the Help menu
:-)

Are you using Python 2 or Python 3?


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

@ccordoba12
Copy link
Member

I can confirm this problem. We'll see what we can do about it :-)

@ccordoba12 ccordoba12 changed the title Spyder 2.3.4 with Matplotlib 1.4.3 on Python-2.7 on Ubuntu 14.04 does not display 3d plots Spyder is not displaying Matplotlib 3d plots May 6, 2015
@ccordoba12 ccordoba12 changed the title Spyder is not displaying Matplotlib 3d plots Spyder is not displaying Matplotlib 3d plots in its Python consoles May 6, 2015
@ccordoba12 ccordoba12 modified the milestone: v2.3.5 Jun 1, 2015
@ccordoba12
Copy link
Member

This is not an error in Spyder. You just need to use

plt.draw()

instead of

plt.show()

as the last line of your example to make the plot appear.

Here is an explanation of the difference between the two:

http://stackoverflow.com/a/23141491/438386

Given that in interactive mode (i.e. introducing each command at a time), you generate an empty figure first (with hf = plt.figure()), I think you need to call plt.draw() to redraw it later.

@s0r2637
Copy link
Author

s0r2637 commented Jun 7, 2015

Thanks! I will look into this.

Srini

On Sun, Jun 7, 2015 at 6:05 PM, Carlos Cordoba notifications@github.com
wrote:

This is not an error in Spyder. You just need to use

plt.draw()

instead of

plt.show()

as the last line of your example to make the plot appear.

Here is an explanation of the difference between the two:

http://stackoverflow.com/a/23141491/438386

Given that in interactive mode (i.e. introducing each command at a time),
you generate an empty figure first (with hf = plt.figure()), I think you
need to call plt.draw() to redraw it later.


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

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

2 participants