My Code:
ax = df_quests_event_ticket.plot.barh(stacked=True, figsize=(12, 9))
# .patches is everything inside of the chart
for rect in ax.patches:
# Bar Dimensions
height = rect.get_height()
width = rect.get_width()
x = rect.get_x()
y = rect.get_y()
# Bar Labels
label_text = f'{width:.1f}%' # format decimal values
# ax.text(x, y, text)
label_x = x + width / 2
label_y = y + height / 2
# only plot labels greater than given width
if width > 0:
ax.text(label_x, label_y, label_text, ha='center', va='center', fontsize=12)
#Legend
ax.legend(bbox_to_anchor=(1.05, 1), loc='upper left', borderaxespad=0.) ##problemn with positioning
#Labels
ax.set_ylabel("Quests", fontsize=18)
ax.set_xlabel("Percent of Audience", fontsize=18)
#Invert Y Axis
ax.invert_yaxis()
#Title
ax.set_title("Quest Completion")
plt.show()
Can't seem to find a way to add the total % to the end of each Stacked Bar
Any help is appreciated!