ipypublish.scripts.nb_setup module¶
Some useful functions for creating publishable jupyter notebooks
usage:
from ipypublish import nb_setup
plt = nb_setup.setup_matplotlib(
print_errors=True,
output=('pdf',))
pd = nb_setup.setup_pandas(escape_latex=True)
sym = nb_setup.setup_sympy()
import numpy as np
from IPython.display import Image, Latex
-
ipypublish.scripts.nb_setup.
images_gridconcat
(pathslist, width=700, height=700, aspaths=True, hgap=0, vgap=0)[source]¶ concatenate multiple images in a grid
- Parameters
pathslist (list[list]) – if aspaths=True, list of path strings, else list of PIL.Image instances each sub list constitutes a row
width (int) – maximum width of final image
height (int) – maximum height of final image
hgap (int) – size of horizontal space between images
vgap (int) – size of vertical space between images
- Returns
image
- Return type
-
ipypublish.scripts.nb_setup.
images_hconcat
(images, width=700, height=700, gap=0, aspaths=True)[source]¶ concatenate multiple images horizontally
- Parameters
- Returns
image
- Return type
Examples
>>> img_path = create_test_image(size=(50,50)) >>> img = images_hconcat([img_path,img_path]) >>> img.size (100, 50)
>>> img_path = create_test_image(size=(50,50)) >>> img = images_hconcat([img_path,img_path],width=40,height=40) >>> img.size (40, 20)
>>> img_path = create_test_image(size=(50,50)) >>> img = images_hconcat([img_path,img_path],width=[40,30]) >>> img.size (70, 40)
>>> img_path = create_test_image(size=(50,50)) >>> img = images_hconcat([img_path,img_path],gap=10) >>> img.size (110, 50)
-
ipypublish.scripts.nb_setup.
images_read
(paths)[source]¶ read a list of image paths to a list of PIL.IMAGE instances
-
ipypublish.scripts.nb_setup.
images_vconcat
(images, width=700, height=700, gap=0, aspaths=True)[source]¶ concatenate multiple images vertically
- Parameters
- Returns
image
- Return type
Examples
>>> img_path = create_test_image(size=(50,50)) >>> img = images_vconcat([img_path,img_path]) >>> img.size (50, 100)
>>> img_path = create_test_image(size=(50,50)) >>> img = images_vconcat([img_path,img_path],width=40,height=40) >>> img.size (20, 40)
>>> img_path = create_test_image(size=(50,50)) >>> img = images_vconcat([img_path,img_path],width=[40,30]) >>> img.size (40, 70)
>>> img_path = create_test_image(size=(50,50)) >>> img = images_vconcat([img_path,img_path],gap=10) >>> img.size (50, 110)
-
ipypublish.scripts.nb_setup.
setup_matplotlib
(output='pdf', 'svg', rcparams=None, usetex=True, print_errors=False)[source]¶ import and setup matplotlib in the jupyter notebook