

.. _sphx_glr_gallery_misc_print_stdout_sgskip.py:


============
Print Stdout
============

print png to standard out

usage: python print_stdout.py > somefile.png




.. code-block:: python


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

    plt.plot([1, 2, 3])

    if sys.version_info[0] >= 3:
        plt.savefig(sys.stdout.buffer)
    else:
        plt.savefig(sys.stdout)

**Total running time of the script:** ( 0 minutes  0.000 seconds)



.. only :: html

 .. container:: sphx-glr-footer


  .. container:: sphx-glr-download

     :download:`Download Python source code: print_stdout_sgskip.py <print_stdout_sgskip.py>`



  .. container:: sphx-glr-download

     :download:`Download Jupyter notebook: print_stdout_sgskip.ipynb <print_stdout_sgskip.ipynb>`


.. only:: html

 .. rst-class:: sphx-glr-signature

    `Gallery generated by Sphinx-Gallery <https://sphinx-gallery.readthedocs.io>`_
