Skip to content

Bug with 3D graphing #8706

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

Closed
Maxence1402 opened this issue Jun 2, 2017 · 3 comments
Closed

Bug with 3D graphing #8706

Maxence1402 opened this issue Jun 2, 2017 · 3 comments
Milestone

Comments

@Maxence1402
Copy link

Maxence1402 commented Jun 2, 2017

Bug report

Bug summary

I'm trying to plot 3d surfaces, however the given example on the website does not work well at all, see below. It seems like the plotting does not take all the given points...

'''
======================
3D surface (color map)
======================

Demonstrates plotting a 3D surface colored with the coolwarm color map.
The surface is made opaque by using antialiased=False.

Also demonstrates using the LinearLocator and custom formatting for the
z axis tick labels.
'''

from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
from matplotlib import cm
from matplotlib.ticker import LinearLocator, FormatStrFormatter
import numpy as np


fig = plt.figure()
ax = fig.gca(projection='3d')

# Make data.
X = np.arange(-5, 5, 0.25)
Y = np.arange(-5, 5, 0.25)
X, Y = np.meshgrid(X, Y)
R = np.sqrt(X**2 + Y**2)
Z = np.sin(R)

# Plot the surface.
surf = ax.plot_surface(X, Y, Z, cmap=cm.coolwarm,
                       linewidth=0, antialiased=False)

# Customize the z axis.
ax.set_zlim(-1.01, 1.01)
ax.zaxis.set_major_locator(LinearLocator(10))
ax.zaxis.set_major_formatter(FormatStrFormatter('%.02f'))

# Add a color bar which maps values to colors.
fig.colorbar(surf, shrink=0.5, aspect=5)

plt.show()

Actual outcome

Image here

Expected outcome

(http://i.imgur.com/5geshSc.png)

Matplotlib version

  • Operating System:Windows 10
  • Matplotlib Version: The latest on June 2nd, 2017 I suppose
  • Python Version: 3.5.1
  • Using Spyder (Anaconda 2.4.1)
@Maxence1402
Copy link
Author

OK, I checked cstride and rstride and it seems like their default value isn't 1...

@WeatherGod
Copy link
Member

WeatherGod commented Jun 2, 2017 via email

@anntzer
Copy link
Contributor

anntzer commented Jun 4, 2017

The docstring of plot_function is a bit confusing (it still indicates that rstride and cstride defaults to 10, which is not really the case anymore (only one of them will default to 10 if only the other is given, otherwise we use rcount/ccount)).

Also, I think the automatic downsampling behavior is unusual enough that this deserves a WARNING entry (https://github.com/numpy/numpy/blob/master/doc/HOWTO_DOCUMENT.rst.txt#other-points-to-keep-in-mind).

@QuLogic QuLogic added this to the 2.1.1 (next bug fix release) milestone Oct 5, 2017
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

4 participants