PK NnG plot_tikz.py"""
tikz
====
Add pgf/tikz drawing to the slide.
You could find great examples here http://www.texample.net/tikz/examples/
"""
from beampy import *
# Remove quiet=True to get beampy compilation outputs
doc = document(quiet=True)
latex_cmd = r"\newcounter{density}\setcounter{density}{10}"
tex_packages = ['ifthen']
with slide('A tikz figure'):
tikz(r"""
\def\couleur{SeaGreen}
\path[coordinate] (0,0) coordinate(A)
++( 60:12cm) coordinate(B)
++(-60:12cm) coordinate(C);
\draw[fill=\couleur!\thedensity] (A) -- (B) -- (C) -- cycle;
\foreach \x in {1,...,15}{%
\pgfmathsetcounter{density}{\thedensity+10}
\setcounter{density}{\thedensity}
\path[coordinate] coordinate(X) at (A){};
\path[coordinate] (A) -- (B) coordinate[pos=.15](A)
-- (C) coordinate[pos=.15](B)
-- (X) coordinate[pos=.15](C);
\draw[fill=\couleur!\thedensity] (A)--(B)--(C)--cycle;
}
""", latex_pre_tikzpicture=latex_cmd,
tex_packages=tex_packages,
x='center', y='center')
display_matplotlib(gcs())
#########################################################################
#
#Module arguments
#================
#
#.. autoclass:: beampy.tikz
# :noindex:
#
PK Nea a plot_itemize.py"""
itemize
=======
Create a list or an enumeration of items from an input python list of strings.
"""
from beampy import *
# Remove quiet=True to get Beampy render outputs
doc = document(quiet=True)
with slide('Itemize'):
itemize(['''This is a long text inside an item.
It will crop at the given itemize width''',
r'$\sqrt{1+10} \times \frac{x}{y}$',
'tata'],
width=400
)
display_matplotlib(gcs())
####################################################
#
#Module arguments
#================
#
#.. autofunction:: beampy.itemize
# :noindex:
#
PK Nkl plot_code.py"""
code
====
Include code in your presentation.
Code coloration is managed by `Pygments `_
.. warning::
This module is in very draft stage !!!
"""
from beampy import *
# Remove quiet=True to get beampy compilation outputs
doc = document(quiet=True)
with slide('A small python code'):
c = code("""
from pylab import *
n = range(10)
plot(n, n*random.rand(), 'ko')
for i in range(10):
print(i)
""", width=500)
display_matplotlib(gcs())
###########################################################
#Module arguments
#================
#
#.. autoclass:: beampy.code
# :noindex:
#
PK N@@ plot_line.py"""
line
====
Easiest way to create lines in svg rather than using the :py:mod:beampy.svg.
"""
from beampy import *
# Remove quiet=True to get Beampy render outputs
doc = document(quiet=True)
with slide('Svg: Line'):
line(800-20, 600-50, x=20, y=50, color='red')
hline(300, color='orange', linewidth='4px')
vline(400, color='crimson', linewidth='10px', opacity=0.5)
display_matplotlib(gcs())
####################################################
#
#Module arguments
#================
#
#.. autoclass:: beampy.line
# :noindex:
#
#.. autofunction:: beampy.hline
# :noindex:
#
#.. autofunction:: beampy.vline
# :noindex:
#
PK NU-L L plot_grid.py"""
grid
====
Easiest way to create grid in svg rather than using the :py:mod:beampy.svg
.. note::
This function is not yet optimised creating a grid loop over hline and vline resulting
in a slow compilation time.
"""
from beampy import *
# Remove quiet=True to get Beampy render outputs
doc = document(quiet=True)
with slide('Svg: grid'):
grid(25, 25, color='gray')
grid(100, 100, color='crimson')
display_matplotlib(gcs())
####################################################
#
#Module arguments
#================
#
#.. autofunction:: beampy.grid
# :noindex:
#
PK NHjŊ
plot_group.py"""
group
=====
Group Beampy modules to place them easily.
Grouping modules allows to create complex layout in your slide.
"""
from beampy import *
# Remove quiet=True to get Beampy render outputs
doc = document(quiet=True)
with slide('Grouping elements'):
# Using with statement:
with group(y=0.1, background='lightblue', width='90%') as g1:
text("I'm inside the first group", y=0)
text('Me too!', y="+0.1")
# Create two groups (g2 and g4) aligned on top
# and with automatic horizontal position
with group(x='auto', y=0.3, width=400, height=200, background='lightgreen') as g2:
text('At the group center', x='center', y='center')
# Add child group to the parent group
with group(width='50%', background='red', x=g2.left+0, y=g2.bottom+bottom(0)) as g3:
text('A group in a group')
with group(width='50%', background='violet', x=g3.right+0, y=g3.top+0) as g3:
text('A group in a group')
with group(x='auto', y=g2.top+0, height=300, width=300) as g4:
text('''A last group with a bigger height and a lower width.
The text inside this group has the group width!''')
# Add a border to the last group
g4.add_border()
display_matplotlib(gcs())
###################################################
#
#Module arguments
#================
#
#.. autoclass:: beampy.group
# :noindex:
PK N[4; ;
plot_arrow.py"""
arrow
=====
Add arrow to slide. Arrow are drawn using tikz.
"""
from beampy import *
# Remove quiet=True to get beampy compilation outputs
doc = document(quiet=True)
with slide('Draw an arrow'):
arrow(x=10, y=0.1, dx=780, dy=0, lw=6, color='Crimson')
rectangle(x=0.05, y=0.3, width=150, height=150,
color='crimson', edgecolor='None')
t1 = text('First', y=0.25, x=0.55)
a1 = arrow(x=t1.right+0, y=t1.bottom+0, dx=100, dy=100)
t2 = text('Second', y=a1.bottom+0, x=a1.right+0)
a2 = arrow(x=t2.center+0, y=t2.bottom+0, dx=-100, dy=150, color='red',
style='<->', bend='left', head_style='latex', lw=4)
t3 = text('Third', y=a2.bottom+bottom(0), x=a2.left+right(0))
a3 = arrow(x=t3.left+0, y=t3.center+0, dx=-350, dy=-170,
color='LightGreen', lw=5, out_angle=180, in_angle=0,
dashed=True)
display_matplotlib(gcs())
###############################################################################
#
#Module arguments
#================
#
#.. autofunction:: beampy.arrow
# :noindex:
#
PK Nwv v plot_box.py"""
box
===
Create a boxed group, that could have a title.
"""
from beampy import *
# Remove quiet=True to get Beampy render outputs
doc = document(quiet=True)
with slide('Add nice boxes to group'):
with box(x=20, y='center', width=300, height='60%', title='Very very very long box title') as b1:
text('Box text')
with box(x=b1.right+10, y=b1.top+0, width=450,
title='Change color and drop-shadow', title_align='center',
color='crimson', shadow=True) as b2:
text('Box text, with a centered title, and a nice crimson color', width='90%')
with box(x=b1.right+10, y=b2.bottom+50, width=b2.width, color='darkorange',
rounded=70, background_color='lightgray', linewidth=4, auto_height_margin=30) as b3:
text('''
Without title for the box, more rounded angle, bigger
linewidth, and a background color
''', align='center', width='90%')
display_matplotlib(gcs())
###################################################
#
#Module arguments
#================
#
#.. autoclass:: beampy.box
# :noindex:
PK NUHc plot_TOC.py"""
table of contents
=================
Create a table of content for your presentation.
To create the structure of your presentation you could use the following function:
- section('Section title')
- subsection('Subsection title')
- subsubsection('Subsubsection title')
"""
from beampy import *
# Remove quiet=True to get Beampy render outputs
doc = document(quiet=True)
section('Introduction')
with slide('Table of content'):
tableofcontents()
section('The main topic')
subsection('Argument 1')
with slide('Display only the current section'):
tableofcontents(currentsection=True)
subsubsection('Demonstration 1')
with slide('Current subsection'):
tableofcontents(currentsubsection=True)
subsection('Argument 2')
subsubsection('Demonstration 1')
subsubsection('Demonstration 2')
section('Conclusion')
with slide('Two columns table of contents'):
with group(width='45%', x='auto', y='center') as t1:
tableofcontents(x=0, y=0, sections=[1, 2],
section_style='square',
subsection_style='round')
with group(width=t1.width, x='auto', y=t1.top+0) as t2:
tableofcontents(x=0, y=0, sections=3,
section_style='square')
t1.add_border()
t2.add_border()
display_matplotlib('slide_0')
save('./examples_html_outputs/toc.html')
###############################################################
#
#HTML output
#===========
#
#.. raw:: html
#
#
#
#Module arguments
#================
#
#.. autoclass:: beampy.tableofcontents
# :noindex:
PK NĆ 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
-------------
"""
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())
########################################################
#
#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())
########################################################
#
#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
#===========
#
#.. raw:: html
#
#
#
#
#Module arguments
#================
#
#.. autoclass:: beampy.figure
# :noindex:
#
PK N+}u plot_svg.py"""
svg
===
Create graphical elements using svg syntax.
To make svg writing easier, shortcuts module have been created to draw (line,
rectangle, grid)
"""
from beampy import *
# Remove quiet=True to get Beampy render outputs
doc = document(quiet=True)
with slide('Svg'):
svg('', y='center')
svg(""" """, x='center', y='center')
display_matplotlib(gcs())
####################################################
#
#Module arguments
#================
#
#.. autoclass:: beampy.svg
# :noindex:
#
PK N+ه
plot_title.py"""
maketitle
=========
Create a title slide for the presentation.
:py:mod:`maketitle` could be overwritten by the theme used for the prensentation
"""
from beampy import *
# Remove quiet=True to get Beampy render outputs
doc = document(quiet=True)
with slide():
maketitle('Beampy a tool to make simple presentation',
author='H. Chauvet',
subtitle='Written in Python',
date='now')
display_matplotlib(gcs())
######################################################################################
#
#Module arguments
#================
#
#.. autofunction:: beampy.maketitle
# :noindex:
PK N.- - plot_rectangle.py"""
rectangle
=========
Easiest way to create rectangle in svg rather than using the
:py:mod:beampy.svg.
"""
from beampy import *
# Remove quiet=True to get Beampy render outputs
doc = document(quiet=True)
with slide('Svg: rectangle'):
rectangle(width=300, height=300, y='center')
rectangle(width=100, height=100, color='yellow', y='center',
edgecolor='red')
display_matplotlib(gcs())
####################################################
#
#Module arguments
#================
#
#.. autoclass:: beampy.rectangle
# :noindex:
#
PK N=\ \
plot_video.py"""
video
=====
Add video to your slide.
"""
from beampy import *
# Remove quiet=True to get beampy compilation outputs
doc = document(quiet=True)
with slide('Video module'):
video('./ressources/test.webm', still_image_time=5.5)
display_matplotlib(gcs())
save('./examples_html_outputs/video.html')
##########################################################
#
#HTML output
#===========
#
#.. raw:: html
#
#
#
#
#Module arguments
#================
#
#.. autoclass:: beampy.video
# :noindex:
#
PK Nz` plot_text.py"""
text
====
Add text to your slide.
By default text is processed by Latex and accept Latex syntax.
"""
from beampy import *
# Remove quiet=True to get beampy compilation outputs
doc = document(quiet=True)
with slide('Text module'):
text(r'A simple text with \LaTeX syntax so you could write equation:')
text(r'$$\sqrt{\frac{x}{y}}$$')
t = text(r'You could align text to center by using the \textbf{align} parameter',
align='center', width=350)
# add border to the text to see the effect of center alignment
t.add_border()
display_matplotlib(gcs())
##########################################################
#
#Module arguments
#================
#
#.. autoclass:: beampy.text
# :noindex:
#
PK Nj plot_svganimate.py"""
animatesvg
==========
Create animation from a list of svg files or a list of matplotlib figures.
From svg file list
------------------
"""
from beampy import *
# Remove quiet=True to get beampy compilation outputs
doc = document(quiet=True)
with slide('Animation from svg files'):
animatesvg("./ressources/svg_anims/*.svg", width="600")
display_matplotlib(gcs())
##########################################################################
#
#From matplotlib figure list
#----------------------------
#
import pylab as p
with slide('Animation from matplotlib figures'):
anim_figs = []
for i in range(20):
fig = p.figure()
x = p.linspace(0,2*p.pi)
p.plot(x, p.sin(x+i))
p.plot(x, p.sin(x+i+p.pi))
p.close(fig)
anim_figs += [fig]
animatesvg(anim_figs)
save('./examples_html_outputs/animatesvg.html')
##########################################################################
#
#HTML output
#===========
#
#.. raw:: html
#
#
#
#Module arguments
#================
#
#.. autoclass:: beampy.animatesvg
# :noindex:
#
PK NnG plot_tikz.pyPK Nea a F plot_itemize.pyPK Nkl plot_code.pyPK N@@
plot_line.pyPK NU-L L 8
plot_grid.pyPK NHjŊ
plot_group.pyPK N[4; ;
c plot_arrow.pyPK Nwv v plot_box.pyPK NUHc h plot_TOC.pyPK NĆ % plot_figure.pyPK N+}u + plot_svg.pyPK N+ه
/ plot_title.pyPK N.- - E2 plot_rectangle.pyPK N=\ \
4 plot_video.pyPK Nz` (7 plot_text.pyPK Nj /: plot_svganimate.pyPK ?