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

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())
../_images/sphx_glr_plot_figure_001.png

From Matplotlib

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())
../_images/sphx_glr_plot_figure_002.png

From a gif

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

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

Module arguments

class beampy.figure(content, ext=None, **kwargs)

Include a figure to the current slide. Figure formats could be (svg, pdf, png, jpeg, gif, matplotib figure, and bokeh figure)

Parameters:
  • content (str or matplotlib.figure or bokeh.figure) – Figure input source. To load file, content is the path to the file. For matplotlib and bokeh, content is the python object figure of either matplotlib or bokeh.
  • ext ({'svg','jpeg','png','pdf', 'gif', 'bokeh','matplotlib'} or None, optional) – Image format defined as string (the default value is None, which implies that the image format is guessed from file or python object name.
  • x (int or float or {'center', 'auto'} or str, optional) – Horizontal position for the figure (the default is ‘center’).
  • y (int or float or {'center', 'auto'} or str, optional) – Vertical position for the figure (the default is ‘auto’, which implies equal blank width between ‘auto’ positioned elements)
  • width (int or float or None, optional) – Width of the figure (the default is None, which implies that the width is width of the image).

Gallery generated by Sphinx-Gallery