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

A 3D object appears in front of another object, even though it is physically behind it. #9499

Closed
diggerdu opened this issue Oct 21, 2017 · 1 comment

Comments

Projects
None yet
2 participants
@diggerdu
Copy link

commented Oct 21, 2017

Bug report

Bug summary

A 3D object appears in front of another object, even though it is physically behind it.

Code for reproduction

import matplotlib as mpl
from mpl_toolkits.mplot3d import Axes3D
from matplotlib.patches import Circle, Rectangle
import matplotlib.path as mpath
import matplotlib.patches as mpatches
import numpy as np
import mpl_toolkits.mplot3d.art3d as art3d
import matplotlib.pyplot as plt

mpl.rcParams['legend.fontsize'] = 10

fig = plt.figure()
ax = fig.gca(projection='3d')
ax.set_xlim(-16, 16)
ax.set_ylim(-16, 16)
ax.set_zlim(-16, 16)



for depth in [0.]:
    theta = np.linspace(-5 * np.pi, 5 * np.pi, 1000)
    x = depth * np.ones(theta.shape)
    y = theta
    z = 4 * np.cos(0.2 * theta) * np.sin(0.4 * 8 * theta)
    points = np.array([y, z]).T
    patch = mpatches.PathPatch(mpath.Path(points))
    ax.add_patch(patch)
    art3d.pathpatch_2d_to_3d(patch, z=depth, zdir='x')

for depth in range(6 ,7):
    ret = Rectangle((0-5, 0-5), 5 * 2, 5 * 2, facecolor=(depth /10, depth/10, depth/10), edgecolor=(0.,0.,0.), alpha=1.)
    ax.add_patch(ret)
    art3d.pathpatch_2d_to_3d(ret, z=depth, zdir='x')


plt.show()

Outcome
figure_1

Matplotlib version

  • Operating system: Linux mercury 4.10.0-35-generic #39-Ubuntu SMP Wed Sep 13 07:46:59 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
  • Matplotlib version: 2.0.2
  • Matplotlib backend (print(matplotlib.get_backend())):Qt5Agg
  • Python version:Python 3.6.1 |Anaconda 4.4.0 (64-bit)| (default, May 11 2017, 13:09:58)
  • Jupyter version (if applicable):
  • Other libraries:

@anntzer anntzer added the mplot3d label Oct 21, 2017

@anntzer

This comment has been minimized.

Copy link
Contributor

commented Oct 21, 2017

This is a well known issue, acknowlegded and documented at http://matplotlib.org/mpl_toolkits/mplot3d/faq.html#my-3d-plot-doesn-t-look-right-at-certain-viewing-angles, and the general agreement is that it would be quite difficult to solve.
Closing, not because we do not think the issue is unimportant, but because having another issue open on this is unlikely to change anything.

@anntzer anntzer closed this Oct 21, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.