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