Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@anishazaveri
Last active May 30, 2020 03:38
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/483ffd81d3cafeb4abc0f742cda1b374 to your computer and use it in GitHub Desktop.
Save anishazaveri/483ffd81d3cafeb4abc0f742cda1b374 to your computer and use it in GitHub Desktop.
# plot data
# add two layers of points to create an illusion of a discontinuous line. "zorder" specifies plotting order
ax.scatter(x, y, s=64, color='white', zorder=2)
ax.scatter(x, y, s=8, color='black', zorder=3)
# add connecting line
ax.plot(x, y, color='black', zorder=1, linewidth=0.7)
# add horizontal dotted lines. See linestyles here: https://matplotlib.org/3.1.0/gallery/lines_bars_and_markers/linestyles.html
ax.plot([1970, 1977], [380, 380], linestyle=(
0, (5, 10)), linewidth=0.3, color='black')
ax.plot([1970, 1977], [400, 400], linestyle=(
0, (5, 10)), linewidth=0.3, color='black')
# add text
ax.text(1967, 415, "Per capita\nbudget expenditures,\nin constant dollars")
ax.text(1978, 390, "5%")
# add bar
bar = ArrowStyle.BarAB(widthA=0.2, widthB=0.2)
ax.annotate('', xy=(1977.5, 378), xytext=(1977.5, 402),
arrowprops={'arrowstyle': bar, 'lw': 0.7})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment