-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlatexify.py
More file actions
53 lines (43 loc) · 1.83 KB
/
latexify.py
File metadata and controls
53 lines (43 loc) · 1.83 KB
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
import numpy
import matplotlib
def latexify(fig_width=None, fig_height=None, columns=1):
# code from http://nipunbatra.github.io/2014/08/latexify/
"""Set up matplotlib's RC params for LaTeX plotting.
Call this before plotting a figure.
Parameters
----------
fig_width : float, optional, inches
fig_height : float, optional, inches
columns : {1, 2}
"""
# code adapted from http://www.scipy.org/Cookbook/Matplotlib/LaTeX_Examples
# Width and max height in inches for IEEE journals taken from
# computer.org/cms/Computer.org/Journal%20templates/transactions_art_guide.pdf
if fig_width is None:
assert(columns in [1,2])
fig_width = 3.39 if columns==1 else 6.9 # width in inches
if fig_height is None:
golden_mean = (numpy.sqrt(5)-1.0)/2.0 # Aesthetic ratio
fig_height = fig_width*golden_mean # height in inches
# MAX_HEIGHT_INCHES = 8.0
# if fig_height > MAX_HEIGHT_INCHES:
# print("WARNING: fig_height too large:" + str(fig_height) +
# "so will reduce to" + str(MAX_HEIGHT_INCHES) + "inches.")
# fig_height = MAX_HEIGHT_INCHES
params = {'backend': 'pdf',
#'text.latex.preamble': ['\usepackage{gensymb}'],
'axes.labelsize': 8, # fontsize for x and y labels (was 10)
'axes.titlesize': 8,
#'text.fontsize': 8, # was 10
'text.color': 'black',
'legend.fontsize': 8, # was 10
'xtick.labelsize': 8,
'ytick.labelsize': 8,
'text.usetex': True,
'figure.figsize': [fig_width,fig_height],
#'figure.max_num_figures' : 40,
#'font.family': 'serif',
#'font.serif': ["Latin modern"]
'savefig.dpi': 200
}
matplotlib.rcParams.update(params)