8000 Backport PR #14062 on branch v3.1.x (Improve advanced quiver example) by meeseeksmachine · Pull Request #14067 · matplotlib/matplotlib · GitHub
[go: up one dir, main page]

Skip to content

Backport PR #14062 on branch v3.1.x (Improve advanced quiver example) #14067

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions examples/images_contours_and_fields/quiver_demo.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
"""
========================================================
Demonstration of advanced quiver and quiverkey functions
========================================================
=======================================
Advanced quiver and quiverkey functions
=======================================

Demonstrates some more advanced options for `~.axes.Axes.quiver`. For a simple
example refer to :doc:`/gallery/images_contours_and_fields/quiver_simple_demo`.

Known problem: the plot autoscaling does not take into account the arrows, so
those on the boundaries are often out of the picture. This is *not* an easy
problem to solve in a perfectly general way. The workaround is to manually
expand the Axes objects.
Note: The plot autoscaling does not take into account the arrows, so
those on the boundaries may reach out of the picture. This is not an easy
problem to solve in a perfectly general way. The recommended workaround is to
manually set the Axes limits in such a case.
"""

import matplotlib.pyplot as plt
import numpy as np

Expand Down Expand Up @@ -38,14 +39,16 @@

###############################################################################

# sphinx_gallery_thumbnail_number = 3

fig3, ax3 = plt.subplots()
ax3.set_title("pivot='tip'; scales with x view")
M = np.hypot(U, V)
Q = ax3.quiver(X, Y, U, V, M, units='x', pivot='tip', width=0.022,
scale=1 / 0.15)
qk = ax3.quiverkey(Q, 0.9, 0.9, 1, r'$1 \frac{m}{s}$', labelpos='E',
coordinates='figure')
ax3.scatter(X, Y, color='k', s=5)
ax3.scatter(X, Y, color='0.5', s=1)

plt.show()

Expand Down
0