Last active
May 16, 2020 02:07
-
-
Save sdwebb/0984f9363f22b0e3fb6cc5867c968ba9 to your computer and use it in GitHub Desktop.
A Tufte style dot-dash plot
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 | |
from matplotlib.ticker import FixedLocator | |
import matplotlib.font_manager as fm | |
from matplotlib import pyplot as plt | |
font = fm.FontProperties( | |
family = 'Gill Sans', | |
fname = '/usr/share/fonts/truetype/adf/GilliusADF-Regular.otf') | |
import matplotlib.pylab as pylab | |
params = {'axes.spines.right' : False, | |
'axes.spines.left' : False, | |
'axes.spines.top' : False, | |
'axes.spines.bottom' : False, | |
'font.family' : 'Gill Sans'} | |
pylab.rcParams.update(params) | |
import numpy as np | |
# | |
# A working example | |
# | |
x = np.random.random(100) | |
y = np.exp(-2.*x + np.random.normal(loc=1., scale=.1, size=100)) | |
fig, ax = plt.subplots() | |
ax.scatter(x, y, s=5, c='k') | |
ax.xaxis.set_minor_locator(FixedLocator(x)) | |
ax.yaxis.set_minor_locator(FixedLocator(y)) | |
ax.set_xlabel(r'$x$') | |
ax.set_ylabel(r'$y$') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here is an example of how to create an Edward Tufte style dot-dash scatter plot using matplotlib. I think the axis label font size is too small, but that's easy to fix by adding to the
params
dictionary and this is meant to be a minimum working example. Here is the final output: