You are reading an old version of the documentation (v3.2.1). For the latest version see https://matplotlib.org/stable/gallery/misc/print_stdout_sgskip.html

John Hunter Excellence in Plotting Contest 2020 submissions are open! Entries are due June 1, 2020.

Version 3.2.1
matplotlib
Fork me on GitHub
  • Installation
  • Documentation
  • Examples
  • Tutorials
  • Contributing

Navigation

  • index
  • modules |
  • home| 
  • contents »

Related Topics

  • Documentation overview
Show Page Source

Note

Click here to download the full example code

Print StdoutΒΆ

print png to standard out

usage: python print_stdout.py > somefile.png

import sys
import matplotlib
matplotlib.use('Agg')
import matplotlib.pyplot as plt

plt.plot([1, 2, 3])
plt.savefig(sys.stdout.buffer)
Download Python source code: print_stdout_sgskip.py
Download Jupyter notebook: print_stdout_sgskip.ipynb

Keywords: matplotlib code example, codex, python plot, pyplot Gallery generated by Sphinx-Gallery

© Copyright 2002 - 2012 John Hunter, Darren Dale, Eric Firing, Michael Droettboom and the Matplotlib development team; 2012 - 2018 The Matplotlib development team.
Last updated on Apr 08, 2020. Created using Sphinx 3.0.0. Doc version v3.2.1-13-g7a9bc5ebb-dirty.