Skip to content

PNG output with PGF backend fails with pdftocairo exit code 99 #8121

Closed

Description

@narpfel

Bug report

Bug summary

When the PGF backend is selected, saving figures to a PNG image does not work because invoking pdftocairo fails with exit code 99. Saving to a PDF file and then invoking pdftocairo with the same arguments works.

Code for reproduction

# plot_to_png.py
import matplotlib as mpl
mpl.use("pgf")
from matplotlib import pyplot as plt

plt.plot([1, 2, 3], [4, 5, 6])
plt.savefig("test.png")

Executing this leads to

me@home:/tmp/mpl » python plot_to_png.py 
Traceback (most recent call last):
  File "plot_to_png.py", line 6, in <module>
    plt.savefig("test.png")
  File "/usr/lib/python3.6/site-packages/matplotlib/pyplot.py", line 697, in savefig
    res = fig.savefig(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/matplotlib/figure.py", line 1572, in savefig
    self.canvas.print_figure(*args, **kwargs)
  File "/usr/lib/python3.6/site-packages/matplotlib/backend_bases.py", line 2244, in print_figure
    **kwargs)
  File "/usr/lib/python3.6/site-packages/matplotlib/backends/backend_pgf.py", line 961, in print_png
    self._print_png_to_fh(fh, *args, **kwargs)
  File "/usr/lib/python3.6/site-packages/matplotlib/backends/backend_pgf.py", line 941, in _print_png_to_fh
    converter(fname_pdf, fname_png, dpi=self.figure.dpi)
  File "/usr/lib/python3.6/site-packages/matplotlib/backends/backend_pgf.py", line 197, in cairo_convert
    check_output(cmd, shell=True, stderr=subprocess.STDOUT)
  File "/usr/lib/python3.6/subprocess.py", line 336, in check_output
    **kwargs).stdout
  File "/usr/lib/python3.6/subprocess.py", line 418, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['pdftocairo', '-singlefile', '-png', '-r 100', '/tmp/mpl_pgf_klhh_fnt/figure.pdf', '/tmp/mpl_pgf_klhh_fnt/figure']' returned non-zero exit status 99.
me@home:/tmp/mpl » 

Expected outcome

This should produce a PNG file of a linear graph.

Saving to a PDF file and then calling pdftocairo works:

# plot_to_pdf.py
import matplotlib as mpl
mpl.use("pgf")
from matplotlib import pyplot as plt

plt.plot([1, 2, 3], [4, 5, 6])
plt.savefig("test.pdf")
me@home:/tmp/mpl » python plot_to_pdf.py 
me@home:/tmp/mpl » pdftocairo -singlefile -png -r 100 /tmp/mpl/test.pdf /tmp/mpl/test
me@home:/tmp/mpl » echo $?
0
me@home:/tmp/mpl » 

Used program versions

  • Arch Linux
  • Python 3.6.0 (default, Jan 16 2017, 12:12:55) 
    [GCC 6.3.1 20170109] on linux
    
    from the Arch repo
  • Matplotlib version 2.0.0, also installed from Arch repo
  • pdftocairo version 0.52.0, also from Arch repo (package is named poppler)

Prior to updating to Matplotlib 2.0.0 (from 1.5.3) and pdftocairo 0.52.0 (from 0.51.0), this worked.

Activity

  1. added this to the milestone on Feb 22, 2017
  2. added
    Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
    on Feb 22, 2017
  3. QuLogic commented on Feb 22, 2017

    @QuLogic
    Member

    Worked in 1.5.3, so marking critical; also because I've got a fix already written...

  4. added a commit that references this issue on Feb 22, 2017
    c0d5a14
  5. dstansby commented on Feb 24, 2017

    @dstansby
    Member

    This is fixed in 2.0.x

  6. added a commit that references this issue on Mar 18, 2017
    76e3693
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.backend: pgf

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions