python - 在 python (matplotlib) 中绘制矢量场

标签 python matplotlib

我在 http://matplotlib.sourceforge.net/examples/pylab_examples/quiver_demo.html 上找到了这段代码

from pylab import *
from numpy import ma

X,Y = meshgrid( arange(0,2*pi,.2),arange(0,2*pi,.2) )
U = cos(X)
V = sin(Y)

#1
figure()
Q = quiver( U, V)
qk = quiverkey(Q, 0.5, 0.92, 2, r'$2 \frac{m}{s}$', labelpos='W',
               fontproperties={'weight': 'bold'})
l,r,b,t = axis()
dx, dy = r-l, t-b
axis([l-0.05*dx, r+0.05*dx, b-0.05*dy, t+0.05*dy])

title('Minimal arguments, no kwargs')

现在,我怎样才能看到这个图形?更好的是,我怎样才能将它保存到一个文件中,比方说,JPEG?代码似乎可以运行,但我看不到任何事情发生。

最佳答案

理想情况下,您可以在交互式 shell(如 EPD Python 的 PyLab)中键入它。否则,您需要显式调用 show() 命令

关于python - 在 python (matplotlib) 中绘制矢量场,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1843194/

相关文章:

python - 在 Python 中使用 Matplotlib 缩放 y 轴

python - 在 Python 中绘制时间戳

python - 尝试使用 pip 安装 matplotlib 和 numpy 时出现错误

python - 如果在 HTML 页面中找不到文本,如何在 python 中打印空值?

python - 如何使用 python 获取 Youtube 视频的持续时间?

python - 在 Mac OS X 上使用键盘关闭 pyplot 图

python - 如何组合多个朴素贝叶斯分类器的输出?

python - 在正则表达式中转义美元符号不起作用

python - Seaborn distplot 与来自不同数组的 rugplot

python - 从 matplotlib 分析图形