stacked-bar-chart

Create a stacked bar plot of percentages and annotate with count

Create a stacked bar plot of percentages and annotate with count Question: I have this data (df) and I get their percentages (data=rel) and plotted a stacked bar graph. Now I want to add values (non percentage values) to the centers of each bar but from my first dataframe. My code for now: import pandas …

Total answers: 2

Swipe or turn data for stacked bar chart in Matplotlib

Swipe or turn data for stacked bar chart in Matplotlib Question: I’m trying to create or generate some graphs in stacked bar I’m using this data: index 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 0 No 94 123 96 108 122 106.0 95.0 124 104 …

Total answers: 1

How to create a proportional horizontal stacked bar chart with percentages

How to create a proportional horizontal stacked bar chart with percentages Question: I have been struggling to create a horizontal bar chart using python, pandas, and matplotlib. Ideally I’d like to have percentages on the chart as well. I merged 2 datasets together to get this: # dataframe df = pd.DataFrame({‘Moving Violation’: [103281, 75376, 66957, …

Total answers: 2

How to create a 100% stacked barplot from a categorical dataframe

How to create a 100% stacked bar plot from a categorical dataframe Question: I have a dataframe structured like this: User Food 1 Food 2 Food 3 Food 4 Steph Onions Tomatoes Cabbages Potatoes Tom Potatoes Tomatoes Potatoes Potatoes Fred Carrots Cabbages Eggplant Phil Onions Eggplant Eggplant I want to use the distinct values from …

Total answers: 1

Add ONLY the total values on top of stacked bars

Add ONLY the total values on top of stacked bars Question: I am working with the following bar plot: And I would like to add only the total amount of each index on top of the bars, like this: However, when I use the following code, I only get parts of the stacks of each …

Total answers: 1

How to make a horizontal stacked bar plot of values as percentage

How to make a horizontal stacked bar plot of values as percentage Question: I have a list of 0,1 in dataframe. How can I plot a percentage of bar plot in pandas or matplotlib, that would have in the legend 1,0 and written annotation of percentage of the 1,0 compare to the whole list? import …

Total answers: 1

How to annotate each segment of a stacked bar chart

How to annotate each segment of a stacked bar chart Question: I’ve been trying to annotate each sub-amount of a stacked bar chart with its values like the picture shown above (values not accurate, just an example). df.iloc[1:].T.plot(kind=’bar’, stacked=True) plt.show() Data frame that I used: The linked post is somewhat similar to my question but …

Total answers: 1

Stacked bar chart in Seaborn

Stacked bar chart in Seaborn Question: I have the following data: countries2012 = [ ‘Bolivia’, ‘Brazil’, ‘Sri Lanka’, ‘Dominican Republic’, ‘Indonesia’, ‘Kenya’, ‘Honduras’, ‘Mozambique’, ‘Peru’, ‘Philipines’, ‘India’, ‘Vietnam’, ‘Thailand’, ‘USA’, ‘World’ ] percentage2012 = [ 0.042780099, 0.16599952, 0.012373058, 0.019171717, 0.011868674, 0.019239173, 0.00000332, 0.014455196, 0.016006654, 0.132970981, 0.077940824, 0.411752517, 0.017986798, 0.017361808, 0.058076027 ] countries2013 = [ ‘Bolivia’, …

Total answers: 2

Add vertical lines to a layered horizontal bar chart

Add vertical lines to a layered horizontal bar chart Question: I am generating a multi bar chart as a horizontal bar chart, and what I need to do now is to annotate (basically create a vertical line) in each of the horizontal bars at a specific place (x-axis value based) for every y-axis, where the …

Total answers: 2

Stacked Bar Chart with Centered Labels

Stacked Bar Chart with Centered Labels Question: I’m trying to "robustly" center the data labels in a stacked bar chart. A simple code example and the result are given below. As you can see, the data labels aren’t really centered in all rectangles. What am I missing? import numpy as np import matplotlib.pyplot as plt …

Total answers: 2