小编Max*_*Max的帖子

如何在 matplotlib 中使用 xy 数据设置 quiverkey 长度缩放?

我正在尝试设置quiverkey与数据的特定箭头长度相匹配的绝对箭头长度quiver。有人可以告诉我这个quiverkey论点是如何U运作的,或者至少如何根据我的需要来扩展它吗?

背景

Python版本:3.6.5

matplotlib 版本:3.0.0

最小的例子

我稍微修改了示例:https://matplotlib.org/gallery/images_contours_and_fields/quiver_simple_demo.html#sphx-glr-gallery-images-contours-and-fields-quiver-simple-demo-py

import matplotlib.pyplot as plt
import numpy as np

X = np.arange(-10, 11, 2)
Y = np.arange(-10, 11, 2)
U, V = np.meshgrid(X, Y)

# calculate length of each arrow
data_arrow_length = np.abs(np.sqrt(np.square(U[:]) + np.square(U[:])))

# set displayed arrow length for longest arrow
displayed_arrow_length = 2

# calculate scale factor for quiver
scale_factor = np.max(data_arrow_length)/displayed_arrow_length

# mysterious arrow length for quiverkey
quiverkey_length = 200

fig, …
Run Code Online (Sandbox Code Playgroud)

python matplotlib

5
推荐指数
1
解决办法
2807
查看次数

标签 统计

matplotlib ×1

python ×1