8000 [Bug]: Matplotlib not work with MiKTeX. · Issue #28212 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
[Bug]: Matplotlib not work with MiKTeX. #28212
Closed
@cesaryuan

Description

@cesaryuan

Bug summary

ax.xaxis.set_major_locator will let matplotlib throw a font not found error. But if we remove ax.xaxis.set_major_locator, the error disappears.

Code for reproduction

from matplotlib import ticker
import matplotlib.pyplot as plt

plt.rcParams['text.usetex'] = True
plt.rcParams['font.family'] = 'serif'
plt.rcParams['font.serif'] = 'Times'

fig, ax = plt.subplots()
ax.plot([1, 2, 3])

#!!!!! If we comment out the following line, the code will run without error
ax.xaxis.set_major_locator(ticker.LinearLocator(numticks=5))

fig.savefig('test.pdf')

Actual outcome

Throws error:

Traceback (most recent call last):
  File "e:\research\article\\bug.py", line 14, in <module>
    fig.savefig('test.pdf')
  File "E:\scoop\apps\miniconda3\current\envs\all\lib\site-packages\matplotlib\figure.py", line 3390, in savefig
    self.canvas.print_figure(fname, **kwargs)
  File "E:\scoop\apps\miniconda3\current\envs\all\lib\site-packages\matplotlib\backend_bases.py", line 2193, in print_figure
    result = print_method(
  File "E:\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 "E:\scoop\apps\miniconda3\current\envs\all\lib\site-packages\matplotlib\backends\backend_pdf.py", line 2807, in print_pdf
    self.figure.draw(renderer)
  File "E:\scoop\apps\miniconda3\current\envs\all\lib\site-packages\matplotlib\artist.py", line 95, in draw_wrapper
    result = draw(artist, renderer, *args, **kwargs)
  File "E:\scoop\apps\miniconda3\current\envs\all\lib\site-packages\matplotlib\artist.py", line 72, in draw_wrapper
    return draw(artist, renderer)
  File "E:\scoop\apps\miniconda3\current\envs\all\lib\site-packages\matplotlib\figure.py", line 3154, in draw
    mimage._draw_list_compositing_images(
  File "E:\scoop\apps\miniconda3\current\envs\all\lib\site-packages\matplotlib\image.py", line 132, in _draw_list_compositing_images
    a.draw(renderer)
  File "E:\scoop\apps\miniconda3\current\envs\all\lib\site-packages\matplotlib\artist.py", line 72, in draw_wrapper
    return draw(artist, renderer)
  File "E:\scoop\apps\miniconda3\current\envs\all\lib\site-packages\matplotlib\axes\_base.py", line 3070, in draw
    mimage._draw_list_compositing_images(
  File "E:\scoop\apps\miniconda3\current\envs\all\lib\site-packages\matplotlib\image.py", line 132, in _draw_list_compositing_images
    a.draw(renderer)
  File "E:\scoop\apps\miniconda3\current\envs\all\lib\site-packages\matplotlib\artist.py", line 72, in draw_wrapper
    return draw(artist, renderer)
  File "E:\scoop\apps\miniconda3\current\envs\all\lib\site-packages\matplotlib\axis.py", line 1391, in draw
    tick.draw(renderer)
  File "E:\scoop\apps\miniconda3\current\envs\all\lib\site-packages\matplotlib\artist.py", line 72, in draw_wrapper
    return draw(artist, renderer)
  File "E:\scoop\apps\miniconda3\current\envs\all\lib\site-packages\matplotlib\axis.py", line 295, in draw
    artist.draw(renderer)
  File "E:\scoop\apps\miniconda3\current\envs\all\lib\site-packages\matplotlib\artist.py", line 72, in draw_wrapper
    return draw(artist, renderer)
  File "E:\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 "E:\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 "E:\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 "E:\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 'E:/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

Expected outcome

No error.

Additional information

MiKTeX version

TeX is a trademark of the American Mathematical Society.
using bzip2 version 1.0.8, 13-Jul-2019
compiled with curl version 8.4.0; using libcurl/8.4.0 Schannel
compiled with expat version 2.5; using expat_2.5.0
compiled with jpeg version 9.5
compiled with liblzma version 50040002; using 50040002
compiled with libpng version 1.6.39; using 1.6.39
compiled with libressl version LibreSSL 3.8.1; using LibreSSL 3.8.1
compiled with MiKTeX Application Framework version 4.8; using 4.8
compiled with MiKTeX Core version 4.24; using 4.24
compiled with MiKTeX Archive Extractor version 4.1; using 4.1
compiled with MiKTeX Package Manager version 4.10; using 4.10
compiled with uriparser version 0.9.7
compiled with xpdf version 4.04
compiled with zlib version 1.2.13; using 1.2.13

Operating system

Windows

Matplotlib Version

3.8.4

Matplotlib Backend

TkAgg

Python version

Python 3.9.19

Jupyter version

No response

Installation

pip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0