Andrew Smith Andrew Smith - 1 year ago 91
Python Question

Adding text labels to a simple matplotlib chart

I'm trying to add text labels to a simple matplotlib chart and nothing I've tried has worked.

plt.ylabel("No. of Likes")

enter image description here

It's a simple plot of the # of FB Likes per Event. I want the tick marks on the X axis to be the names of those events, which have been saved from a Pandas Dataframe into the variable "SpringThemes"

Any idea why this is not displaying the Themes as the tickmark labels on the x axis?

Answer Source

Let's say for example you have a list for your x axis:

x = [1,2,3,4]

You can add ticks on it like this:

plt.xticks([Game 1, Game 2, Game 3,Game 4])

Thus changing the x axis label.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download