Skip to content

Commit 65e8211

Browse files
feat(plotly): implement histogram-basic
Add basic histogram implementation for plotly library.
1 parent 27357ca commit 65e8211

1 file changed

Lines changed: 30 additions & 0 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
"""
2+
histogram-basic: Basic Histogram
3+
Library: plotly
4+
"""
5+
6+
import numpy as np
7+
import plotly.graph_objects as go
8+
9+
10+
# Data
11+
np.random.seed(42)
12+
values = np.random.normal(100, 15, 500)
13+
14+
# Create figure
15+
fig = go.Figure()
16+
fig.add_trace(go.Histogram(x=values, marker_color="#306998", opacity=0.8, nbinsx=30))
17+
18+
# Layout
19+
fig.update_layout(
20+
title={"text": "Basic Histogram", "font": {"size": 20}},
21+
xaxis_title="Value",
22+
yaxis_title="Frequency",
23+
template="plotly_white",
24+
xaxis={"title_font": {"size": 20}, "tickfont": {"size": 16}},
25+
yaxis={"title_font": {"size": 20}, "tickfont": {"size": 16}},
26+
bargap=0.05,
27+
)
28+
29+
# Save
30+
fig.write_image("plot.png", width=1600, height=900, scale=3)

0 commit comments

Comments
 (0)