October 23, 2024
Chicago 12, Melborne City, USA
pdf

Cannot save pdf files with matplotlib


I am using matplotlib to plot figures and save them as pdf files. I want to save the files at a location called .../output/figures/figure_1.pdf. When I try to save the figures, specifying the entire path as filename with fig.savefig(filename) I get the following error:

File ".../bin/analysis_final", line 871, in savee_products
    fig.savefig(filename)
  File ".../site-packages/matplotlib/figure.py", line 2311, in savefig
    self.canvas.print_figure(fname, **kwargs)
  File ".../site-packages/matplotlib/backend_bases.py", line 2210, in print_figure
    result = print_method(
  File ".../site-packages/matplotlib/backend_bases.py", line 1639, in wrapper
    return func(*args, **kwargs)
  File ".../site-packages/matplotlib/backends/backend_pdf.py", line 2593, in print_pdf
    self.figure.draw(renderer)
  File ".../site-packages/matplotlib/artist.py", line 41, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File ".../site-packages/matplotlib/figure.py", line 1863, in draw
    mimage._draw_list_compositing_images(
  File ".../site-packages/matplotlib/image.py", line 132, in _draw_list_compositing_images
    a.draw(renderer)
  File ".../site-packages/matplotlib/artist.py", line 41, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File ".../site-packages/matplotlib/cbook/deprecation.py", line 411, in wrapper
    return func(*inner_args, **inner_kwargs)
  File ".../site-packages/matplotlib/axes/_base.py", line 2748, in draw
    mimage._draw_list_compositing_images(renderer, self, artists)
  File ".../site-packages/matplotlib/image.py", line 132, in _draw_list_compositing_images
    a.draw(renderer)
  File ".../site-packages/matplotlib/artist.py", line 41, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File ".../site-packages/matplotlib/axis.py", line 1169, in draw
    tick.draw(renderer)
  File ".../site-packages/matplotlib/artist.py", line 41, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File ".../site-packages/matplotlib/axis.py", line 291, in draw
    artist.draw(renderer)
  File ".../site-packages/matplotlib/artist.py", line 41, in draw_wrapper
    return draw(artist, renderer, *args, **kwargs)
  File ".../site-packages/matplotlib/text.py", line 721, in draw
    textrenderer.draw_tex(gc, x, y, clean_line,
  File ".../site-packages/matplotlib/cbook/deprecation.py", line 411, in wrapper
    return func(*inner_args, **inner_kwargs)
  File ".../site-packages/matplotlib/backends/backend_pdf.py", line 2080, in draw_tex
    pdfname = self.file.dviFontName(dvifont)
  File ".../site-packages/matplotlib/backends/backend_pdf.py", line 778, in dviFontName
    tex_font_map = dviread.PsfontsMap(dviread.find_tex_file('pdftex.map'))
  File ".../site-packages/matplotlib/dviread.py", line 843, in __new__
    with open(filename, 'rb') as file:
FileNotFoundError: [Errno 2] No such file or directory: ''

This pdftex.map file is missing, I think, as suggested here. But where can I find a pdftex.map file? And where does it need to be saved to be found by matplotlib?



You need to sign in to view this answers

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video