Wie kann ich für Multi-Index-Spalten in Pandas DataFrame einen bestimmten Levelwert für die Visualisierung in Python gruPython

Python-Programme
Anonymous
 Wie kann ich für Multi-Index-Spalten in Pandas DataFrame einen bestimmten Levelwert für die Visualisierung in Python gru

Post by Anonymous »

Ich habe einen PANDAS -Datenfream, der im Grunde eine Pivot -Tabelle ist. < /p>

Code: Select all

df.plot(kind = "bar",stacked = True)
führt zum folgenden Diagramm. Die Bezeichnungen in der x-Achse sind wie gezeigt verstopft. Hier "src =" https://i.sstatic.net/mlzztugd.png "/>
Wie kann ich mit Matplotlib in Python ähnliche Labels in x-axis erstellen?

Code: Select all

 dict = {'BatteryStorage': {('des-PDef3', 'Central Africa'): 0.0,
('des-PDef3', 'Eastern Africa'): 2475.9,
('des-PDef3', 'North Africa'): 98.0,
('des-PDef3', 'Southern Africa'): 124.0,
('des-PDef3', 'West Africa'): 1500.24,
('pes-PDef3', 'Central Africa'): 0.0,
('pes-PDef3', 'Eastern Africa'): 58.03,
('pes-PDef3', 'North Africa'): 98.0,
('pes-PDef3', 'Southern Africa'): 124.0,
('pes-PDef3', 'West Africa'): 0.0,
('tes-PDef3', 'Central Africa'): 0.0,
('tes-PDef3', 'Eastern Africa'): 1175.86,
('tes-PDef3', 'North Africa'): 98.0,
('tes-PDef3', 'Southern Africa'): 124.0,
('tes-PDef3', 'West Africa'): 0.0},
'Biomass PP': {('des-PDef3', 'Central Africa'): 44.24,
('des-PDef3', 'Eastern Africa'): 1362.4,
('des-PDef3', 'North Africa'): 178.29,
('des-PDef3', 'Southern Africa'): 210.01999999999998,
('des-PDef3', 'West Africa'): 277.4,
('pes-PDef3', 'Central Africa'): 44.24,
('pes-PDef3', 'Eastern Africa'): 985.36,
('pes-PDef3', 'North Africa'): 90.93,
('pes-PDef3', 'Southern Africa'): 144.99,
('pes-PDef3', 'West Africa'): 130.33,
('tes-PDef3', 'Central Africa'): 44.24,
('tes-PDef3', 'Eastern Africa'): 1362.4,
('tes-PDef3', 'North Africa'): 178.29,
('tes-PDef3', 'Southern Africa'): 210.01999999999998,
('tes-PDef3', 'West Africa'): 277.4}}

df = pd.DataFrame.from_dict(dict)
df.plot(kind = "bar",stacked = True)
plt.show()

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post