Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ethen8181
GitHub Repository: ethen8181/machine-learning
Path: blob/master/notebook_format/formats.py
1470 views
1
import json
2
import warnings
3
import matplotlib
4
from IPython.core.display import HTML
5
6
7
def load_style(css_style = 'custom1.css', plot_style = True):
8
"""
9
custom1.css adapted from
10
https://github.com/rlabbe/ThinkBayes/blob/master/code/custom.css
11
12
custom2.css adapted from
13
https://github.com/neilpanchal/iPython-Notebook-Theme
14
"""
15
16
# recent matplotlibs are raising deprecation warnings that
17
# we don't worry about (it's the axes_prop_cycle).
18
warnings.filterwarnings('ignore')
19
20
# update the default matplotlib's formating
21
if plot_style:
22
with open('plot.json') as f:
23
s = json.load(f)
24
25
matplotlib.rcParams.update(s)
26
27
# load the styles for the notebooks
28
with open(css_style) as f:
29
styles = f.read()
30
31
return HTML(styles)
32
33