Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 74 additions & 0 deletions plots/streamline-basic/implementations/plotly.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
""" pyplots.ai
streamline-basic: Basic Streamline Plot
Library: plotly 6.5.0 | Python 3.13.11
Quality: 85/100 | Created: 2025-12-31
"""

import numpy as np
import plotly.figure_factory as ff


# Data - Create a grid for the vector field
x = np.linspace(-3, 3, 30)
y = np.linspace(-3, 3, 30)

# Create vortex flow field: u = -y, v = x (circular streamlines)
X, Y = np.meshgrid(x, y)

# Simple vortex flow (no normalization - preserves velocity magnitude)
u = -Y
v = X

# Create streamline plot with uniform color
fig = ff.create_streamline(x, y, u, v, density=1.5, arrow_scale=0.08, line={"width": 2.5, "color": "#306998"})

# Explicitly hide any colorbar that might be added
for trace in fig.data:
if hasattr(trace, "showscale"):
trace.showscale = False
if hasattr(trace, "marker") and trace.marker is not None:
trace.marker.showscale = False

# Update layout for large canvas with proper axis ranges matching data
fig.update_layout(
title={"text": "streamline-basic · plotly · pyplots.ai", "font": {"size": 28}, "x": 0.5, "xanchor": "center"},
xaxis={
"title": {"text": "X Position (dimensionless)", "font": {"size": 22}},
"tickfont": {"size": 18},
"showgrid": True,
"gridwidth": 1,
"gridcolor": "rgba(0,0,0,0.1)",
"zeroline": True,
"zerolinewidth": 2,
"zerolinecolor": "rgba(0,0,0,0.3)",
"range": [-3.5, 3.5],
"autorange": False,
},
yaxis={
"title": {"text": "Y Position (dimensionless)", "font": {"size": 22}},
"tickfont": {"size": 18},
"showgrid": True,
"gridwidth": 1,
"gridcolor": "rgba(0,0,0,0.1)",
"zeroline": True,
"zerolinewidth": 2,
"zerolinecolor": "rgba(0,0,0,0.3)",
"range": [-3.5, 3.5],
"autorange": False,
"scaleanchor": "x",
"scaleratio": 1,
},
template="plotly_white",
margin={"l": 120, "r": 50, "t": 100, "b": 100},
plot_bgcolor="white",
showlegend=False,
)

# Hide any colorbar annotations or colorbars
fig.update_coloraxes(showscale=False)

# Save as PNG (4800 x 2700 px)
fig.write_image("plot.png", width=1600, height=900, scale=3)

# Save interactive HTML version
fig.write_html("plot.html", include_plotlyjs="cdn")
26 changes: 26 additions & 0 deletions plots/streamline-basic/metadata/plotly.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
library: plotly
specification_id: streamline-basic
created: '2025-12-31T00:10:14Z'
updated: '2025-12-31T00:30:31Z'
generated_by: claude-opus-4-5-20251101
workflow_run: 20608632439
issue: 2861
python_version: 3.13.11
library_version: 6.5.0
preview_url: https://storage.googleapis.com/pyplots-images/plots/streamline-basic/plotly/plot.png
preview_thumb: https://storage.googleapis.com/pyplots-images/plots/streamline-basic/plotly/plot_thumb.png
preview_html: https://storage.googleapis.com/pyplots-images/plots/streamline-basic/plotly/plot.html
quality_score: 85
review:
strengths:
- Clean vortex flow pattern clearly demonstrates streamline visualization
- Good use of plotly figure_factory for streamline generation
- Appropriate density parameter (1.5) creates balanced streamline distribution
- Correct title format and good font sizing throughout
- Interactive HTML output leverages plotly strength
- Equal aspect ratio (scaleanchor) preserves circular pattern correctly
weaknesses:
- Colorbar appears in rendered output despite multiple attempts to hide it in code
- creates visual clutter and misleading Velocity Magnitude label for uniform-colored
streamlines
- Layout asymmetry due to unwanted colorbar taking space on right side