Skip to content

Instantly share code, notes, and snippets.

@anishazaveri
Last active May 30, 2020 03:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anishazaveri/c0db2d634a1b839402c188c0c3cb8313 to your computer and use it in GitHub Desktop.
Save anishazaveri/c0db2d634a1b839402c188c0c3cb8313 to your computer and use it in GitHub Desktop.
from matplotlib.ticker import FuncFormatter
from matplotlib.patches import ArrowStyle
fig, ax = plt.subplots(figsize=(7, 3))
# remove splines
for spine in ax.spines.keys():
ax.spines[spine].set_visible(False)
# set axis limits
ax.set_ylim(290, 420)
ax.set_xlim(1966.5, 1979)
# define axis ticks
ax.xaxis.set_ticks(x)
ax.yaxis.set_ticks(list(range(300, 420, 20)))
# increase space between axis labels and ticks
ax.yaxis.set_tick_params(pad=8)
ax.xaxis.set_tick_params(pad=8)
# create formatter to convert y_ticks to dollars
def format_ticks(x, pos):
return f'${x}'
formatter = FuncFormatter(format_ticks)
# modify y ticks to dollars
ax.yaxis.set_major_formatter(formatter)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment