Skip to content
Related Articles

Related Articles

Improve Article
How to create a Cumulative Histogram in Plotly?
  • Last Updated : 05 Sep, 2020

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.

Creating cumulative histogram

A cumulative histogram is a histogram that counts the cumulative cases over the range of cases. It can be created by passing True to the cumulative_enabled parameter.

Example 1: Vertical cumulative histogram

Python3




import plotly.express as px 
import plotly.graph_objects as go 
    
df = px.data.iris() 
    
fig = go.Figure(data=[go.Histogram(x=df['sepal_width'], 
                                   cumulative_enabled=True)]) 
fig.show()

Output:



Example 2: Horizontal cumulative histogram

Python3




import plotly.express as px 
import plotly.graph_objects as go 
    
df = px.data.iris() 
    
fig = go.Figure(data=[go.Histogram(y=df['sepal_width'], 
                                   cumulative_enabled=True)]) 
fig.show()

Output:

 Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.  

To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course




My Personal Notes arrow_drop_up
Recommended Articles
Page :