SNEE_utils is a python package that could be reused from analysts working within the Suffolk and north east Essex Intelligence Function. Repositories in this organisation are created and maintained by analysts working in the SNEE Intelligence function hub.
It contains two child packages:
- nb_html_export.py --> This python file contains a set of convenience function to convert notebook to html and add table of contents. This primarily used nbconvert to perform the conversion and bs4 to insert the table of contents.
- A Python package containing useful functions for implementing SNEE style.
SNEE_utils
is a parent package that holds both the child packages namely: py_utils
and SNEE_styles
Python packages. Installation is using pip:
- It is recommended to use a Virtual Environment
- This will then install the module in your environment, optionally specifying the version
pip install git+https://github.com/SNEE-ICS/SNEE_Utils.git
or optionally specifying a version:
pip install git+https://github.com/SNEE-ICS/SNEE_Utils.git@v0.0.6
Once the parent package is installed, to use the py_utils or SNEE_styles package in your notebook, use:
from py_utils import *
my_notebook = 'Report.ipynb'
# By default this will add table fo content and exclude inputs cells(code)
formatted_html_with_toc = convert_notebook_to_html_string(my_notebok)
# Saves the notebook down to the original file name, but with .html
write_notebook_to_html(formatted_html_with_toc, my_notebook)
# For Matplotlib and Seaborn Plots
from snee_styles import mpl_styles
mpl_styles()
# For Plotly Plots
from snee_styles import plotly_style
plotly_style()
⚠️ For Jupyter Notebooks--> Please make sure you runfrom snee_styles import mpl_style, plotly_style
andmpl_style()
plotly_style
in code cells as shown above.
- Line plots
- Scatter plots
- Bubble plots
- Bar charts
- Pie charts
- Histograms and distribution plots
- 3D surface plots
- Stream plots
- Polar plots
To run the examples in example.ipynb
, install the required packages using pip install -r requirements_notebook.txt
in a Python virtual environment of your choice.
import matplotlib.pyplot as plt
from snee_styles import mpl_style
def plot():
mpl_style()
fig, axes = plt.subplots(2, 2, figsize=(15, 10))
# the following functions are defined in example.ipynb
line_plot(axes[0, 0])
scatter_plot(axes[0, 1])
distribution_plot(axes[1, 0])
ax = plt.subplot(2, 2, 4, projection='polar')
polar_plot(ax)
plot()
Plotly example plots can be viewed by clicking the link below:
Line Plot
Scatter Plot
Distribution Plot
QB Styles is licensed under the Apache 2.0 License.
Contributions to code and issues are welcome.