Usually when I need to plot multiple traces I do that with the help of a for
loop.
Why wouldn’t it be possible to simply do it like this:
fig = go.Figure()
fig.add_scatter(y = np.random.normal(size=(4,10)))
fig
Usually when I need to plot multiple traces I do that with the help of a for
loop.
Why wouldn’t it be possible to simply do it like this:
fig = go.Figure()
fig.add_scatter(y = np.random.normal(size=(4,10)))
fig
You’re pretty close to what it should be! It’s actually .add_trace instead.
This should do the trick:
fig = go.Figure()
for _ in range(4):
fig.add_trace(
go.Scatter(y = np.random.normal(size=(4,10))
)
fig
add_scatter()
does the same thing as add_trace(go.Scatter())
actually.
If @ursus’ question is a design question, I guess the answer is basically that Plotly.js doesn’t work that way, and the Plotly.py API tries to stay close to the way Plotly.js works. In fact you can give more-than-1-dimensional data to y
or x
but that doesn’t yield multiple traces: it instead forces your axis into multi-category mode (max of 2-dimensional at the moment!)
It is a design question.
Most of the plotting functions I’ve used allow for this behavior. And I think that is a natural behavior.
Would it be possible to overload the way Plotly.js works to allow for that functionality?
Not a pressing issue.