Create a plotly line plot with N lines that change color continuously from blue to red.
- User
Create a plotly line plot with N lines that change color continuously from blue to red.
Assistant
Here's a Plotly line plot with N lines that change color continuously from blue to red:
pythonimport plotly.graph_objects as go N = 10 # Number of lines # Create figure fig = go.Figure() # Add lines for n in range(N): # Create list of x and y values x = list(range(100)) y = [np.sin(x[i] + n) for i in range(100)] # Add line fig.add_trace(go.Scatter(x=x, y=y, line=dict(color=f'rgb({n*255/N},0,{255-n*255/N})', width=2), name=f'Line {n}')) # Update layout fig.update_layout(title='Color-changing lines', xaxis_title='x', yaxis_title='y') # Show plot fig.show()
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.