In this Plotly tutorial, you will learn how to plot a histogram in Python. You can use px.histogram() function to plot a histogram.
Example 1
# Import Plotly Module import plotly.express as px # Data data = [15, 19, 20, 30, 30, 30, 30, 30, 40, 40, 40, 50, 60, 70, 80] # Histogram plot = px.histogram(data, title='Simple Plotly Histogram', height=400, width=600) # Show the Plot plot.show()
Output:

Example 2
# Import Plotly Module
import plotly.express as px
# Import Dataset
dataset = px.data.gapminder().query("continent=='Oceania'")
# Histogram
plot = px.histogram(dataset, x="lifeExp", color='country', title='Plotly Histogram', height=400, width=600)
# Show the Plot
plot.show()Output:



