-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
2,137 additions
and
177 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
import pandas as pd | ||
import matplotlib | ||
|
||
from math import sqrt | ||
SPINE_COLOR = 'gray' | ||
|
||
def latexify(fig_width=None, fig_height=None, columns=1): | ||
"""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 | ||
|
||
assert(columns in [1,2]) | ||
|
||
if fig_width is None: | ||
fig_width = 2.0 if columns==1 else 4.0 # width in inches | ||
|
||
if fig_height is None: | ||
golden_mean = 1/1.62 # 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': 'ps', | ||
'text.latex.preamble': '\\usepackage{gensymb}', | ||
'axes.labelsize': 10, # fontsize for x and y labels (was 10) | ||
'axes.titlesize': 10, | ||
'font.size': 10, # was 10 | ||
'legend.fontsize': 10, # was 10 | ||
'xtick.labelsize': 10, | ||
'ytick.labelsize': 10, | ||
'text.usetex': True, | ||
'figure.figsize': [fig_width,fig_height], | ||
'font.family': 'serif' | ||
} | ||
|
||
matplotlib.rcParams.update(params) | ||
|
||
|
||
def format_axes(ax): | ||
|
||
for spine in ['top', 'right']: | ||
ax.spines[spine].set_visible(False) | ||
|
||
for spine in ['left', 'bottom']: | ||
ax.spines[spine].set_color(SPINE_COLOR) | ||
ax.spines[spine].set_linewidth(0.5) | ||
|
||
ax.xaxis.set_ticks_position('bottom') | ||
ax.yaxis.set_ticks_position('left') | ||
|
||
for axis in [ax.xaxis, ax.yaxis]: | ||
axis.set_tick_params(direction='out', color=SPINE_COLOR) | ||
|
||
return ax |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.