<p dir="auto">The mathtext rendered in the 1.3.1 release does't work with the bundled pyparsing.py module (1.5.0).</p>
<p dir="auto">Simply installing the latest version of the pyparsing.py module with easy install doesn't work. It does if the matplotlib\pyparsing.py file is overvritten with the newer version (2.0.1).</p>
<p dir="auto">I don't know why the pyparsing.py module comes with the matplotlib source, but it could be useful to provide an option to allow using that installed manually.</p>
<p dir="auto">Thank you!</p>
<h3 dir="auto">Bug report</h3>
<p dir="auto"><strong>Bug summary</strong></p>
<p dir="auto">Because <code class="notranslate">IndexFormatter.__call__</code> doesn't round to the nearest integer but truncates/round up to the next integer, x ticks labels are duplicated when user pans plot to left, displaying values below minimum.</p>
<p dir="auto"><strong>Code for reproduction</strong></p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="
import matplotlib.pyplot as plt
from matplotlib.ticker import IndexFormatter

x = [1, 2, 3, 4, 5]
y = [1, 3, 5, 6, 0]
x_labels = ['under', 'a', 'b', 'c', 'd', 'e', 'over']

fig, ax = plt.subplots()
print(x[1])
ax.xaxis.set_major_formatter(IndexFormatter(x_labels))
ax.plot(x, y, '-o')
plt.show()"><pre class="notranslate"><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-s1">ticker</span> <span class="pl-k">import</span> <span class="pl-v">IndexFormatter</span>

<span class="pl-s1">x</span> <span class="pl-c1">=</span> [<span class="pl-c1">1</span>, <span class="pl-c1">2</span>, <span class="pl-c1">3</span>, <span class="pl-c1">4</span>, <span class="pl-c1">5</span>]
<span class="pl-s1">y</span> <span class="pl-c1">=</span> [<span class="pl-c1">1</span>, <span class="pl-c1">3</span>, <span class="pl-c1">5</span>, <span class="pl-c1">6</span>, <span class="pl-c1">0</span>]
<span class="pl-s1">x_labels</span> <span class="pl-c1">=</span> [<span class="pl-s">'under'</span>, <span class="pl-s">'a'</span>, <span class="pl-s">'b'</span>, <span class="pl-s">'c'</span>, <span class="pl-s">'d'</span>, <span class="pl-s">'e'</span>, <span class="pl-s">'over'</span>]

