Comments (6)
Thanks. I have repro'd the issue (you can also install miktex on mac/linux) and the fix is not obvious :/
from matplotlib.
- Do you get the same error with the following?
from matplotlib import ticker
import matplotlib.pyplot as plt
plt.rcParams['text.usetex'] = True
plt.rcParams['font.family'] = 'serif'
plt.rcParams['font.serif'] = 'Times'
plt.figtext(.5, .5, "$-1$")
fig.savefig('test.pdf')
- In either case, insert
plt.set_loglevel("debug")
immediately after setting the rcparams and re-run the failing code. In the output you should see lines of the formDEBUG:matplotlib.dviread:Dvi: /path/to/.matplotlib/tex.cache/bd/69/bd69c059493a3cf42a641ebfa844039e.dvi
(with a different filename). (If the code in 1) also fails for you it may be easier to use it as there will be fewer files to try.) For each such dvi file, try running from the terminal (not python)python -m matplotlib.dviread /path/to/the/dvifile.dvi
and post the output.
from matplotlib.
@anntzer Thanks so much for you reply.
-
Also get the same error.
-
original output
(all) PS D:\user\Desktop\matplotlib-bug> & D:/scoop/apps/miniconda3/current/envs/all/python.exe d:/user/Desktop/matplotlib-bug/bug.py
DEBUG:matplotlib.pyplot:Loaded backend tkagg version 8.6.
DEBUG:matplotlib.texmanager:family: serif, font: Times, info: \usepackage{mathptmx}
DEBUG:matplotlib.texmanager:DejaVu Sans font is not compatible with usetex.
DEBUG:matplotlib.texmanager:Bitstream Vera Sans font is not compatible with usetex.
DEBUG:matplotlib.texmanager:family: sans-serif, font: Computer Modern Sans Serif, info: \usepackage{type1ec}
DEBUG:matplotlib.texmanager:Apple Chancery font is not compatible with usetex.
DEBUG:matplotlib.texmanager:Textile font is not compatible with usetex.
DEBUG:matplotlib.texmanager:family: cursive, font: Zapf Chancery, info: \usepackage{chancery}
DEBUG:matplotlib.texmanager:DejaVu Sans Mono font is not compatible with usetex.
DEBUG:matplotlib.texmanager:Bitstream Vera Sans Mono font is not compatible with usetex.
DEBUG:matplotlib.texmanager:family: monospace, font: Computer Modern Typewriter, info: \usepackage{type1ec}
DEBUG:matplotlib.dviread:Dvi: C:\Users\cesar\.matplotlib\tex.cache\28\05\280592a6cb87d0a6f07f2be6c239ff4c.dvi
DEBUG:matplotlib.dviread:Dvi._xxx: encountered special: header=l3backend-dvips.pro
DEBUG:matplotlib.dviread:Dvi._xxx: encountered special: papersize=5203.43999pt,5203.43999pt
DEBUG:matplotlib.dviread:opening tfm file D:/scoop/apps/miktex/current/texmfs/install/fonts/tfm/adobe/times/ptmr7t.tfm
DEBUG:matplotlib.dviread:lh=18, bc=0, ec=170, nw=21, nh=16, nd=16
DEBUG:matplotlib.dviread:Dvi: D:/scoop/apps/miktex/current/texmfs/install/fonts/vf/adobe/times/ptmr7t.vf
DEBUG:matplotlib.dviread:opening tfm file D:/scoop/apps/miktex/current/texmfs/install/fonts/tfm/adobe/times/ptmr8r.tfm
DEBUG:matplotlib.dviread:lh=18, bc=1, ec=255, nw=34, nh=16, nd=16
DEBUG:matplotlib.dviread:Dvi._xxx: encountered special: Warning: missing glyph `Gamma'
DEBUG:matplotlib.dviread:Dvi._xxx: encountered special: Warning: missing glyph `Delta'
DEBUG:matplotlib.dviread:Dvi._xxx: encountered special: Warning: missing glyph `Theta'
DEBUG:matplotlib.dviread:Dvi._xxx: encountered special: Warning: missing glyph `Lambda'
DEBUG:matplotlib.dviread:Dvi._xxx: encountered special: Warning: missing glyph `Xi'
DEBUG:matplotlib.dviread:Dvi._xxx: encountered special: Warning: missing glyph `Pi'
DEBUG:matplotlib.dviread:Dvi._xxx: encountered special: Warning: missing glyph `Sigma'
DEBUG:matplotlib.dviread:Dvi._xxx: encountered special: Warning: missing glyph `Upsilon'
DEBUG:matplotlib.dviread:Dvi._xxx: encountered special: Warning: missing glyph `Phi'
DEBUG:matplotlib.dviread:Dvi._xxx: encountered special: Warning: missing glyph `Psi'
DEBUG:matplotlib.dviread:Dvi._xxx: encountered special: Warning: missing glyph `Omega'
DEBUG:matplotlib.dviread:Dvi._xxx: encountered special: Warning: missing glyph `dotlessj'
DEBUG:matplotlib.dviread:Dvi._xxx: encountered special: Warning: missing glyph `lslashslash'
DEBUG:matplotlib.texmanager:family: serif, font: Times, info: \usepackage{mathptmx}
DEBUG:matplotlib.texmanager:DejaVu Sans font is not compatible with usetex.
DEBUG:matplotlib.texmanager:Bitstream Vera Sans font is not compatible with usetex.
DEBUG:matplotlib.texmanager:family: sans-serif, font: Computer Modern Sans Serif, info: \usepackage{type1ec}
DEBUG:matplotlib.texmanager:Apple Chancery font is not compatible with usetex.
DEBUG:matplotlib.texmanager:Textile font is not compatible with usetex.
DEBUG:matplotlib.texmanager:family: cursive, font: Zapf Chancery, info: \usepackage{chancery}
DEBUG:matplotlib.texmanager:DejaVu Sans Mono font is not compatible with usetex.
DEBUG:matplotlib.texmanager:Bitstream Vera Sans Mono font is not compatible with usetex.
DEBUG:matplotlib.texmanager:family: monospace, font: Computer Modern Typewriter, info: \usepackage{type1ec}
DEBUG:matplotlib.dviread:Dvi: C:\Users\cesar\.matplotlib\tex.cache\af\1f\af1f4e0a95d1cb3284108346197a266e.dvi
DEBUG:matplotlib.dviread:Dvi._xxx: encountered special: header=l3backend-dvips.pro
DEBUG:matplotlib.dviread:Dvi._xxx: encountered special: papersize=5203.43999pt,5203.43999pt
DEBUG:matplotlib.dviread:opening tfm file D:/scoop/apps/miktex/current/texmfs/install/fonts/tfm/adobe/times/zptmcm7y.tfm
DEBUG:matplotlib.dviread:lh=18, bc=0, ec=127, nw=45, nh=16, nd=16
DEBUG:matplotlib.dviread:Dvi: D:/scoop/apps/miktex/current/texmfs/install/fonts/vf/adobe/times/zptmcm7y.vf
DEBUG:matplotlib.dviread:opening tfm file D:/scoop/apps/miktex/current/texmfs/install/fonts/tfm/public/cm/cmsy10.tfm
DEBUG:matplotlib.dviread:lh=18, bc=0, ec=127, nw=44, nh=15, nd=16
DEBUG:matplotlib.dviread:opening tfm file D:/scoop/apps/miktex/current/texmfs/install/fonts/tfm/adobe/symbol/psyr.tfm
DEBUG:matplotlib.dviread:lh=17, bc=32, ec=254, nw=52, nh=16, nd=16
DEBUG:matplotlib.dviread:opening tfm file D:/scoop/apps/miktex/current/texmfs/install/fonts/tfm/adobe/times/zptmcm7t.tfm
DEBUG:matplotlib.dviread:lh=18, bc=0, ec=170, nw=33, nh=16, nd=16
DEBUG:matplotlib.dviread:Dvi: D:/scoop/apps/miktex/current/texmfs/install/fonts/vf/adobe/times/zptmcm7t.vf
DEBUG:matplotlib.dviread:opening tfm file D:/scoop/apps/miktex/current/texmfs/install/fonts/tfm/public/cm/cmr10.tfm
DEBUG:matplotlib.dviread:lh=18, bc=0, ec=127, nw=36, nh=16, nd=10
DEBUG:matplotlib.dviread:Dvi._xxx: encountered special: Warning: missing glyph `dotlessj'
DEBUG:matplotlib.dviread:Dvi._xxx: encountered special: Warning: missing glyph `lslashslash'
DEBUG:matplotlib.texmanager:family: serif, font: Times, info: \usepackage{mathptmx}
DEBUG:matplotlib.texmanager:DejaVu Sans font is not compatible with usetex.
DEBUG:matplotlib.texmanager:Bitstream Vera Sans font is not compatible with usetex.
DEBUG:matplotlib.texmanager:family: sans-serif, font: Computer Modern Sans Serif, info: \usepackage{type1ec}
DEBUG:matplotlib.texmanager:Apple Chancery font is not compatible with usetex.
DEBUG:matplotlib.texmanager:Textile font is not compatible with usetex.
DEBUG:matplotlib.texmanager:family: cursive, font: Zapf Chancery, info: \usepackage{chancery}
DEBUG:matplotlib.texmanager:DejaVu Sans Mono font is not compatible with usetex.
DEBUG:matplotlib.texmanager:Bitstream Vera Sans Mono font is not compatible with usetex.
DEBUG:matplotlib.texmanager:family: monospace, font: Computer Modern Typewriter, info: \usepackage{type1ec}
DEBUG:matplotlib.dviread:Dvi: C:\Users\cesar\.matplotlib\tex.cache\af\1f\af1f4e0a95d1cb3284108346197a266e.dvi
DEBUG:matplotlib.dviread:Dvi._xxx: encountered special: header=l3backend-dvips.pro
DEBUG:matplotlib.dviread:Dvi._xxx: encountered special: papersize=5203.43999pt,5203.43999pt
DEBUG:matplotlib.dviread:Dvi: D:/scoop/apps/miktex/current/texmfs/install/fonts/vf/adobe/times/zptmcm7y.vf
Traceback (most recent call last):
File "d:\user\Desktop\matplotlib-bug\bug.py", line 10, in <module>
plt.savefig('test.pdf')
File "D:\scoop\apps\miniconda3\current\envs\all\lib\site-packages\matplotlib\pyplot.py", line 1134, in savefig
res = fig.savefig(*args, **kwargs) # type: ignore[func-returns-value]
File "D:\scoop\apps\miniconda3\current\envs\all\lib\site-packages\matplotlib\figure.py", line 3390, in savefig
self.canvas.print_figure(fname, **kwargs)
File "D:\scoop\apps\miniconda3\current\envs\all\lib\site-packages\matplotlib\backend_bases.py", line 2193, in print_figure
result = print_method(
File "D:\scoop\apps\miniconda3\current\envs\all\lib\site-packages\matplotlib\backend_bases.py", line 2043, in <lambda>
print_method = functools.wraps(meth)(lambda *args, **kwargs: meth(
File "D:\scoop\apps\miniconda3\current\envs\all\lib\site-packages\matplotlib\backends\backend_pdf.py", line 2807, in print_pdf
self.figure.draw(renderer)
File "D:\scoop\apps\miniconda3\current\envs\all\lib\site-packages\matplotlib\artist.py", line 95, in draw_wrapper
result = draw(artist, renderer, *args, **kwargs)
File "D:\scoop\apps\miniconda3\current\envs\all\lib\site-packages\matplotlib\artist.py", line 72, in draw_wrapper
return draw(artist, renderer)
File "D:\scoop\apps\miniconda3\current\envs\all\lib\site-packages\matplotlib\figure.py", line 3154, in draw
mimage._draw_list_compositing_images(
File "D:\scoop\apps\miniconda3\current\envs\all\lib\site-packages\matplotlib\image.py", line 132, in _draw_list_compositing_images
a.draw(renderer)
File "D:\scoop\apps\miniconda3\current\envs\all\lib\site-packages\matplotlib\artist.py", line 72, in draw_wrapper
return draw(artist, renderer)
File "D:\scoop\apps\miniconda3\current\envs\all\lib\site-packages\matplotlib\text.py", line 793, in draw
textrenderer.draw_tex(gc, x, y, clean_line,
File "D:\scoop\apps\miniconda3\current\envs\all\lib\site-packages\matplotlib\backends\backend_pdf.py", line 2267, in draw_tex
pdfname = self.file.dviFontName(dvifont)
File "D:\scoop\apps\miniconda3\current\envs\all\lib\site-packages\matplotlib\backends\backend_pdf.py", line 938, in dviFontName
psfont = tex_font_map[dvifont.texname]
File "D:\scoop\apps\miniconda3\current\envs\all\lib\site-packages\matplotlib\dviread.py", line 905, in __getitem__
raise LookupError(
LookupError: An associated PostScript font (required by Matplotlib) could not be found for TeX font 'zptmcm7y' in 'D:/scoop/apps/miktex/current/texmfs/data/fonts/map/pdftex/pdftex.map'; this problem can often be solved by installing a suitable PostScript font package in your TeX package manager
matplotlib.dviread output:
(all) PS D:\user\Desktop\matplotlib-bug> python -m matplotlib.dviread C:\Users\cesar\.matplotlib\tex.cache\28\05\280592a6cb87d0a6f07f2be6c239ff4c.dvi
=== new page === (w: 509863, h: 444328, d: 141880)
font: 'ptmr8r' scale: 0.625
x y glyph chr w (glyphs)
983040 1441792 108 l 182183
1165223 1441792 112 p 327680
(all) PS D:\user\Desktop\matplotlib-bug> python -m matplotlib.dviread C:\Users\cesar\.matplotlib\tex.cache\af\1f\af1f4e0a95d1cb3284108346197a266e.dvi
=== new page === (w: 836888, h: 444328, d: 54392)
font: 'zptmcm7y' scale: 0.625
x y glyph chr w (glyphs)
983040 1441792 0 . 509208
font: 'ptmr8r' scale: 0.625
x y glyph chr w (glyphs)
1492248 1441792 49 1 327680
from matplotlib.
Updates: I created a pure Windows 11 virtual machine. And install MiKTeX and Miniconda 3 from scratch. The bug can still be reproduced.
Then, I tried TexLive, and it works. So the bug is that MiKTeX does not work well with Matplotlib?
from matplotlib.
Possibly, though we should still try to fix that! I suspect this may be due to misconfiguration on your side (so perhaps the fix would be a better error message), but will need to investigate more (likely not in the very short term).
from matplotlib.
I suspect this may be due to misconfiguration on your side.
For this, I created a virtual machine with VMware (to control variables, I'm even using the English Windows version instead of the locale one I'm on). Install MiKTex and Python with its official installer.
VMware reproduce steps:
- create Window 11 vm by its iso: https://software.download.prss.microsoft.com/dbazure/Win11_23H2_English_x64v2.iso
- install Python: https://www.python.org/downloads/release/python-3119/
- install MiKTeX: https://miktex.org/download
- check miktex updates and install updates
- pip install matplotlib
- python bug.py
from matplotlib import ticker
import matplotlib.pyplot as plt
plt.rcParams['text.usetex'] = True
plt.rcParams['font.family'] = 'serif'
plt.rcParams['font.serif'] = 'Times'
# plt.set_loglevel("debug")
plt.figtext(.5, .5, "$-1$")
plt.savefig('test.pdf')
I compare the dvi file generated by texlive and miktex. Here is the result:
MiKTeX: (another thing to be noted is I can compile to pdf successfully by MiKTeX.)
=== new page === (w: 836888, h: 444328, d: 54392)
font: 'zptmcm7y' scale: 0.625
x y glyph chr w (glyphs)
983040 1441792 0 . 509208
font: 'ptmr8r' scale: 0.625
x y glyph chr w (glyphs)
1492248 1441792 49 1 327680
TeXLive:
=== new page === (w: 836888, h: 444328, d: 0)
font: 'cmsy10' scale: 0.625
x y glyph chr w (glyphs)
983040 1441792 0 . 509726
font: 'ptmr8r' scale: 0.625
x y glyph chr w (glyphs)
1492248 1441792 49 1 327680
from matplotlib.
Related Issues (20)
- [ENH]: matplotlib.widgets.PolygonSelector widget initial cursor position at data rather than (0,0) HOT 7
- [Doc]: drawedges attribute described twice in matplotlib.colorbar documentation HOT 5
- [ENH]: Add TypedDict (like) type hints to rcParams HOT 3
- [Bug]: Inconsistent Visualization of Intervals in ax.barh for Different Duration Widths HOT 2
- [Bug]: `set_text` does not work when accessed from `axis.get_xticklabels` HOT 2
- [ENH]: More accurate type stub for `plt.subplots` like VSCode did before. HOT 1
- [ENH]: Band and Sankey Diagramm HOT 2
- [Bug]: constant valued line plot has strange/unexpected y-axis HOT 13
- [Bug]: mpltype custom role breaks sphinx build for third-party projects that have intersphinx links to matplotlib HOT 8
- [Bug]: ImportError: /home/travis/miniconda/envs/env/lib/python3.11/lib-dynload/pyexpat.cpython-311-x86_64-linux-gnu.so: undefined symbol: XML_SetReparseDeferralEnabled HOT 6
- [Doc]: Gallery example showing 3D slice planes HOT 5
- Mathplt HOT 1
- [ENH]: Color along line by a value HOT 8
- [ENH]: Request for linestyle='.' and linestyle='.-' in plt.plot HOT 1
- [Doc]: Tutorial how to write custom wrapper functions HOT 2
- font finding in OSX produces 200+ lines of warnings HOT 5
- [Doc]: Sphinx gallery links mispointed for Axes3D methods HOT 3
- [Bug]: axes3d.py's _on_move() converts the roll angle to radians, but then passes it to view_init() as if it were still in degrees
- [Bug]: Animation was deleted without rendering anything HOT 1
- [ENH]: Reusing the same GUI window for showing multiple figures HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from matplotlib.