Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Rendering issue occurs when plotting 3D surfaces at a discontinuity #12395

Closed
Milestone
@mattforestyoung

Description

@mattforestyoung

Bug report

Bug summary

When running the code below to plot the surface for the equation 1 - y/x, the plot works but I get an error and the rendering of the surface breaks when viewed from some angles.

Code for reproduction

importmathimportnumpyasnpimportmatplotlibasmplimportmatplotlib.pyplotaspltimportmatplotlib.tickerfrommatplotlibimportcmfrommpl_toolkits.mplot3dimportAxes3D# Generate the datax=np.linspace(-1.0,1.0,50)y=np.linspace(-1.0,1.0,50)z=np.zeros(len(x))x,y=np.meshgrid(x,y)z=1-y/xz[z>=5.0]=5.0# Clips top of surfacez[z<=-5.0]=-5.0# Clips bottom of surface# place NaNs at the discontinuitypos=np.where(np.abs(np.diff(z))>=5.0)z[pos]=np.nan# Create the plotp1=plt.figure()ax=p1.gca(projection='3d')surf=ax.plot_surface(x,y,z,rstride=1,cstride=1,cmap=cm.coolwarm,linewidth=0,vmin=np.nanmin(z),vmax=np.nanmax(z),antialiased=False)plt.title("1 - y/x")ax.set_xlim(-1.0,1.0)ax.set_ylim(-1.0,1.0)ax.set_zlim(-5.0,5.0)ax.set_xlabel("x")ax.set_ylabel("y")ax.set_zlabel("z")p1.show()raw_input("Press any key to close all plots: ")

Actual outcome

/usr/lib/pymodules/python2.7/matplotlib/colors.py:576: RuntimeWarning: invalid value encountered in less  cbook._putmask(xa, xa < 0.0, -1)

Odd rendering issues appear:

rendering_angle1

render_angle3

Expected outcome

I'd expect to not get errors and to not see the rendering issue. I am using older versions of virtually everything, and this may be a platform-specific issue. Or I may be using this code in a way it was not intended to be used, in which case if there is a more-correct way to do this I'd appreciate someone showing me how to do it.

Matplotlib version

  • Operating system: Ubuntu 14.04
  • Matplotlib version: 1.3.1
  • Matplotlib backend (print(matplotlib.get_backend())): 'TkAgg'
  • Python version: 2.7.6
  • Jupyter version (if applicable): N/A
  • Other libraries:

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp