pysteps icon indicating copy to clipboard operation
pysteps copied to clipboard

Options for quiverkey when plotting motion fields

Open miaoneng opened this issue 5 years ago • 1 comments

It would be good to give an option that allow a quiverkey (legend) to be added to motion fields, otherwise it would be difficult to accurately read speed from motion plots.

See example below

20200814_090036

Since quiver function didn't return a quiver object, so it is hard to do that after the call. I modified the script in motionfield.py, I have something like

    # plot quiver
    qv1 = ax.quiver(
        X[skip],
        np.flipud(Y[skip]),
        dx[skip],
        -dy[skip],
        angles="xy",
        zorder=1e6,
        **kwargs_quiver,
    )
    w, h = plt.gcf().get_size_inches()
    plt.quiverkey(qv1, w * 0.95, h * 0.1, 10, '10 m/s', coordinates='inches')

But this is hard-coded for my own cases. It would be good to have an option to control this from the API call.

miaoneng avatar Aug 14 '20 16:08 miaoneng

Hello @striges, your suggestion would certainly make a good addition to the quiver method in the motionfields visualization module. As you mention, your code would need to be more general so that it can handle any data resolution (default units could be "px timestep-1"). Would you like to give it a try and submit a PR ?

edit: you can find some guidelines about contributing to pysteps here

dnerini avatar Aug 16 '20 08:08 dnerini