-
-
Save HHammond/2f3a5ab2aca280da986b27a8d5bc90a4 to your computer and use it in GitHub Desktop.
Notebooks Plotting
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
from matplotlib import pyplot as plt | |
import matplotlib.patheffects as pe | |
import matplotlib.ticker as mtick | |
import matplotlib.style as style | |
import seaborn as sns | |
%matplotlib inline | |
%config InlineBackend.figure_format = 'svg' | |
style.use(['seaborn-whitegrid', 'seaborn-notebook', 'seaborn-colorblind']) | |
plt.rcParams['legend.handlelength'] = 1.0 | |
plt.rcParams['axes.spines.left'] = True | |
plt.rcParams['axes.spines.bottom'] = True | |
plt.rcParams['axes.spines.top'] = False | |
plt.rcParams['axes.spines.right'] = False | |
plt.rcParams["lines.linewidth"] = 1.5 | |
plt.rcParams["axes.facecolor"] = "#FDFEFF" | |
plt.rcParams["savefig.facecolor"] = "#FDFEFF" | |
plt.rcParams["axes.edgecolor"] = "#828C95" | |
plt.rcParams["xtick.color"] = "#828C95" | |
plt.rcParams["ytick.color"] = "#828C95" | |
plt.rcParams["xtick.direction"] = "out" | |
plt.rcParams["ytick.direction"] = "out" | |
plt.rcParams["xtick.labelsize"] = "small" | |
plt.rcParams["ytick.labelsize"] = "small" | |
plt.rcParams["xtick.major.size"] = 6 | |
plt.rcParams["xtick.minor.size"] = 3 | |
plt.rcParams["ytick.major.size"] = 6 | |
plt.rcParams["ytick.minor.size"] = 3 | |
plt.rcParams["xtick.major.width"] = 0.5 | |
plt.rcParams["xtick.minor.width"] = 0.5 | |
plt.rcParams["ytick.major.width"] = 0.5 | |
plt.rcParams["ytick.minor.width"] = 0.5 | |
plt.rcParams["grid.color"] = "#F4F4F4" | |
plt.rcParams["grid.linestyle"] = "-" |
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
import re | |
def pct_format(v, *args): | |
expr = r""" | |
(?<!^) # Not start of string | |
( | |
\.? # Capture decimal if only followed by zeros | |
0{2,} # Capture extra zeros | |
) | |
(?=%) # Must be before the percent sign | |
""" | |
return re.sub(expr, "", "{:.5%}".format(v), count=1, flags=re.VERBOSE) | |
stroke_effect = [ | |
pe.Stroke(linewidth=4, foreground='w'), | |
pe.Normal(), | |
] | |
text_effect = [ | |
pe.Stroke(linewidth=1.5, foreground='w'), | |
pe.Normal(), | |
] | |
PURPLE = '#DA70D6' |
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
from matplotlib import pyplot as plt | |
import seaborn as sns | |
%matplotlib inline | |
%config InlineBackend.figure_format = 'retina' | |
plt.rcParams['figure.figsize'] = (16, 9) | |
import matplotlib.style as style | |
# style.use(['seaborn-whitegrid', 'seaborn-notebook', 'seaborn-colorblind']) | |
# style.use(['seaborn-whitegrid', 'seaborn-paper', 'seaborn-colorblind']) | |
# style.use(['seaborn-whitegrid', 'seaborn-presentation', 'seaborn-colorblind']) | |
style.use(['seaborn-whitegrid', 'seaborn-talk', 'seaborn-colorblind']) | |
# Make your plots more readable | |
plt.rcParams['lines.linewidth'] = 2.5 | |
# Remove the edges from your graph | |
def hide_spines(): | |
plt.rcParams['axes.spines.left'] = False | |
plt.rcParams['axes.spines.bottom'] = False | |
plt.rcParams['axes.spines.top'] = False | |
plt.rcParams['axes.spines.right'] = False | |
def show_spines(): | |
plt.rcParams['axes.spines.left'] = True | |
plt.rcParams['axes.spines.bottom'] = True | |
plt.rcParams['axes.spines.top'] = True | |
plt.rcParams['axes.spines.right'] = True | |
# Bump the font sizes on your labels | |
plt.rcParams['xtick.labelsize'] = 14 | |
plt.rcParams['ytick.labelsize'] = 14 | |
import matplotlib.patheffects as pe | |
import matplotlib.ticker as mtick |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment