Seaborn barplot with regression line

Viewed 8763

Is there a way to add a regression line to a barplot in seaborn where the x axis contains pandas.Timestamps?

For example, overlay a trendline in this bar plot below. Am looking for the most efficient way to do this:

seaborn.set(style="white", context="talk")
a = pandas.DataFrame.from_dict({'Attendees': {pandas.Timestamp('2016-12-01'): 10,
  pandas.Timestamp('2017-01-01'): 12,
  pandas.Timestamp('2017-02-01'): 15,
  pandas.Timestamp('2017-03-01'): 16,
  pandas.Timestamp('2017-04-01'): 20}})
ax = seaborn.barplot(data=a, x=a.index, y=a.Attendees, color='lightblue', )
seaborn.despine(offset=10, trim=False)
ax.set_ylabel("")
ax.set_xticklabels(['Dec', 'Jan','Feb','Mar','Apr'])
plt.show()

enter image description here

1 Answers
Related