.. _sphx_glr_auto_examples_plot_figure.py: figure ====== Insert a figure inside a slide. Figure format can be: * pdf * svg * jpeg * png * gif * Matplotlib figure object * Bokeh figure object From one file ------------- .. code-block:: python from beampy import * # Remove quiet=True to get beampy compilation outputs doc = document(quiet=True) with slide('A figure from a file'): figure('./ressources/test_0.svg', width=400) display_matplotlib(gcs()) .. image:: /auto_examples/images/sphx_glr_plot_figure_001.png :align: center From Matplotlib --------------- .. code-block:: python with slide('A matplotlib figure'): import matplotlib.pyplot as mpl import numpy as np f = mpl.figure() mpl.plot(np.random.rand(100), np.random.rand(100), 'o') figure(f, width=500) display_matplotlib(gcs()) .. image:: /auto_examples/images/sphx_glr_plot_figure_002.png :align: center From a gif ---------- .. code-block:: python with slide('An animated gif'): figure('../../tests/test.gif', width='50%') From Bokeh ---------- .. note:: No svg export available for now, check the html file of the prensetation .. code-block:: python with slide('A bokeh figure'): from bokeh.plotting import figure as bokfig p = bokfig(height=300, width=600) x = np.random.rand(100) y = np.random.rand(100) p.circle(x, y, legend="sin(x)") figure(p) # Export the 3 slides of the presentation save('./examples_html_outputs/figure.html') HTML output =========== .. raw:: html Module arguments ================ .. autoclass:: beampy.figure :noindex: .. only :: html .. container:: sphx-glr-footer .. container:: sphx-glr-download :download:`Download Python source code: plot_figure.py ` .. container:: sphx-glr-download :download:`Download Jupyter notebook: plot_figure.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_