.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/plotting/export.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_gallery_plotting_export.py: Plot a scaled Image =================== Demonstrates rendering a canvas to an image at higher resolution than the original display. NOTE: This example is currently broken. .. GENERATED FROM PYTHON SOURCE LINES 15-39 .. image-sg:: /gallery/plotting/images/sphx_glr_export_001.png :alt: export :srcset: /gallery/plotting/images/sphx_glr_export_001.png :class: sphx-glr-single-img .. code-block:: Python import vispy.plot as vp # Create a canvas showing plot data fig = vp.Fig() fig[0, 0].plot([1, 6, 2, 4, 3, 8, 5, 7, 6, 3]) # Render the canvas scene to a numpy array image with higher resolution # than the original canvas scale = 4 image = fig.render(size=(fig.size[0]*scale, fig.size[1]*scale)) # Display the data in the array, sub-sampled down to the original canvas # resolution fig_2 = vp.Fig() fig_2[0, 0].image(image[::-scale, ::scale]) # By default, the view adds some padding when setting its range. # We'll remove that padding so the image looks exactly like the original # canvas: fig_2[0, 0].camera.set_range(margin=0) if __name__ == '__main__': fig.app.run() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.534 seconds) .. _sphx_glr_download_gallery_plotting_export.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: export.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: export.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: export.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_