2

I'm trying to set my plot title and x and y label. Totals are all numbers float64. I'm trying to do it as simple as possible way.

Here is the part of my code:

plt.close('all')
cand_all =pd.DataFrame({'Bachmann':[total15],
                        'Romney':[total2],
                        'Obama':[total3],
                        'Roemer': [total4],
                       'Pawlenty':[total5],
                       'Johnson':[total6],
                       'Paul':[total7],
                       'Santorum':[total8],
                       'Cain':[total9],
                       'Gingrich':[total10],
                       'McCotter':[total12],
                       'Huntsman':[total13],
                       'Perry':[total14]}) 



cand_all.plot.bar()
Trenton McKinney
  • 56,955
  • 33
  • 144
  • 158
pooh098
  • 201
  • 1
  • 4
  • 15

1 Answers1

5

You need to provide a axes (ax) parameter.

ax=plt.subplot(111)
cand_all.plot.bar(ax=ax)
ax.set_xlabel('xlabel')
ax.set_ylabel('ylabel')
ax.set_title('title')

Note that for pandas dataframes, name of the index (if exists) would be automatically become x label.

Serenity
  • 35,289
  • 20
  • 120
  • 115