forked from SgmAstro/DESI
-
Notifications
You must be signed in to change notification settings - Fork 1
/
pubplot.py
53 lines (39 loc) · 1.12 KB
/
pubplot.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
'''
Generate publication ready plots
'''
import os
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
def set_size(width=240, fraction=2):
""" 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 ** 0.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
return (fig_width_in, fig_height_in)
plt.style.use(os.environ['HOME'] + '/DESI/style.mplstyle')
nice_fonts = {
"text.usetex": True,
"font.family": "serif",
"font.serif" : "Times New Roman",
}
plt.rcParams["figure.figsize"] = set_size()
matplotlib.rcParams.update(nice_fonts)