Why does that one line of code break the annotation? And how can I get the data labels, which are animal names and not the numbers, added to the chart?
Cheers
CodePudding user response:
The reason why you're getting an error is clear, your plot has only 11 bars but you're passing 166 labels to them. My guess is you've mixed up your dfAnimalRankings
and new_df
as a result you've got mismatched labels.
The workaround here would be to set x_labels
to
x_labels = new_df['Animals'].tolist()
That way you'll get exactly 11 labels for 11 bars.