<h3 dir="auto">Bug summary</h3>
<p dir="auto">Pyplot can't parse mathtext string, where there is a latin chatacter after greek letter (with spacing of course)</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 matplotlib.pyplot as plt
plt.title(r'$\alpha x$')
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-s1">plt</span>.<span class="pl-en">title</span>(<span class="pl-s">r'$\alpha x$'</span>)
<span class="pl-s1">plt</span>.<span class="pl-en">show</span>()</pre></div>
<h3 dir="auto">Actual outcome</h3>
<p dir="auto">Exception in Tkinter callback<br>
Traceback (most recent call last):<br>
File "/home/brave_falcon/.local/lib/python3.8/site-packages/matplotlib/_mathtext.py", line 2277, in parse<br>
result = self._expression.parseString(s)<br>
File "/home/brave_falcon/.local/lib/python3.8/site-packages/pyparsing/core.py", line 1107, in parse_string<br>
raise exc.with_traceback(None)<br>
pyparsing.exceptions.ParseFatalException: Unknown symbol: \alpha, found ''  (at char 0), (line:1, col:1)</p>
<h3 dir="auto">Expected outcome</h3>
<p dir="auto">Just normal parsing of mathtext, without raising errors</p>
<h3 dir="auto">Operating system</h3>
<p dir="auto">Ubuntu 18.04.6 LTS</p>
<h3 dir="auto">Matplotlib Version</h3>
<p dir="auto">3.4.3</p>
<h3 dir="auto">Matplotlib Backend</h3>
<p dir="auto">TkAgg</p>
<h3 dir="auto">Python version</h3>
<p dir="auto">Python 3.8.12</p>
<h3 dir="auto">Jupyter version</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Other libraries</h3>
<p dir="auto"><em>No response</em></p>
<h3 dir="auto">Installation</h3>
<p dir="auto">pip</p>
<h3 dir="auto">Conda channel</h3>
<p dir="auto"><em>No response</em></p>
<p dir="auto">I've noticed there is push in the documentation for using objects over the pyplot functions. I agree that this the best way to use Matplotlib(other than the set_ get_ methods). The problem I have is that Jedi(used in Spyder IDE and other editors) doesn't recognize the return types of some Matplotlib functions and methods such as <code class="notranslate">plt.figure</code> and <code class="notranslate">plt.subplot</code>.  For example in Jedi 0.9 you get:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="In [1]: import jedi; jedi.Script('import pylab; a = pylab.figure(); a.set_f').completions()
Out[1]: []"><pre class="notranslate"><code class="notranslate">In [1]: import jedi; jedi.Script('import pylab; a = pylab.figure(); a.set_f').completions()
Out[1]: []
</code></pre></div>
<p dir="auto">I usually have to play with MPL code in the console first to remember all the functions instead of just typing it all in the editor.</p>
<p dir="auto">Luckily recently this patch(<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="187605183" data-permission-text="Title is private" data-url="https://github.com/davidhalter/jedi/issues/796" data-hovercard-type="pull_request" data-hovercard-url="/davidhalter/jedi/pull/796/hovercard" href="https://github.com/davidhalter/jedi/pull/796">davidhalter/jedi#796</a>) has been recently submitted to Jedi(not by me) which adds among other things implements return type hints from numpydoc docstrings. With this Jedi patch I get:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="In [1]: import jedi; jedi.Script('import pylab; a = pylab.figure(); a.set_f').completions()
Out[1]: 
[&lt;Completion: set_facecolor&gt;,
 &lt;Completion: set_figheight&gt;,
 &lt;Completion: set_figure&gt;,
 &lt;Completion: set_figwidth&gt;,
 &lt;Completion: set_frameon&gt;]"><pre class="notranslate"><code class="notranslate">In [1]: import jedi; jedi.Script('import pylab; a = pylab.figure(); a.set_f').completions()
Out[1]: 
[&lt;Completion: set_facecolor&gt;,
 &lt;Completion: set_figheight&gt;,
 &lt;Completion: set_figure&gt;,
 &lt;Completion: set_figwidth&gt;,
 &lt;Completion: set_frameon&gt;]
</code></pre></div>
<p dir="auto">Which is great. This works because there is a Numpydoc docstring for <code class="notranslate">plt.figure</code> with return of <code class="notranslate">Figure</code>. This works in Spyder IDE as well.</p>
<p dir="auto">Unfortunately, this code doesn't work even after the patch:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import jedi; jedi.Script('import pylab; ax = pylab.figure().add_subplot(111); ax.set_x').completions()"><pre class="notranslate"><code class="notranslate">import jedi; jedi.Script('import pylab; ax = pylab.figure().add_subplot(111); ax.set_x').completions()
</code></pre></div>
<p dir="auto">This is a result of the docstrings for Figure.add_subplot and Figure.add_axes not containing a numpydoc return statement.</p>
<p dir="auto">However, If I add this the top of their docstrings:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="    &quot;&quot;&quot;
    Returns
    -------
    axes : Axes
       The Axes you made
       
    Examples
    --------"><pre class="notranslate"><code class="notranslate">    """
    Returns
    -------
    axes : Axes
       The Axes you made
       
    Examples
    --------
</code></pre></div>
<p dir="auto">I then get this result with the patch applied:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="In [3]: import jedi; jedi.Script('import pylab; ax = pylab.figure().add_subplot(111); ax.set_x').completions()
Out[3]: 
[&lt;Completion: set_xbound&gt;,
 &lt;Completion: set_xlabel&gt;,
 &lt;Completion: set_xlim&gt;,
 &lt;Completion: set_xmargin&gt;,
 &lt;Completion: set_xscale&gt;,
 &lt;Completion: set_xticklabels&gt;,
 &lt;Completion: set_xticks&gt;]"><pre class="notranslate"><code class="notranslate">In [3]: import jedi; jedi.Script('import pylab; ax = pylab.figure().add_subplot(111); ax.set_x').completions()
Out[3]: 
[&lt;Completion: set_xbound&gt;,
 &lt;Completion: set_xlabel&gt;,
 &lt;Completion: set_xlim&gt;,
 &lt;Completion: set_xmargin&gt;,
 &lt;Completion: set_xscale&gt;,
 &lt;Completion: set_xticklabels&gt;,
 &lt;Completion: set_xticks&gt;]
</code></pre></div>
<p dir="auto">Which is quite helpful when trying to remember all those Axes methods and for new learners.</p>
<p dir="auto">I'm sure there are a few other functions( like <code class="notranslate">plt.gcf</code> and <code class="notranslate">Figure.gca</code> to name a couple) that could use a type hint as well.</p>
<p dir="auto">Here it is working in Spyder (Some functions of Numpy work too...That <code class="notranslate">z</code> completes as a <code class="notranslate">numpy.adarray</code> ):</p>
<p dir="auto"><a target="_blank" rel="noopener noreferrer nofollow" href="https://cloud.githubusercontent.com/assets/10513354/20744218/d1798a62-b697-11e6-9d3c-f9ecd77fde2f.png"><img src="https://cloud.githubusercontent.com/assets/10513354/20744218/d1798a62-b697-11e6-9d3c-f9ecd77fde2f.png" alt="screenshot from 2016-11-29 23-05-25" style="max-width: 100%;"></a></p>
<p dir="auto">For more info on this with spyder see my comments on <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="58000278" data-permission-text="Title is private" data-url="https://github.com/spyder-ide/spyder/issues/2162" data-hovercard-type="issue" data-hovercard-url="/spyder-ide/spyder/issues/2162/hovercard" href="https://github.com/spyder-ide/spyder/issues/2162">spyder-ide/spyder#2162</a></p>
<p dir="auto">To help us understand and resolve your issue please check that you have provided<br>
the information below.</p>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> Matplotlib version, Python version and Platform (Windows, OSX, Linux ...)<br>
I'm using Python 3.5 on Linux with Matplotlib 1.5.3</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> How did you install Matplotlib and Python (pip, anaconda, from source ...)<br>
Anaconda</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox" checked=""> If possible please supply a <a href="http://sscce.org/" rel="nofollow">Short, Self Contained, Correct, Example</a><br>
that demonstrates the issue i.e a small piece of code which reproduces the issue<br>
and can be run with out any other (or as few as possible) external dependencies.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> If this is an image generation bug attach a screenshot demonstrating the issue.</li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> If this is a regression (Used to work in an earlier version of Matplotlib), please<br>
note where it used to work.</li>
</ul>