Matplotlib.pyplot.quiver () в Python
Matplotlib - это библиотека привязок Python, которая предоставляет пользователю среду построения графиков, подобную MATLAB. Matplotlib можно использовать в сценариях Python, оболочке Python и IPython, серверах веб-приложений и различных инструментах графического пользовательского интерфейса, таких как Tkinter, awxPython и т. Д.
Matplotlib.pyplot.quiver ()
matplotlib.pyplot.quiver method is used to plot a 2D field of arrows.
Syntax: matplotlib.pyplot.quiver(x_coordinate, y_coordinate, x_direction, y_direction)
Parameters:
x_coordinate : x-coordinate of the arrow location
y_coordinate : y-coordinate of the arrow location
x_direction : x-component of the direction of the arrow
y_direction : y-component of the direction of the arrowOptional Parameters:
scale: used to set the scale of the graph
scale_units: used to set the units of the plane with respect to x and y
angle: used to determine the angle of the arrow vectors plottedReturn Value : Returns a 2D graph with arrows plotted
Example #1
#Python program to explain# matplotlib.pyplot.quiver method import matplotlib.pyplot as pltimport numpy as np #defining necessary arraysx = 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 graphplt.quiver(x, y, x_dir, y_dir, scale=1) |
Output:
Example #2
Plotting multiple arrows on a graph using quiver method
# Python program to explain # matplotlib.pyplot.quiver method # importing necessary librariesimport matplotlib.pyplot as plt # defining necessary arraysx_coordinate = [0, 1.5]y_coordinate = [0.5, 1.5]x_direction = [1, -0.5]y_direction = [1, -1] # plotting the graphplt.quiver(x_coordinate, y_coordinate, x_direction, y_direction, scale_units ="xy", scale = 1.) |
Выход: 
Внимание компьютерщик! Укрепите свои основы с помощью базового курса программирования Python и изучите основы.
Для начала подготовьтесь к собеседованию. Расширьте свои концепции структур данных с помощью курса Python DS. А чтобы начать свое путешествие по машинному обучению, присоединяйтесь к курсу Машинное обучение - базовый уровень.