<h3 dir="auto">Bug summary</h3>
<p dir="auto">There are several rendering errors when creating a <code class="notranslate">bar3d</code> chart:</p>
<ul dir="auto">
<li>for some bars the side walls are missing, e.g. at (1,0), (3,0) or (7,0).</li>
<li>the edge to the x-axis of the top of bar (0,1) is partially visible, although it should be completely covered by bar (0,0).</li>
<li>the label of the y-axis is shifted to the left, the 0 is not at the level of the 0-coordinate.</li>
</ul>
<p dir="auto">The list of errors is not complete, I think everyone can recognize the errors when looking closely.</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="#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import numpy as np
import matplotlib.pyplot as plt
from matplotlib import cm

# generate data
x = np.array(10*list(range(10)))
y = np.array([])
for i in x[0:10]:
    y = np.append(y,np.ones(10)*i)
rng = np.random.default_rng(4)
z = rng.random(len(x))+0.5

# plot
fig = plt.figure()
ax = fig.add_subplot(1,1,1, projection='3d')
ax.set_xlabel('x')
ax.set_ylabel('y')
x_pos = x-1/2
y_pos = y-1/2
z_pos = [0]*len(z)
x_size = np.ones(len(z))
y_size = np.ones(len(z))
z_size = z
colormap = cm.ScalarMappable()
color = colormap.to_rgba(z)
ax.bar3d(x_pos, y_pos, z_pos, x_size, y_size, z_size, color=color, shade=True)
plt.savefig('plt.png', dpi=300)"><pre class="notranslate"><span class="pl-c">#!/usr/bin/env python3</span>
<span class="pl-c"># -*- coding: utf-8 -*-</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">matplotlib</span>.<span class="pl-s1">pyplot</span> <span class="pl-k">as</span> <span class="pl-s1">plt</span>
<span class="pl-k">from</span> <span class="pl-s1">matplotlib</span> <span class="pl-k">import</span> <span class="pl-s1">cm</span>

<span class="pl-c"># generate data</span>
<span class="pl-s1">x</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">array</span>(<span class="pl-c1">10</span><span class="pl-c1">*</span><span class="pl-en">list</span>(<span class="pl-en">range</span>(<span class="pl-c1">10</span>)))
<span class="pl-s1">y</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">array</span>([])
<span class="pl-k">for</span> <span class="pl-s1">i</span> <span class="pl-c1">in</span> <span class="pl-s1">x</span>[<span class="pl-c1">0</span>:<span class="pl-c1">10</span>]:
    <span class="pl-s1">y</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">append</span>(<span class="pl-s1">y</span>,<span class="pl-s1">np</span>.<span class="pl-en">ones</span>(<span class="pl-c1">10</span>)<span class="pl-c1">*</span><span class="pl-s1">i</span>)
<span class="pl-s1">rng</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-s1">random</span>.<span class="pl-en">default_rng</span>(<span class="pl-c1">4</span>)
<span class="pl-s1">z</span> <span class="pl-c1">=</span> <span class="pl-s1">rng</span>.<span class="pl-en">random</span>(<span class="pl-en">len</span>(<span class="pl-s1">x</span>))<span class="pl-c1">+</span><span class="pl-c1">0.5</span>

