I would like to create a histogram with the y values representing the number of occurrences of a set and the x axis representing the number of sets. For example...
Ideally, there would be three bars (bins) associated with each set. Here is the code I've come up with...
# Bins (x-axis)
bins = [1,2,3]
# Trace (y-axis)
passengers = [14, 27, 19]
# Data
data = [go.Histogram(x=bins, y=passengers)]
# Layout
layout = Layout(title='Histogram Example')
# Figure
fig = {'data': data, 'layout': layout}
#Plot
iplot(fig)
What is the simplest way to represent this data with Plotly's go.Histogram function?
I have created a graph using your data using the official reference. See here .
import plotly.graph_objects as go
bins = ["Age0-20","Age21-40","Age41-60"]
passengers = ["14","27","19"]
fig = go.Figure()
fig.add_trace(go.Histogram(histfunc="sum", y=passengers, x=bins, name="sum"))
fig.update_layout(showlegend=True)
fig.show()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.