Skip to content

Commit 9427107

Browse files
feat(plotly): implement streamline-basic (#2908)
## Implementation: `streamline-basic` - plotly Implements the **plotly** version of `streamline-basic`. **File:** `plots/streamline-basic/implementations/plotly.py` **Parent Issue:** #2861 --- :robot: *[impl-generate workflow](https://github.com/MarkusNeusinger/pyplots/actions/runs/20608632439)* --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
1 parent ba2935c commit 9427107

2 files changed

Lines changed: 100 additions & 0 deletions

File tree

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
""" pyplots.ai
2+
streamline-basic: Basic Streamline Plot
3+
Library: plotly 6.5.0 | Python 3.13.11
4+
Quality: 85/100 | Created: 2025-12-31
5+
"""
6+
7+
import numpy as np
8+
import plotly.figure_factory as ff
9+
10+
11+
# Data - Create a grid for the vector field
12+
x = np.linspace(-3, 3, 30)
13+
y = np.linspace(-3, 3, 30)
14+
15+
# Create vortex flow field: u = -y, v = x (circular streamlines)
16+
X, Y = np.meshgrid(x, y)
17+
18+
# Simple vortex flow (no normalization - preserves velocity magnitude)
19+
u = -Y
20+
v = X
21+
22+
# Create streamline plot with uniform color
23+
fig = ff.create_streamline(x, y, u, v, density=1.5, arrow_scale=0.08, line={"width": 2.5, "color": "#306998"})
24+
25+
# Explicitly hide any colorbar that might be added
26+
for trace in fig.data:
27+
if hasattr(trace, "showscale"):
28+
trace.showscale = False
29+
if hasattr(trace, "marker") and trace.marker is not None:
30+
trace.marker.showscale = False
31+
32+
# Update layout for large canvas with proper axis ranges matching data
33+
fig.update_layout(
34+
title={"text": "streamline-basic · plotly · pyplots.ai", "font": {"size": 28}, "x": 0.5, "xanchor": "center"},
35+
xaxis={
36+
"title": {"text": "X Position (dimensionless)", "font": {"size": 22}},
37+
"tickfont": {"size": 18},
38+
"showgrid": True,
39+
"gridwidth": 1,
40+
"gridcolor": "rgba(0,0,0,0.1)",
41+
"zeroline": True,
42+
"zerolinewidth": 2,
43+
"zerolinecolor": "rgba(0,0,0,0.3)",
44+
"range": [-3.5, 3.5],
45+
"autorange": False,
46+
},
47+
yaxis={
48+
"title": {"text": "Y Position (dimensionless)", "font": {"size": 22}},
49+
"tickfont": {"size": 18},
50+
"showgrid": True,
51+
"gridwidth": 1,
52+
"gridcolor": "rgba(0,0,0,0.1)",
53+
"zeroline": True,
54+
"zerolinewidth": 2,
55+
"zerolinecolor": "rgba(0,0,0,0.3)",
56+
"range": [-3.5, 3.5],
57+
"autorange": False,
58+
"scaleanchor": "x",
59+
"scaleratio": 1,
60+
},
61+
template="plotly_white",
62+
margin={"l": 120, "r": 50, "t": 100, "b": 100},
63+
plot_bgcolor="white",
64+
showlegend=False,
65+
)
66+
67+
# Hide any colorbar annotations or colorbars
68+
fig.update_coloraxes(showscale=False)
69+
70+
# Save as PNG (4800 x 2700 px)
71+
fig.write_image("plot.png", width=1600, height=900, scale=3)
72+
73+
# Save interactive HTML version
74+
fig.write_html("plot.html", include_plotlyjs="cdn")
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
library: plotly
2+
specification_id: streamline-basic
3+
created: '2025-12-31T00:10:14Z'
4+
updated: '2025-12-31T00:30:31Z'
5+
generated_by: claude-opus-4-5-20251101
6+
workflow_run: 20608632439
7+
issue: 2861
8+
python_version: 3.13.11
9+
library_version: 6.5.0
10+
preview_url: https://storage.googleapis.com/pyplots-images/plots/streamline-basic/plotly/plot.png
11+
preview_thumb: https://storage.googleapis.com/pyplots-images/plots/streamline-basic/plotly/plot_thumb.png
12+
preview_html: https://storage.googleapis.com/pyplots-images/plots/streamline-basic/plotly/plot.html
13+
quality_score: 85
14+
review:
15+
strengths:
16+
- Clean vortex flow pattern clearly demonstrates streamline visualization
17+
- Good use of plotly figure_factory for streamline generation
18+
- Appropriate density parameter (1.5) creates balanced streamline distribution
19+
- Correct title format and good font sizing throughout
20+
- Interactive HTML output leverages plotly strength
21+
- Equal aspect ratio (scaleanchor) preserves circular pattern correctly
22+
weaknesses:
23+
- Colorbar appears in rendered output despite multiple attempts to hide it in code
24+
- creates visual clutter and misleading Velocity Magnitude label for uniform-colored
25+
streamlines
26+
- Layout asymmetry due to unwanted colorbar taking space on right side

0 commit comments

Comments
 (0)