<h3 dir="auto">Bug summary</h3>
<p dir="auto">When providing a large number of <code class="notranslate">x</code> and <code class="notranslate">height</code> values, there are often missing bars.</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="import numpy as np
import matplotlib.pyplot as plt

num_elems = 35000
x = np.sort(np.random.random(num_elems))
plt.bar(range(num_elems), x)"><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-s1">num_elems</span> <span class="pl-c1">=</span> <span class="pl-c1">35000</span>
<span class="pl-s1">x</span> <span class="pl-c1">=</span> <span class="pl-s1">np</span>.<span class="pl-en">sort</span>(<span class="pl-s1">np</span>.<span class="pl-s1">random</span>.<span class="pl-en">random</span>(<span class="pl-s1">num_elems</span>))
<span class="pl-s1">plt</span>.<span class="pl-en">bar</span>(<span class="pl-en">range</span>(<span class="pl-s1">num_elems</span>), <span class="pl-s1">x</span>)</pre></div>
<h3 dir="auto">Actual outcome</h3>
<p dir="auto">The expected outcome should be a smooth right-triangle.</p>
<h3 dir="auto">Expected outcome</h3>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/186566/152627282-8c80d38f-1744-416e-8083-0f311a1574c5.png"><img src="https://user-images.githubusercontent.com/186566/152627282-8c80d38f-1744-416e-8083-0f311a1574c5.png" alt="image" style="max-width: 100%;"></a></p>
<h3 dir="auto">Additional information</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Operating system</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Matplotlib Version</h3>
<p dir="auto">3.3.4</p>
<h3 dir="auto">Matplotlib Backend</h3>
<p dir="auto">module://IPython.kernel.zmq.pylab.backend_inline</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"><em>No response</em></p>
<p dir="auto">I found a bug in the bar plot when the bar size gets really small and lots of bins are represented. I found it while doing a histogram and traced it into the bar plot.</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="from pylab import *
import random

random.seed()

b = int(2.2 / 0.0006)
x = [-1 + i * 0.0006 for i in range(b)]
y = [random.uniform(0, 100) for _ in range(b)]

fig, (ax1, ax2) = subplots(2, 1)

ax1.bar(x, y, width=0.0001)
ax2.plot(x, y, lw=0.2)

plt.tight_layout()
plt.savefig('hist.png', dpi=150, format='png')
plt.close()"><pre class="notranslate"><span class="pl-k">from</span> <span class="pl-s1">pylab</span> <span class="pl-k">import</span> <span class="pl-c1">*</span>
<span class="pl-k">import</span> <span class="pl-s1">random</span>

<span class="pl-s1">random</span>.<span class="pl-en">seed</span>()

<span class="pl-s1">b</span> <span class="pl-c1">=</span> <span class="pl-en">int</span>(<span class="pl-c1">2.2</span> <span class="pl-c1">/</span> <span class="pl-c1">0.0006</span>)
<span class="pl-s1">x</span> <span class="pl-c1">=</span> [<span class="pl-c1">-</span><span class="pl-c1">1</span> <span class="pl-c1">+</span> <span class="pl-s1">i</span> <span class="pl-c1">*</span> <span class="pl-c1">0.0006</span> <span class="pl-k">for</span> <span class="pl-s1">i</span> <span class="pl-c1">in</span> <span class="pl-en">range</span>(<span class="pl-s1">b</span>)]
<span class="pl-s1">y</span> <span class="pl-c1">=</span> [<span class="pl-s1">random</span>.<span class="pl-en">uniform</span>(<span class="pl-c1">0</span>, <span class="pl-c1">100</span>) <span class="pl-k">for</span> <span class="pl-s1">_</span> <span class="pl-c1">in</span> <span class="pl-en">range</span>(<span class="pl-s1">b</span>)]

<span class="pl-s1">fig</span>, (<span class="pl-s1">ax1</span>, <span class="pl-s1">ax2</span>) <span class="pl-c1">=</span> <span class="pl-en">subplots</span>(<span class="pl-c1">2</span>, <span class="pl-c1">1</span>)

<span class="pl-s1">ax1</span>.<span class="pl-en">bar</span>(<span class="pl-s1">x</span>, <span class="pl-s1">y</span>, <span class="pl-s1">width</span><span class="pl-c1">=</span><span class="pl-c1">0.0001</span>)
<span class="pl-s1">ax2</span>.<span class="pl-en">plot</span>(<span class="pl-s1">x</span>, <span class="pl-s1">y</span>, <span class="pl-s1">lw</span><span class="pl-c1">=</span><span class="pl-c1">0.2</span>)

<span class="pl-s1">plt</span>.<span class="pl-en">tight_layout</span>()
<span class="pl-s1">plt</span>.<span class="pl-en">savefig</span>(<span class="pl-s">'hist.png'</span>, <span class="pl-s1">dpi</span><span class="pl-c1">=</span><span class="pl-c1">150</span>, <span class="pl-s1">format</span><span class="pl-c1">=</span><span class="pl-s">'png'</span>)
<span class="pl-s1">plt</span>.<span class="pl-en">close</span>()</pre></div>
<p dir="auto"><strong>Actual outcome</strong></p>
<p dir="auto">The bug consists in missing bars for some unknown reason. The code below shows the comparison between the bar plot and the same x, y plotted as a line. It can be noticed the difference in number of represented points.</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/1878127/27587559-1f084a3c-5b45-11e7-8dca-ef7d5381eb42.png"><img src="https://user-images.githubusercontent.com/1878127/27587559-1f084a3c-5b45-11e7-8dca-ef7d5381eb42.png" alt="hist" style="max-width: 100%;"></a></p>
<p dir="auto"><strong>Matplotlib version</strong></p>
<ul dir="auto">
<li>Operating System: Manjaro Linux</li>
<li>Matplotlib Version: 2.0.2</li>
<li>Python Version: 3.6.1</li>
</ul>
<p dir="auto">I installed through pre-compiled package provided by Manjaro maintainers</p>