Skip to content

Instantly share code, notes, and snippets.

@rchardptrsn
Last active February 1, 2020 20:51
Show Gist options
  • Save rchardptrsn/198c8933256d1e9639e154d85baa6a00 to your computer and use it in GitHub Desktop.
Save rchardptrsn/198c8933256d1e9639e154d85baa6a00 to your computer and use it in GitHub Desktop.
import seaborn as sns
import matplotlib.pyplot as plt
from matplotlib.collections import LineCollection
# Initialize figure and size of the plot
plt.figure(figsize=(14,8))
# Seaborn line plot
ax = sns.lineplot(x='Year',y='Average GDP Pct Change',
data=pct_change,
hue='Quartile',
palette='Accent')
# Create a dashed line at zero for comparison
ax.annotate("",
xy=(1961, 0), xycoords='data',
xytext=(2019, 0), textcoords='data',
arrowprops=dict(arrowstyle="-",
ls='dashed',
edgecolor = "red",
connectionstyle="arc3, rad=0"),
)
# Set xtick labels and rotate the x-axis labels
plt.setp(ax.get_xticklabels(), rotation=90)
# Set the title
plt.title('Average GDP Percent Change per Year - Quartiles')
# Grab the figure
fig = ax.get_figure()
# Save the figure
fig.savefig('Avg GDP pct change')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment