8000 Cannot savefig to stdout: TypeError: write() argument must be str, not bytes · Issue #18049 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content
Cannot savefig to stdout: TypeError: write() argument must be str, not bytes #18049
Closed
@iljah

Description

@iljah

As far as I can tell from documentation (matplotlib.org/3.2.2/api/_as_gen/matplotlib.pyplot.savefig.html), following should work:

#! /usr/bin/env python3
from sys import stdout
import matplotlib.pyplot as plot
plot.savefig(stdout, format = 'png')

but produces:

Traceback (most recent call last):
  File "./bug.py", line 4, in <module>
    plot.savefig(stdout, format = 'png')
  File "/usr/lib64/python3.8/site-packages/matplotlib/pyplot.py", line 723, in savefig
    res = fig.savefig(*args, **kwargs)
  File "/usr/lib64/python3.8/site-packages/matplotlib/figure.py", line 2203, in savefig
    self.canvas.print_figure(fname, **kwargs)
  File "/usr/lib64/python3.8/site-packages/matplotlib/backend_bases.py", line 2119, in print_figure
    result = print_method(
  File "/usr/lib64/python3.8/site-packages/matplotlib/backends/backend_agg.py", line 536, in print_png
    _png.write_png(renderer._renderer, fh, self.figure.dpi,
TypeError: write() argument must be str, not bytes

I'm using /usr/lib64/python3.8/site-packages/matplotlib-3.2.2-py3.8.egg-info from fedora 32. Same thing with at least format=pdf.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0