<span class="pl-s1">fig</span>, <span class="pl-s1">ax</span> <span class="pl-c1">=</span> <span class="pl-s1">plt</span>.<span class="pl-en">subplots</span>()
<span class="pl-en">print</span>(<span class="pl-s1">x</span>[<span class="pl-c1">1</span>])
<span class="pl-s1">ax</span>.<span class="pl-s1">xaxis</span>.<span class="pl-en">set_major_formatter</span>(<span class="pl-v">IndexFormatter</span>(<span class="pl-s1">x_labels</span>))
<span class="pl-s1">ax</span>.<span class="pl-en">plot</span>(<span class="pl-s1">x</span>, <span class="pl-s1">y</span>, <span class="pl-s">'-o'</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/28050769/75695105-904c3b00-5c77-11ea-89ee-f9820b404858.png"><img src="https://user-images.githubusercontent.com/28050769/75695105-904c3b00-5c77-11ea-89ee-f9820b404858.png" alt="bug" style="max-width: 100%;"></a></p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="class IndexFormatter(Formatter):

[...]

    def __call__(self, x, pos=None):
        &quot;&quot;&quot;
        Return the format for tick value `x` at position pos.

        The position is ignored and the value is rounded to the nearest
        integer ******** NOT TRUE *********, which is used to look up the label.
        &quot;&quot;&quot;
        i = int(x + 0.5)
        if i &lt; 0 or i &gt;= self.n:
            return ''
        else:
            return self.labels[i]
"><pre class="notranslate"><span class="pl-k">class</span> <span class="pl-v">IndexFormatter</span>(<span class="pl-v">Formatter</span>):

[...]

    <span class="pl-k">def</span> <span class="pl-en">__call__</span>(<span class="pl-s1">self</span>, <span class="pl-s1">x</span>, <span class="pl-s1">pos</span><span class="pl-c1">=</span><span class="pl-c1">None</span>):
        <span class="pl-s">"""</span>
<span class="pl-s">        Return the format for tick value `x` at position pos.</span>
<span class="pl-s"></span>
<span class="pl-s">        The position is ignored and the value is rounded to the nearest</span>
<span class="pl-s">        integer ******** NOT TRUE *********, which is used to look up the label.</span>
<span class="pl-s">        """</span>
        <span class="pl-s1">i</span> <span class="pl-c1">=</span> <span class="pl-en">int</span>(<span class="pl-s1">x</span> <span class="pl-c1">+</span> <span class="pl-c1">0.5</span>)
        <span class="pl-k">if</span> <span class="pl-s1">i</span> <span class="pl-c1">&lt;</span> <span class="pl-c1">0</span> <span class="pl-c1">or</span> <span class="pl-s1">i</span> <span class="pl-c1">&gt;=</span> <span class="pl-s1">self</span>.<span class="pl-s1">n</span>:
            <span class="pl-k">return</span> <span class="pl-s">''</span>
        <span class="pl-k">else</span>:
            <span class="pl-k">return</span> <span class="pl-s1">self</span>.<span class="pl-s1">labels</span>[<span class="pl-s1">i</span>]</pre></div>
<p dir="auto"><a href="https://matplotlib.org/3.1.3/_modules/matplotlib/ticker.html#IndexFormatter" rel="nofollow">IndexFormatter</a> returns self.labels[0] for x = -1 instead of an empty string</p>
<p dir="auto"><strong>Expected outcome</strong></p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/28050769/75695138-9cd09380-5c77-11ea-8414-938fc0ddf3a6.png"><img src="https://user-images.githubusercontent.com/28050769/75695138-9cd09380-5c77-11ea-8414-938fc0ddf3a6.png" alt="int_round" style="max-width: 100%;"></a></p>
<p dir="auto"><strong>Proposed solution to correct [IndexFormatter] (<a href="https://matplotlib.org/3.1.3/_modules/matplotlib/ticker.html#IndexFormatter" rel="nofollow">https://matplotlib.org/3.1.3/_modules/matplotlib/ticker.html#IndexFormatter</a>)</strong></p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="
def __call__(self, x, pos=None):
        &quot;&quot;&quot;
        Return the format for tick value `x` at position pos.

        The position is ignored and the value is rounded to the nearest
        integer, which is used to look up the label.
        &quot;&quot;&quot;
        i = int(round(x))
        if i &lt; 0 or i &gt;= self.n:
            return ''
        else:
            return self.labels[i]"><pre class="notranslate"><span class="pl-k">def</span> <span class="pl-en">__call__</span>(<span class="pl-s1">self</span>, <span class="pl-s1">x</span>, <span class="pl-s1">pos</span><span class="pl-c1">=</span><span class="pl-c1">None</span>):
        <span class="pl-s">"""</span>
<span class="pl-s">        Return the format for tick value `x` at position pos.</span>
<span class="pl-s"></span>
<span class="pl-s">        The position is ignored and the value is rounded to the nearest</span>
<span class="pl-s">        integer, which is used to look up the label.</span>
<span class="pl-s">        """</span>
        <span class="pl-s1">i</span> <span class="pl-c1">=</span> <span class="pl-en">int</span>(<span class="pl-en">round</span>(<span class="pl-s1">x</span>))
        <span class="pl-k">if</span> <span class="pl-s1">i</span> <span class="pl-c1">&lt;</span> <span class="pl-c1">0</span> <span class="pl-c1">or</span> <span class="pl-s1">i</span> <span class="pl-c1">&gt;=</span> <span class="pl-s1">self</span>.<span class="pl-s1">n</span>:
            <span class="pl-k">return</span> <span class="pl-s">''</span>
        <span class="pl-k">else</span>:
            <span class="pl-k">return</span> <span class="pl-s1">self</span>.<span class="pl-s1">labels</span>[<span class="pl-s1">i</span>]</pre></div>
<p dir="auto"><strong>Matplotlib version</strong></p>
<ul dir="auto">
<li>Matplotlib version:  3.1.3</li>
</ul>