📜  Python中的 Matplotlib.pyplot.quiver()

📅  最后修改于: 2022-05-13 01:55:08.473000             🧑  作者: Mango

Python中的 Matplotlib.pyplot.quiver()


Matplotlib是一个Python绑定库,它为用户提供了一个类似于 MATLAB 的绘图框架。 Matplotlib 可用于Python脚本、 Python和 IPython shell、Web 应用程序服务器以及各种图形用户界面工具包,如 Tkinter、awxPython 等。

Matplotlib.pyplot.quiver()

matplotlib.pyplot.quiver方法用于绘制 2D 箭头字段。

示例 #1

#Python program to explain
# matplotlib.pyplot.quiver method
  
  
import matplotlib.pyplot as plt
import numpy as np
   
#defining necessary arrays
x = np.linspace(0,2,8)
y = np.linspace(2,0,8)
x_dir = y_dir = np.zeros((8,8))
y_dir[5,5] = 0.2
   
#plotting the 2D graph
plt.quiver(x, y, x_dir, y_dir, scale=1)

输出:
matplotlib.pyplot.quiver

示例 #2
使用quiver方法在图形上绘制多个箭头

# Python program to explain 
# matplotlib.pyplot.quiver method
  
# importing necessary libraries
import matplotlib.pyplot as plt
  
# defining necessary arrays
x_coordinate = [0, 1.5]
y_coordinate = [0.5, 1.5]
x_direction = [1, -0.5]
y_direction = [1, -1]
  
# plotting the graph
plt.quiver(x_coordinate, y_coordinate,
           x_direction, y_direction,
           scale_units ='xy', scale = 1.)

输出:
matplotlib.pyplot.quiver