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,
You can include the text labels in the text attribute. To make sure that they are displayed on the scatter plot, set mode='lines+markers+text' . See the Plotly documentation on text and annotations.
Quiver plot is basically a type of 2D plot which shows vector lines as arrows. This type of plots are useful in Electrical engineers to visualize electrical potential and show stress gradients in Mechanical engineering.
By default, text annotations have xref and yref set to "x" and "y" , respectively, meaning that their x/y coordinates are with respect to the axes of the plot.
Adding Traces New traces can be added to a plot_ly figure using the add_trace() method. This method accepts a plot_ly figure trace and adds it to the figure.
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()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With