I am using a doublebar plot to compare the total reach of each track. since the total reach of one group is significantly larger than the second group, I decided to create another column, total reach - log(x)
, that is just the np.log of the original total reach
. The y axis reflects the scale for the log but I want to annotate the bars with the actual values from total reach
.
Any idea on how to do that?
import seaborn as sns
import matplotlib.pyplot as plt
#plot a bar graph and assign track name variable to hue
double_plot = sns.barplot(
x='date',
y='total reach - log(x)',
hue='track name',
data=dflog,
palette=['blue','red'],
alpha=1,
dodge=True,
)
double_plot.set_ylim(0,dflog['total reach - log(x)'].max())
for item in double_plot.get_xticklabels():
item.set_rotation(45)
for p in double_plot.patches:
double_plot.annotate(format(p.get_height(), '.0f'),
(p.get_x() + p.get_width() / 2., p.get_height()),
ha = 'center', va = 'center',
xytext = (0, 9),
textcoords = 'offset points')
fig = plt.gcf()
fig.set_size_inches(15,7)
plt.title("Total Followers - log(x) - Fleetwood Mac's Dreams")