Hovertext on create_quiver

I am trying to edit hovertext in figure_factory.create_quiver().

I am visualizing Spatio-temporal data and basically have 5 columns for coordinates (x, y), differences in coordinates (dx, dy) and velocity (calculated by dx and dy).

the exact code I am using now is below.


When I hover the cursor on an arrow, it only shows the coordinate of one of its edges, not the velocity(df['v']).

Then I looked into the ff.create_quiver().data[0] and found out the lengths of x and y axes and that of df['v'] (i.e. length of original df) do not match; x and y axes are twice as long as the original dataframe.

Is it because one arrow consists of multiple lines?

And how can I put hovertext on each arrow?


Since I have scatters each of which is associated to one arrow, the workaround I come up with is put hovertext on the scatters.

This worked for me, though admittedly it’s quite ugly. It will add the text to every point in the quiver.

hovertext = df.loc[list(df.index.repeat(3)) + list(df.index.repeat(4)), 'v']

The explanation: The figure factory makes a quiver by first drawing all the base lines of the quiver, which consists of two points plus a (None, None) point to cause a line break. (This is why it’s repeating 3 times.) Next, the factory draws the point of the arrow, which consists of three points plus another (None, None). (This is why it repeats 4 times.)