-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreportUtils.py
65 lines (52 loc) · 1.59 KB
/
reportUtils.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
import matplotlib
from sklearn.manifold import TSNE
from sklearn.decomposition import PCA
import os
os.environ["PATH"] += os.pathsep + '/usr/bin'
def set_size(width, fraction=1):
""" Set aesthetic figure dimensions to avoid scaling in latex.
Parameters
----------
width: float
Width in pts
fraction: float
Fraction of the width which you wish the figure to occupy
Returns
-------
fig_dim: tuple
Dimensions of figure in inches
"""
# Width of figure
fig_width_pt = width * fraction
# Convert from pt to inches
inches_per_pt = 1 / 72.27
# Golden ratio to set aesthetic figure height
golden_ratio = (5**.5 - 1) / 2
# Figure width in inches
fig_width_in = fig_width_pt * inches_per_pt
# Figure height in inches
fig_height_in = fig_width_in * golden_ratio
fig_dim = (fig_width_in, fig_height_in)
return fig_dim
pgf_with_rc_fonts = {"pgf.texsystem": "pdflatex"}
matplotlib.rcParams.update(pgf_with_rc_fonts)
plt.style.use('seaborn-colorblind')
width = 800
nice_fonts = {
# Use LaTeX to write all text
"text.usetex": True,
"font.family": "serif",
"font.serif": "Charter",
# Use 10pt font in plots, to match 10pt font in document
"axes.labelsize": 11,
"font.size": 11,
# Make the legend/label fonts a little smaller
"legend.fontsize": 11,
"xtick.labelsize": 11,
"ytick.labelsize": 11,
}
mpl.rcParams.update(nice_fonts)