- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to plot vectors in Python using Matplotlib?
To plot vectors in Python using matplotlib, we can take the following steps −
Create a matrix of 2×3 dimension.
Create an origin point, from where vecors could be originated.
Plot a 3D fields of arrows using quiver() method with origin, data, colors and scale=15.
Example
import numpy as np from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True data = np.array([[2, 1], [-1, 2], [4, -1]]) origin = np.array([[0, 0, 0], [0, 0, 0]]) plt.quiver(*origin, data[:, 0], data[:, 1], color=['black', 'red', 'green'], scale=15) plt.show()
Output
- Related Articles
- How to plot 2D math vectors with Matplotlib?
- How to plot MFCC in Python using Matplotlib?
- How to plot an array in Python using Matplotlib?
- How to plot 3D graphs using Python Matplotlib?
- How to plot longitudinal magnitude spectrum in Matplotlib using Python?
- How to plot an angle spectrum using Matplotlib in Python?
- How to a plot stem plot in Matplotlib Python?
- Putting arrowheads on vectors in Matplotlib's 3D plot
- How to plot CSV data using Matplotlib and Pandas in Python?
- How to plot signal in Matplotlib in Python?
- How to plot cdf in Matplotlib in Python?
- Frequency plot in Python/Pandas DataFrame using Matplotlib
- How to plot collections.Counter histogram using Matplotlib?
- How to plot magnitude spectrum in Matplotlib in Python?
- How to Plot Cluster using Clustermaps class in Matplotlib

Advertisements