Reputation: 167
I have a dataframe that shows monthly revenue. There is an additional column that shows the number of locations opened in that month.
> Date Order Amount Locations Opened
16 2016-05-31 126443.17 2.0
> 17 2016-06-30 178144.27 0.0
18 2016-07-31 230331.96 1.0
> 19 2016-08-31 231960.04 0.0
20 2016-09-30 208445.26 0.0
I'm using seaborn to plot the revenue by month
sns.lineplot(x="Date", y="Order Amount",
data=total_monthly_rev).set_title("Total Monthly Revenue")
I've been trying, unsuccessfully, to use the third column, Locations Opened, to add supporting text to the lineplot so I can show the number of locations opened in a month, where Locations Opened > 0.
Upvotes: 3
Views: 7582
Reputation: 3967
IIUC, use text
:
plt.figure(figsize=(12, 5))
sns.lineplot(x="Date", y="Order Amount", data=total_monthly_rev).set_title("Total Monthly Revenue")
# Using a variable to manage how above/below text should appear
slider = 1000
for i in range(total_monthly_rev.shape[0]):
if total_monthly_rev['LocationsOpened'].iloc[i] > 0:
plt.text(total_monthly_rev.Date.iloc[i],
total_monthly_rev['Order Amount'].iloc[i] + slider,
total_monthly_rev['LocationsOpened'].iloc[i])
plt.show()
Upvotes: 5