[FIXED] Festlegen von Titel- und Achsenbeschriftungen

Ausgabe

Ich versuche, meinen Handlungstitel und die X- und Y-Beschriftung festzulegen. Summen sind alle Zahlen float64. Ich versuche es so einfach wie möglich zu machen.

Hier ist der Teil meines Codes:

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()

Lösung

Sie müssen einen Achsenparameter ( ax) angeben.

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

Beachten Sie, dass für pandasDatenrahmen der Name des Index (falls vorhanden) automatisch zu x-Label wird.


Beantwortet von –
user3521099


Antwort geprüft von –
Cary Denson (FixError Admin)

0 Shares:
Leave a Reply

Your email address will not be published. Required fields are marked *

You May Also Like