0

How do I get the state name to show in x-axis instead of the numbers and how can I display the chart with different colors. margin of victory by state:

margin of victory by state

pushkin
  • 9,575
  • 15
  • 51
  • 95
Ola
  • 1
  • 1
  • Possible duplicate of [matplotlib strings as labels on x axis](https://stackoverflow.com/questions/7559242/matplotlib-strings-as-labels-on-x-axis) – hoffee Jul 13 '18 at 17:02

1 Answers1

0

You can use the xticks function to change the x-axis labels. In your case, this would look something like this:

plt.xticks(locs=list(range(37)), labels=[list of state names goes here])

Documentation here.

hoffee
  • 470
  • 3
  • 16
  • Thank Hoffee, It works now with this line plt.xticks(range(37), [list of state names goes here]) plt.show() – Ola Jul 15 '18 at 11:08