Search code examples
pythonmatplotlibplotzoomingarrows

Matplotlib: How do I scale a quiver plot while zooming?


I need some help with matplotlib.quiver.

I was creating some data that give me a nice quiver plot:

Full Quiver Plot

The arrows have a good small size to make the plot readable. But now I want to zoom (by using the magnifier symbol on the bottom) to the top left corner to see more details around the red dot. And I get this picture:

Zoomed Quiver Plot

This is still right, but now it is bad readable. The arrows are too short to see what’s going on there.

So my question is: How do I need to call ax.quiver(*meshgrid, *data) to scale the arrow lengths such that they will become larger when zooming into?

Thank you! :)


Solution

  • From the quiver documentation:

    units : [ 'width' | 'height' | 'dots' | 'inches' | 'x' | 'y' | 'xy' ] The arrow dimensions (except for length) are measured in multiples of this unit.

    'width' or 'height': the width or height of the axis

    'dots' or 'inches': pixels or inches, based on the figure dpi

    'x', 'y', or 'xy': respectively X, Y, or sqrt(X2+Y2) in data units

    The arrows scale differently depending on the units. For 'x' or 'y', the arrows get larger as one zooms in; for other units, the arrow size is independent of the zoom state. For 'width or 'height', the arrow size increases with the width and height of the axes, respectively, when the window is resized; for 'dots' or 'inches', resizing does not change the arrows.

    (emphasis mine)