Clustered Stacked Bar in Python Pandas [closed]

2024/7/7 3:59:50

I have created a single stacked bar chart but I want to have them clustered. Exactly something like the picture.

Wondering if it's possible.

link to picture

Answer
df = pd.DataFrame(dict(Subsidy=[3, 3, 3],Bonus=[1, 1, 1],Expense=[2, 2, 2]),list('ABC'))df

enter image description here

ax = df[['Subsidy', 'Bonus']].plot.bar(stacked=True, position=1,width=.2, ylim=[0, 8], color=['orange', 'red'])
df[['Expense']].plot.bar(ax=ax, position=0, width=.2, color=['green'])

enter image description here

https://en.xdnf.cn/q/120742.html

Related Q&A

A pythons beginner exercise [closed]

Its difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying thi…

Python iterate over multi value nested dictionary [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.Want to improve this question? Update the question so it focuses on one problem only by editing this post.Closed 7…

Why is this python while loop not ending?

I am wondering why this code seems to loop infinitely? The logic, while not False = while True, and this True is referring to 100 < 0 which is false, hence it should execute the print statement ins…

sort a field in ascending order and delete the first and last number [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.This question appears to be off-topic because it lacks sufficient information to diagnose the proble…

PermissionError: [Errno 13] Permission denied:

Im trying to write in a txt file the vertices of a spline mesh, but I get this error: PermissionError: [Errno 13] Permission denied: C\:Windows\system32\vt_84.txtThe code is

python calculator [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable…

How to sequence row based on another row?

I am trying to convert a formula from excel to pandas.The DataFrame looks like this: Column A Column B H H H J J J J K K I want to fill column B to increment while the value in co…

Multiclassification task using keras [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.Want to improve this question? Update the question so it focuses on one problem only by editing this post.Closed 3…

Clarification needed regarding immutability of strings in Python [closed]

Closed. This question is seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. It does not meet Stack Overflow guidelines. It is not currently accepting …

Please help me in solving Fractional Knapsack problem (Maximum Value of the Loot)

Maximum Value of the LootProblem Introduction: A thief finds much more loot than his bag can fit. Help him to find the most valuable combination of items assuming that any fraction of a loot item can b…