Reputation: 470
I'd like to add quivers to an existing figure with plotly (python). But the only peace of documentation I could find either create only one quiver (here) or a brand new figure (there).
Here's the example on plotly doc :
import plotly.figure_factory as ff
import numpy as np
x,y = np.meshgrid(np.arange(0, 2, .2), np.arange(0, 2, .2))
u = np.cos(x)*y
v = np.sin(x)*y
fig = ff.create_quiver(x, y, u, v)
fig.show()
If anyone has a better understanding of plotly that I do, I'd appreciate a lot a few explanations!
Thanks a lot,
Upvotes: 6
Views: 2704
Reputation: 61184
Assuming that you'd like to add quivers to an existing ff.create_quiver()
figure, all you have to do is:
fig1 = ff.create_quiver(x, y, u, v)
,fig2 = ff.create_quiver(x, y, u*0.9, v*2)
,fig2.data
to fig1
using fig1.add_traces(data = fig2.data)
import plotly.figure_factory as ff
import numpy as np
x,y = np.meshgrid(np.arange(0, 2, .2), np.arange(0, 2, .2))
u = np.cos(x)*y
v = np.sin(x)*y
fig1 = ff.create_quiver(x, y, u, v)
fig2 = ff.create_quiver(x, y, u*0.9, v*2)
fig1.add_traces(data = fig2.data)
fig1.show()
Upvotes: 4