Skip to content

Instantly share code, notes, and snippets.

@ColCarroll
Last active March 9, 2021 21:18
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ColCarroll/bb509ba8016fbbfe485ba6b89912452b to your computer and use it in GitHub Desktop.
Save ColCarroll/bb509ba8016fbbfe485ba6b89912452b to your computer and use it in GitHub Desktop.
My custom matplotlib stylesheet
lines.linewidth: 3
lines.markerfacecolor: None
lines.markeredgewidth: 2
lines.markersize: 8
lines.solid_capstyle: butt
legend.fancybox: true
axes.prop_cycle: cycler('color', ['000000', '1b6989', 'e69f00', '009e73', 'f0e442','50b4e9', 'd55e00', 'cc79a7'])
axes.facecolor: fffff8
axes.axisbelow: true
axes.labelsize: large
axes.titlesize: x-large
axes.grid: false
axes.linewidth: 1
hist.bins: auto
xtick.major.size: 0
ytick.major.size: 0
xtick.minor.size: 0
ytick.minor.size: 0
font.family: serif
font.serif: Palatino, Palatino Linotype, Palatino LT STD, Book Antiqua, Georgia, DejaVu Serif
font.size: 14
figure.constrained_layout.use: True
figure.facecolor: fffff8
figure.figsize: 10.0, 7.0
path.simplify: True
path.simplify_threshold: 1.0
agg.path.chunksize: 10000
@ColCarroll
Copy link
Author

ColCarroll commented Mar 26, 2019

Put this in

python -c 'import matplotlib, os; print(os.path.join(matplotlib.get_configdir(), "stylelib"))'

then use with matplotlib.style.use('tufte')

looks like this:
image

fig, axes = plt.subplots(ncols=2, figsize=(15, 5))
t = np.linspace(-2 * np.pi, 2 * np.pi, 1000)
for j in range(8):
    axes[0].plot(t, np.cos(5 * t) + j - 0.5 * t ** 2)
    axes[0].set_xlabel('x-axis')
    axes[0].set_ylabel('y-axis')
    axes[0].set_title('Lines')
    
    
scatter1 = np.random.multivariate_normal(np.zeros(2), np.array([[1, 0.9], [0.9, 1]]), 300).T
scatter2 = np.random.multivariate_normal(np.zeros(2), np.array([[1, -0.9], [-0.9, 1]]), 200).T

axes[1].plot(*scatter1, 'o', label='Positive correlation')
axes[1].plot(*scatter2, 'o', label='Negative Correlation')
axes[1].set_title('Scatter')
axes[1].legend(loc=1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment