<h3 dir="auto"></h3>
<p dir="auto">OS: Archlinux<br>
Python: 2.7.8<br>
PyQt bindings: 5.3.2-1<br>
Qt: 5.3.2-1<br>
Matplotlib: 1.4.0-2</p>
<h3 dir="auto"></h3>
<p dir="auto">Steps to reproduce:</p>
<p dir="auto">from matplotlib import pyplot as plt<br>
y_data = [....]<br>
plt.plot(y_data, 'k+')<br>
plt.show()</p>
<p dir="auto">then press the "Save the figure" icon, it shows the dialog to write a filename. Then press Save, a model error window will pop-up complaining that "png)')" is not a supporte file extension.</p>
<p dir="auto">Digging further in matplotlib/backend_bases.py (~2098) tries to resolve the extension by</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="        if cbook.is_string_like(filename):
            format = os.path.splitext(filename)[1][1:]"><pre class="notranslate"><code class="notranslate">        if cbook.is_string_like(filename):
            format = os.path.splitext(filename)[1][1:]
</code></pre></div>
<p dir="auto">but filename is this unicode:<br>
u"(u'/home/rbm/figure_1.png', u'Portable Network Graphics (*.png)')"</p>
<p dir="auto">This in turn comes from the qt5 backend filters passed in method save_fig of matplotlib/backends/backend_qt5.py :<br>
Encapsulated Postscript (<em>.eps);;Joint Photographic Experts Group (</em>.jpeg <em>.jpg);;PGF code for LaTeX (</em>.pgf);;Portable Document Format (<em>.pdf);;Portable Network Graphics (</em>.png);;Postscript (<em>.ps);;Raw RGBA bitmap (</em>.raw <em>.rgba);;Scalable Vector Graphics (</em>.svg <em>.svgz);;Tagged Image File Format (</em>.tif *.tiff)</p>
<p dir="auto">This will fail for every other format whatever choosed in the Save File dialog.<br>
I tested the GTK backend and it doesn't have this problem.</p>
<p dir="auto">Bug also reported here: <a href="https://bugs.archlinux.org/task/41790" rel="nofollow">https://bugs.archlinux.org/task/41790</a><br>
When clicking on the Save button on the NavigationToolbar, I get an error:<br>
<code class="notranslate">Format "png)')" is not supported. Supported formats: eps, jpeg, jpg, pdf, pgf, png, ps, raw, rgba, svg, svgz, tif, tiff.</code></p>
<p dir="auto">I tracked the bug to be coming from the output of the <code class="notranslate">_getSaveFileName</code> function, that is supposed to be a string but is a tuple in reality. In <code class="notranslate">qt_compat.py</code>, <code class="notranslate">_getSaveFileName</code> links to QtWidgets.QtFileDialog.getSaveFileName.<br>
In pyqt4, this function returns a string, but the doc pyqt4/5 differences says that in pyqt5 the functions returns a tuple (filename, extension), as for <code class="notranslate">getSaveFileNameAndFilter</code> in pyqt4.</p>
<p dir="auto">Commenting line 96 in <code class="notranslate">qt_compat.py</code>  solved the problem, because <code class="notranslate">_getSaveFileName</code> is then correctly defined in line 117 (only returning the first element of the tuple).</p>