Issue
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()
Solution
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.
Answered By - user3521099
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.