How to pivot the arrows on a quiver plot

Whis this dataframe using matplotlib.quiver I create the next graph:

plt.quiver(df['x'], df['y'], df['u'], df['v'], units='xy',width=0.5,scale=1/0.025,pivot='mid',headlength=0)


if I zoom in, the parameter pivot='mid' makes possible this::

I tried to create a similar plot with Plotly

fig=create_quiver(df['x'], df['y'], df['u'], df['v'], arrow_scale=0.001, scale=0.01)

but got this:

Is there any way to make the arrows rotate around the point (x,y) like in matplotlib (something like pivot='mid' )?

ff.create_quiver() has no keyword for mirroring the vectors through a point. But theoretically you can get the same plot as with matplotlib, with the following code:

import pandas as pd
import plotly.figure_factory as ff
from numpy import pi

df = pd.read_csv("quiver.csv")
fig=ff.create_quiver(2*df['x'].tolist(), 2*df['y'].tolist(), 
                  df['u'].tolist()+(df["u"].apply(lambda x: -1*x)).tolist(),
                  df['v'].tolist()+(df["v"].apply(lambda x: -1*x)).tolist(), 
                  arrow_scale=0.001, scale=0.01, angle=pi/18)

I said theoretically, because doubling the length of the dataframe we get a plot with lists x, y, u, v of length


each. I did not succeed to get the fig, because the jupyter kernel stopped, most likely due to the large amount of data.

1 Like

Thanks mate. The large amount of data causes the jupyter kernel to stall, so I try it in Colab, it takes 18 minutes to complete the task, the result is exactly the same as matplotlib!

1 Like

I cannot understand why to it takes so much to generate this plot.
Out of curiosity I also tested how long it takes, using the Julia version of (PlotlyJS.jl).
I couldn’t believe it when I saw that in less than a second the quiver plot was displayed.
Time to get the fig is 8.131 ms:
Julia is fast as C & Fortran.

1 Like

I have zero knowledge of Julia, but I want to give it a try, I hope to get it! Thanks for everything @empet

Hi again @empet !
Where can I find the quiver.jl file?

Hi @esia2019

In this notebook the lines of code in the first cell, between

are the contents of quiver.jl.
You can save quiver.jl either in the same folder as your current notebook, or in a subfolder, say julians,
and import it as:


This notebook illustrates a few examples to see how different settings lead to different quiver plots.

To install Parameters, in REPL import Pkg:

using Pkg

Good luck!! :slight_smile: