matplotlib / matplotlib

matplotlib: plotting with Python
https://matplotlib.org/stable/
20.25k stars 7.64k forks source link

Saving polar plots with MiKTeX on Windows fails for some file formats #14146

Closed urogers closed 5 years ago

urogers commented 5 years ago

Bug summary

Saving matplotlib polar plots on Windows 7 and Windows 10, with MiKTex 2.9.7.000, fails for some formats (e.g., pdf, svg) and works for others (e.g., png, jpg)

Code for reproduction

import matplotlib.pyplot as plt
import matplotlib as mpl
mpl.rcParams['text.usetex'] = True

plt.figure()
ax = plt.subplot(111, polar=True)

plt.savefig('foo.png')  # Works
plt.savefig('foo.jpg')  # Works
plt.savefig('foo.tif')  # Works
# plt.savefig('foo.pdf')  # Fails
# plt.savefig('foo.svg')  # Fails
plt.show()

Actual outcome

"Error saving .... " window pops up with error code b'tcss1000' for pdf, and b'tcss3583' for svg. (The numbers change)

Matplotlib version

Installed via Anaconda3

QuLogic commented 5 years ago

Matplotlib version: 2.2.2

This version is fairly old; please try with 3.0.2.

ImportanceOfBeingErnest commented 5 years ago

I can reproduce this with master branch, windows 8.1 and miktex 2.9.6630.

It bisects to https://github.com/matplotlib/matplotlib/pull/11381

anntzer commented 5 years ago

Looks like a duplicate of https://github.com/matplotlib/matplotlib/issues/10272 (try installing the cm-super tex package)? (It may make sense to switch from computer modern to latin modern at some point, which at least has the advantage that we can check for its existence with \usepackage{lmodern}.)

ImportanceOfBeingErnest commented 5 years ago

Installing cm-super solves this for pdf output, but not for svg. In the svg case I get

D:\****\lib\site-packages\matplotlib\textpath.py:349: UserWarning: The glyph (176) of font  
(D:/***/MiKTeX/fonts/type1/public/cm-super/sfss3583.pfb) cannot be converted with the encoding.  
Glyph may be wrong   
 "be wrong" % (glyph, font.fname))

And the output is a svg file without the ° symbols.

I think the main point here, in contrast to #10272 is, that a standard empty plot should not fail for standard latex installations.

anntzer commented 5 years ago

Looks like if you zoom a lot, you'll see a tiny degree sign, which suggests to me that the problem is the same as the one described in https://github.com/matplotlib/matplotlib/pull/12928?

ImportanceOfBeingErnest commented 5 years ago

Yes, with current master, the warning reads

The glyph 176 of font D:/****/MiKTeX/fonts/type1/public/cm-super/sfss3583.pfb cannot be converted with the encoding; glyph may be wrong.
anntzer commented 5 years ago

The warning is actually spurious (per #14156), but the sizing problem is real.