Код: Выделить всё
df = pd.DataFrame({
'Plan': [40, 50, 60, 25],
'Fact': [10, 20, 30, 15],
'financing_type': ['type_1', 'type_2', 'type_1', 'type_3']
})
Точно так:

Я сделал это следующим образом:
Код: Выделить всё
df_type_1 = df[df['financing_type'] == 'type_1']
df_type_2 = df[df['financing_type'] == 'type_2']
df_type_3 = df[df['financing_type'] == 'type_3']
plt.bar(['Plan', 'Fact'], [df_type_1['Plan'].sum(), df_type_1['Fact'].sum()], color='blue', label='type_1')
plt.bar(
['Plan', 'Fact'],
[df_type_2['Plan'].sum(), df_type_2['Fact'].sum()],
bottom=[df_type_1['Plan'].sum(), df_type_1['Fact'].sum()],
color='red',
label='type_2',
)
plt.bar(
['Plan', 'Fact'],
[df_type_3['Plan'].sum(), df_type_3['Fact'].sum()],
bottom=[df_type_1['Plan'].sum() + df_type_2['Plan'].sum(), df_type_1['Fact'].sum() + df_type_2['Fact'].sum()],
color='green',
label='type_3',
)
plt.legend()
plt.show()
Подробнее здесь: https://stackoverflow.com/questions/786 ... -dataframe