How to create Stacked bar chart in Python-Plotly? Last Updated : 29 Oct, 2020 Comments Improve Suggest changes Like Article Like Report Plotly is a Python library which is used to design graphs, especially interactive graphs. It can plot various graphs and charts like histogram, barplot, boxplot, spreadplot and many more. It is mainly used in data analysis as well as financial analysis. plotly is an interactive visualization library. Stack bar chart A stacked bar chart or graph is a chart that uses bars to demonstrate comparisons between categories of data, but with ability to impart and compare parts of a whole. Each bar in the chart represents a whole and segments which represent different parts or categories of that whole. Example 1: Using iris dataset Python3 import plotly.express as px df = px.data.iris() fig = px.bar(df, x="sepal_width", y="sepal_length", color="species", hover_data=['petal_width'], barmode = 'stack') fig.show() Output: Example 2: Using tips dataset Python3 import plotly.express as px df = px.data.tips() fig = px.bar(df, x="total_bill", y="day", color="sex", barmode = 'stack') fig.show() Output: Example 3: Using graph_objects class Python3 import plotly.graph_objects as px import numpy as np # creating random data through randomint # function of numpy.random np.random.seed(42) random_x= np.random.randint(1,101,100) random_y= np.random.randint(1,101,100) x = ['A', 'B', 'C', 'D'] plot = px.Figure(data=[go.Bar( name = 'Data 1', x = x, y = [100, 200, 500, 673] ), go.Bar( name = 'Data 2', x = x, y = [56, 123, 982, 213] ) ]) plot.update_layout(barmode='stack') plot.show() Output: Comment More infoAdvertise with us Next Article How to create Stacked bar chart in Python-Plotly? N nishantsundriyal98 Follow Improve Article Tags : Python Python-Plotly Practice Tags : python Similar Reads How to Create Stacked area plot using Plotly in Python? Plotly is a Python library that is used to design graphs, especially interactive graphs. It can plot various graphs and charts like histogram, barplot, boxplot, spreadplot, and many more. It is mainly used in data analysis as well as financial analysis. plotly is an interactive visualization library 2 min read How to group Bar Charts in Python-Plotly? Plotly is a Python library which is used to design graphs, especially interactive graphs. It can plot various graphs and charts like histogram, barplot, boxplot, spreadplot and many more. It is mainly used in data analysis as well as financial analysis. plotly is an interactive visualization library 2 min read How to Create a Stacked Bar Plot In this article, we will discuss how to create a stacked bar plot in Seaborn in Python.A stacked Bar plot is a kind of bar graph in which each bar is visually divided into sub bars to represent multiple column data at once. To plot the Stacked Bar plot we need to specify stacked=True in the plot met 2 min read How to create Tables using Plotly in Python? Plotly is a Python library that is used to design graphs, especially interactive graphs. It can plot various graphs and charts like histogram, barplot, boxplot, spreadplot, and many more. It is mainly used in data analysis as well as financial analysis. plotly is an interactive visualization library 2 min read How to change a color bar in Plotly in Python In this article, we will learn how to change a color bar in Plotly Python. Different types Color-Scale names for Plotlyaggrnyl    burginferno    plasma    rdpu     ylgnbu    mattergeyseragsunset   burgyl    jet      plotly3redorylorbr    solarpiygblackbodycividismagenta    pubu 2 min read Like