<h3 dir="auto">Bug summary</h3>
<p dir="auto">Based on this code below, the line is exactly on top of the surface plot but by rotating along the z-axis, it's obvious that the perspective of the line with respect to the surface changes, as it should not.</p>
<h3 dir="auto">Code for reproduction</h3>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
import math
pi = math.pi

x, y = np.meshgrid( np.linspace(-3, 7, 100) , np.linspace(-3, 7, 100))

V = np.linspace(-4, 4, 100)
U = np.linspace(-4, 4, 100) 

U, V = np.meshgrid(U, V)
X = U**2
Y = V**2

Z = U + 2*V

fig = plt.figure('1', figsize=(8,7))
ax = fig.add_subplot(111, projection='3d')
ax.plot_surface(X, Y, Z, cmap = plt.cm.coolwarm)

k=10
ax.plot(np.linspace(-2-k, 1+k, 10), np.linspace(-4-k, 1+k, 10), np.linspace(3-k, 4+k, 10), 'k' )

ax.set_xlabel('x')
ax.set_ylabel('y')
ax.set_zlabel('z')
plt.tight_layout()"><pre class="notranslate"><span class="pl-k">from</span> <span class="pl-s1">mpl_toolkits</span>.<span class="pl-s1">mplot3d</span> <span class="pl-k">import</span> <span class="pl-v">Axes3D</span>
<span class="pl-k">import</span> <span class="pl-s1">matplotlib</span>.<span class="pl-s1">pyplot</span> <span class="pl-k">as</span> <span class="pl-s1">plt</span>
<span class="pl-k">import</span> <span class="pl-s1">numpy</span> <span class="pl-k">as</span> <span class="pl-s1">np</span>
<span class="pl-k">import</span> <span class="pl-s1">math</span>
<span class="pl-s1">pi</span> <span class="pl-c1">=</span> <span class="pl-s1">math</span>.<span class="pl-s1">pi</span>

<span class="pl-s1">x</span>, <span class="pl-s1">y</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">meshgrid</span>( <span class="pl-s1">np</span>.<span class="pl-en">linspace</span>(<span class="pl-c1">-</span><span class="pl-c1">3</span>, <span class="pl-c1">7</span>, <span class="pl-c1">100</span>) , <span class="pl-s1">np</span>.<span class="pl-en">linspace</span>(<span class="pl-c1">-</span><span class="pl-c1">3</span>, <span class="pl-c1">7</span>, <span class="pl-c1">100</span>))

<span class="pl-v">V</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">linspace</span>(<span class="pl-c1">-</span><span class="pl-c1">4</span>, <span class="pl-c1">4</span>, <span class="pl-c1">100</span>)
<span class="pl-v">U</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">linspace</span>(<span class="pl-c1">-</span><span class="pl-c1">4</span>, <span class="pl-c1">4</span>, <span class="pl-c1">100</span>) 

<span class="pl-v">U</span>, <span class="pl-v">V</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">meshgrid</span>(<span class="pl-v">U</span>, <span class="pl-v">V</span>)
<span class="pl-v">X</span> <span class="pl-c1">=</span> <span class="pl-v">U</span><span class="pl-c1">**</span><span class="pl-c1">2</span>
<span class="pl-v">Y</span> <span class="pl-c1">=</span> <span class="pl-v">V</span><span class="pl-c1">**</span><span class="pl-c1">2</span>

<span class="pl-v">Z</span> <span class="pl-c1">=</span> <span class="pl-v">U</span> <span class="pl-c1">+</span> <span class="pl-c1">2</span><span class="pl-c1">*</span><span class="pl-v">V</span>

<span class="pl-s1">fig</span> <span class="pl-c1">=</span> <span class="pl-s1">plt</span>.<span class="pl-en">figure</span>(<span class="pl-s">'1'</span>, <span class="pl-s1">figsize</span><span class="pl-c1">=</span>(<span class="pl-c1">8</span>,<span class="pl-c1">7</span>))
<span class="pl-s1">ax</span> <span class="pl-c1">=</span> <span class="pl-s1">fig</span>.<span class="pl-en">add_subplot</span>(<span class="pl-c1">111</span>, <span class="pl-s1">projection</span><span class="pl-c1">=</span><span class="pl-s">'3d'</span>)
<span class="pl-s1">ax</span>.<span class="pl-en">plot_surface</span>(<span class="pl-v">X</span>, <span class="pl-v">Y</span>, <span class="pl-v">Z</span>, <span class="pl-s1">cmap</span> <span class="pl-c1">=</span> <span class="pl-s1">plt</span>.<span class="pl-s1">cm</span>.<span class="pl-s1">coolwarm</span>)