<span class="pl-c"># plot</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-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">1</span>,<span class="pl-c1">1</span>,<span class="pl-c1">1</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">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">x_pos</span> <span class="pl-c1">=</span> <span class="pl-s1">x</span><span class="pl-c1">-</span><span class="pl-c1">1</span><span class="pl-c1">/</span><span class="pl-c1">2</span>
<span class="pl-s1">y_pos</span> <span class="pl-c1">=</span> <span class="pl-s1">y</span><span class="pl-c1">-</span><span class="pl-c1">1</span><span class="pl-c1">/</span><span class="pl-c1">2</span>
<span class="pl-s1">z_pos</span> <span class="pl-c1">=</span> [<span class="pl-c1">0</span>]<span class="pl-c1">*</span><span class="pl-en">len</span>(<span class="pl-s1">z</span>)
<span class="pl-s1">x_size</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">ones</span>(<span class="pl-en">len</span>(<span class="pl-s1">z</span>))
<span class="pl-s1">y_size</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">ones</span>(<span class="pl-en">len</span>(<span class="pl-s1">z</span>))
<span class="pl-s1">z_size</span> <span class="pl-c1">=</span> <span class="pl-s1">z</span>
<span class="pl-s1">colormap</span> <span class="pl-c1">=</span> <span class="pl-s1">cm</span>.<span class="pl-v">ScalarMappable</span>()
<span class="pl-s1">color</span> <span class="pl-c1">=</span> <span class="pl-s1">colormap</span>.<span class="pl-en">to_rgba</span>(<span class="pl-s1">z</span>)
<span class="pl-s1">ax</span>.<span class="pl-en">bar3d</span>(<span class="pl-s1">x_pos</span>, <span class="pl-s1">y_pos</span>, <span class="pl-s1">z_pos</span>, <span class="pl-s1">x_size</span>, <span class="pl-s1">y_size</span>, <span class="pl-s1">z_size</span>, <span class="pl-s1">color</span><span class="pl-c1">=</span><span class="pl-s1">color</span>, <span class="pl-s1">shade</span><span class="pl-c1">=</span><span class="pl-c1">True</span>)
<span class="pl-s1">plt</span>.<span class="pl-en">savefig</span>(<span class="pl-s">'plt.png'</span>, <span class="pl-s1">dpi</span><span class="pl-c1">=</span><span class="pl-c1">300</span>)</pre></div>
<h3 dir="auto">Actual outcome</h3>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/81165783/221412290-1787d46c-ca96-4f93-a65c-c7d34b1fc2d0.png"><img src="https://user-images.githubusercontent.com/81165783/221412290-1787d46c-ca96-4f93-a65c-c7d34b1fc2d0.png" alt="plt" style="max-width: 100%;"></a></p>
<h3 dir="auto">Expected outcome</h3>
<p dir="auto">I expect a correct 3D rendering</p>
<h3 dir="auto">Additional information</h3>
<p dir="auto">There is a similar bug <a href="https://github.com/matplotlib/matplotlib/issues/13728" data-hovercard-type="issue" data-hovercard-url="/matplotlib/matplotlib/issues/13728/hovercard">reported here</a>.</p>
<h3 dir="auto">Operating system</h3>
<p dir="auto">Linux Mint</p>
<h3 dir="auto">Matplotlib Version</h3>
<p dir="auto">3.7.0</p>
<h3 dir="auto">Matplotlib Backend</h3>
<p dir="auto">module://matplotlib_inline.backend_inline</p>
<h3 dir="auto">Python version</h3>
<p dir="auto">3.10.6</p>
<h3 dir="auto">Jupyter version</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Installation</h3>
<p dir="auto">pip</p>
<h3 dir="auto">Bug report</h3>
<p dir="auto"><strong>Bug summary</strong><br>
Z-order of rendered planes in 3d bar chart produced by bar3d is wrong. It is seen even in the example here <a href="https://matplotlib.org/gallery/mplot3d/3d_bars.html" rel="nofollow">https://matplotlib.org/gallery/mplot3d/3d_bars.html</a>. One of the bars (at location 2, 4, height 6) is drawn on top of the highest bar, even though it supposed to be behind it.</p>
<p dir="auto"><strong>Code for reproduction</strong><br>
A small modification of the code from example to make it more pronounced.</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import numpy as np
import matplotlib.pyplot as plt
# This import registers the 3D projection, but is otherwise unused.
from mpl_toolkits.mplot3d import Axes3D  # noqa: F401 unused import


# setup the figure and axes
fig = plt.figure(figsize=(8, 8))
ax1 = fig.add_subplot(111, projection='3d')

# fake data
_x = np.arange(8)
_y = np.arange(8)
_xx, _yy = np.meshgrid(_x, _y)
x, y = _xx.ravel(), _yy.ravel()

