Skip to main content
Ctrl+K
You are reading documentation for the unreleased version of Matplotlib. Try searching for the released version of this page instead?
Matplotlib 3.10.1+dfsg1 documentation - Home Matplotlib 3.10.1+dfsg1 documentation - Home
  • Plot types
  • User guide
  • Tutorials
  • Examples
  • Reference
  • Contribute
  • Releases
  • Gitter
  • Discourse
  • GitHub
  • Twitter
  • Plot types
  • User guide
  • Tutorials
  • Examples
  • Reference
  • Contribute
  • Releases
  • Gitter
  • Discourse
  • GitHub
  • Twitter

Section Navigation

  • Lines, bars and markers
  • Images, contours and fields
  • Subplots, axes and figures
  • Statistics
  • Pie and polar charts
  • Text, labels and annotations
  • Color
  • Shapes and collections
  • Style sheets
  • Module - pyplot
  • Module - axes_grid1
  • Module - axisartist
  • Showcase
  • Animation
  • Event handling
  • Miscellaneous
    • Anchored Artists
    • Identify whether artists intersect
    • Manual Contour
    • Coords Report
    • Custom projection
    • Customize Rc
    • AGG filter
    • Ribbon box
    • Add lines directly to a figure
    • Fill spiral
    • Findobj Demo
    • Font indexing
    • Font properties
    • Building histograms using Rectangles and PolyCollections
    • Hyperlinks
    • Image thumbnail
    • Plotting with keywords
    • Matplotlib logo
    • Multipage PDF
    • Multiprocessing
    • Packed-bubble chart
    • Patheffect Demo
    • Print image to stdout
    • Rasterization for vector graphics
    • Set and get properties
    • Apply SVG filter to a line
    • SVG filter pie
    • Table Demo
    • TickedStroke patheffect
    • transforms.offset_copy
    • Zorder Demo
  • 3D plotting
  • Scales
  • Specialty plots
  • Spines
  • Ticks
  • Units
  • Embedding Matplotlib in graphical user interfaces
  • Widgets
  • Userdemo
  • Examples
  • Miscellaneous
  • Print image to stdout

Note

Go to the end to download the full example code.

Print image to 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 Jupyter notebook: print_stdout_sgskip.ipynb

Download Python source code: print_stdout_sgskip.py

Download zipped: print_stdout_sgskip.zip

Gallery generated by Sphinx-Gallery

© Copyright 2002–2012 John Hunter, Darren Dale, Eric Firing, Michael Droettboom and the Matplotlib development team; 2012–2025 The Matplotlib development team.

Created using Sphinx 8.1.3.

Built from 3.10.1+dfsg1.

Built with the PyData Sphinx Theme 0.16.1.