<span class="pl-s1">k</span><span class="pl-c1">=</span><span class="pl-c1">10</span>
<span class="pl-s1">ax</span>.<span class="pl-en">plot</span>(<span class="pl-s1">np</span>.<span class="pl-en">linspace</span>(<span class="pl-c1">-</span><span class="pl-c1">2</span><span class="pl-c1">-</span><span class="pl-s1">k</span>, <span class="pl-c1">1</span><span class="pl-c1">+</span><span class="pl-s1">k</span>, <span class="pl-c1">10</span>), <span class="pl-s1">np</span>.<span class="pl-en">linspace</span>(<span class="pl-c1">-</span><span class="pl-c1">4</span><span class="pl-c1">-</span><span class="pl-s1">k</span>, <span class="pl-c1">1</span><span class="pl-c1">+</span><span class="pl-s1">k</span>, <span class="pl-c1">10</span>), <span class="pl-s1">np</span>.<span class="pl-en">linspace</span>(<span class="pl-c1">3</span><span class="pl-c1">-</span><span class="pl-s1">k</span>, <span class="pl-c1">4</span><span class="pl-c1">+</span><span class="pl-s1">k</span>, <span class="pl-c1">10</span>), <span class="pl-s">'k'</span> )

<span class="pl-s1">ax</span>.<span class="pl-en">set_xlabel</span>(<span class="pl-s">'x'</span>)
<span class="pl-s1">ax</span>.<span class="pl-en">set_ylabel</span>(<span class="pl-s">'y'</span>)
<span class="pl-s1">ax</span>.<span class="pl-en">set_zlabel</span>(<span class="pl-s">'z'</span>)
<span class="pl-s1">plt</span>.<span class="pl-en">tight_layout</span>()</pre></div>
<h3 dir="auto">Actual outcome</h3>
<p dir="auto">The line seems to be plotted below the surface for some azimuthal angles.</p>
<h3 dir="auto">Expected outcome</h3>
<p dir="auto">The line should always be seen on top of the surface.</p>
<h3 dir="auto">Additional information</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Operating system</h3>
<p dir="auto">Windows 10</p>
<h3 dir="auto">Matplotlib Version</h3>
<p dir="auto">3.2.2</p>
<h3 dir="auto">Matplotlib Backend</h3>
<p dir="auto">Qt5Agg</p>
<h3 dir="auto">Python version</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Jupyter version</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Installation</h3>
<p dir="auto">conda</p>
<h3 dir="auto">Bug report</h3>
<p dir="auto"><strong>Bug summary</strong></p>
<p dir="auto">When using the voxels rendering for Axes3D, surfaces and lines are not stacked correctly in the visual perspective of the axes.</p>
<p dir="auto"><strong>Code for reproduction</strong></p>
<p dir="auto">Adding the following lines to the example from matplotlib's example <a href="https://matplotlib.org/gallery/mplot3d/voxels.html" rel="nofollow">https://matplotlib.org/gallery/mplot3d/voxels.html</a> produces the glitch:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="(xx, yy) = np.meshgrid(x, x, indexing='ij')
zz = np.ones_like(xx) * 4
ax.plot_surface(xx, yy, zz)"><pre lang="x" class="notranslate"><code class="notranslate">(xx, yy) = np.meshgrid(x, x, indexing='ij')
zz = np.ones_like(xx) * 4
ax.plot_surface(xx, yy, zz)
</code></pre></div>
<p dir="auto">or<br>
<code class="notranslate">ax.plot_wireframe(xx, yy, zz)</code></p>
<p dir="auto">before the line<br>
<code class="notranslate">plt.show()</code></p>
<p dir="auto"><strong>Actual outcome</strong></p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/106832/53702363-6236df80-3e06-11e9-92f9-a19a0fd5cceb.png"><img src="https://user-images.githubusercontent.com/106832/53702363-6236df80-3e06-11e9-92f9-a19a0fd5cceb.png" alt="voxels_surface" style="max-width: 100%;"></a></p>
<p dir="auto"><strong>Expected outcome</strong></p>
<p dir="auto">The plane should be rendered below the green voxels and some of the red voxels.<br>
When rotating, some of the voxels become visible.<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/106832/53702387-a3c78a80-3e06-11e9-985c-4c432aa3fe1a.png"><img src="https://user-images.githubusercontent.com/106832/53702387-a3c78a80-3e06-11e9-985c-4c432aa3fe1a.png" alt="voxels_surface_2" style="max-width: 100%;"></a></p>
<p dir="auto"><strong>Matplotlib version</strong><br>
Using matplotlib from a miniconda distribution:</p>
<ul dir="auto">
<li>Operating system: linux64</li>
<li>Matplotlib version: 3.0.2</li>
<li>Matplotlib backend : Qt5Agg</li>
<li>Python version: 3.6</li>
</ul>
<p dir="auto">Thank you in advance!</p>
<p dir="auto">Cheers,<br>
Nicola</p>