top = x + y
bottom = np.zeros_like(top)
width = depth = 1

ax1.bar3d(x, y, bottom, width, depth, top, shade=True)
ax1.set_title('Shaded')
plt.show()"><pre class="notranslate"><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">matplotlib</span>.<span class="pl-s1">pyplot</span> <span class="pl-k">as</span> <span class="pl-s1">plt</span>
<span class="pl-c"># This import registers the 3D projection, but is otherwise unused.</span>
<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-c"># noqa: F401 unused import</span>


<span class="pl-c"># setup the figure and axes</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-s1">figsize</span><span class="pl-c1">=</span>(<span class="pl-c1">8</span>, <span class="pl-c1">8</span>))
<span class="pl-s1">ax1</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-c"># fake data</span>
<span class="pl-s1">_x</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">arange</span>(<span class="pl-c1">8</span>)
<span class="pl-s1">_y</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">arange</span>(<span class="pl-c1">8</span>)
<span class="pl-s1">_xx</span>, <span class="pl-s1">_yy</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">meshgrid</span>(<span class="pl-s1">_x</span>, <span class="pl-s1">_y</span>)
<span class="pl-s1">x</span>, <span class="pl-s1">y</span> <span class="pl-c1">=</span> <span class="pl-s1">_xx</span>.<span class="pl-en">ravel</span>(), <span class="pl-s1">_yy</span>.<span class="pl-en">ravel</span>()

<span class="pl-s1">top</span> <span class="pl-c1">=</span> <span class="pl-s1">x</span> <span class="pl-c1">+</span> <span class="pl-s1">y</span>
<span class="pl-s1">bottom</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">zeros_like</span>(<span class="pl-s1">top</span>)
<span class="pl-s1">width</span> <span class="pl-c1">=</span> <span class="pl-s1">depth</span> <span class="pl-c1">=</span> <span class="pl-c1">1</span>

<span class="pl-s1">ax1</span>.<span class="pl-en">bar3d</span>(<span class="pl-s1">x</span>, <span class="pl-s1">y</span>, <span class="pl-s1">bottom</span>, <span class="pl-s1">width</span>, <span class="pl-s1">depth</span>, <span class="pl-s1">top</span>, <span class="pl-s1">shade</span><span class="pl-c1">=</span><span class="pl-c1">True</span>)
<span class="pl-s1">ax1</span>.<span class="pl-en">set_title</span>(<span class="pl-s">'Shaded'</span>)
<span class="pl-s1">plt</span>.<span class="pl-en">show</span>()</pre></div>
<p dir="auto"><strong>Actual outcome</strong></p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/9054941/54744129-1905ce80-4c01-11e9-808a-39a54d870363.png"><img src="https://user-images.githubusercontent.com/9054941/54744129-1905ce80-4c01-11e9-808a-39a54d870363.png" alt="image" style="max-width: 100%;"></a></p>
<p dir="auto">Everything to the right from diagonal is rendered incorrectly.</p>
<p dir="auto"><strong>Matplotlib version</strong><br>
Tested on two machines with the same results.</p>
<ul dir="auto">
<li>Operating system: mac and windows</li>
<li>Matplotlib version:<br>
matplotlib                2.1.2            py36h6d6146d_0<br>
and<br>
matplotlib                3.0.3            py37_0    conda-forge</li>
<li>Matplotlib backend (<code class="notranslate">print(matplotlib.get_backend())</code>): module://ipykernel.pylab.backend_inline</li>
<li>Python version:<br>
3.6.0 |Anaconda custom (64-bit)| (default, Dec 23 2016, 13:19:00)<br>
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)]<br>
and<br>
3.7.1 | packaged by conda-forge | (default, Mar 13 2019, 13:32:59) [MSC v.1900 64 bit (AMD64)]</li>
<li>Jupyter version (if applicable):<br>
ipython                   5.1.0                    py36_1<br>
and<br>
ipython                   7.3.0            py37h39e3cac_0    conda-forge</li>
</ul>