logo
  • Plot types
  • Examples
  • Tutorials
  • Reference
  • User guide
  • Develop
  • Release notes
  • 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
    • Changing colors of lines intersecting a box
    • Manual Contour
    • Coords Report
    • Custom projection
    • Customize Rc
    • AGG filter
    • Ribbon Box
    • Adding lines to figures
    • 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 Stdout
    • Rasterization for vector graphics
    • Set and get properties
    • SVG Filter 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

Note

Go to the end 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 Jupyter notebook: print_stdout_sgskip.ipynb

Download Python source code: print_stdout_sgskip.py

Gallery generated by Sphinx-Gallery

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

Created using Sphinx 7.3.7.