- Trending Categories
- Data Structure
- Operating System
- MS Excel
- C Programming
- 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
Plot a vector field over the axes in Python Matplotlib?
To plot a vector field over the axes in matplotlib, we can take the following steps −
Set the figure size and adjust the padding between and around the subplots.
Make X, Y, T, R, U and V data points using numpy.
Add an axes to the current figure and make it the current axes.
Plot a 3D field of arrows using quiver() method.
To display the figure, use show() method.
import numpy as np import matplotlib.pyplot as plt plt.rcParams["figure.figsize"] = [7.50, 3.50] plt.rcParams["figure.autolayout"] = True n = 8 X, Y = np.mgrid[0:n, 0:n] T = np.arctan2(Y - n / 2., X - n/2.) R = 10 + np.sqrt((Y - n / 2.0) ** 2 + (X - n / 2.0) ** 2) U, V = R * np.cos(T), R * np.sin(T) plt.axes([0.025, 0.025, 0.95, 0.95]) plt.quiver(X, Y, U, V, R, cmap="copper") plt.show()
- Related Articles
- Calculate the curl of a vector field in Python and plot it with Matplotlib
- Matplotlib – Plot over an image background in Python
- Plot 3D bars without axes in Matplotlib
- How to plot a point on 3D axes in Matplotlib?
- Plot scatter points on 3d plot without axes and grids in Matplotlib
- How to get a matplotlib Axes instance to plot to?
- How do I let my Matplotlib plot go beyond the axes?
- How do I plot multiple X or Y axes in Matplotlib?
- How to plot sine curve on polar axes using Matplotlib?
- How to a plot stem plot in Matplotlib Python?
- What is the difference between drawing plots using plot, axes or figure in matplotlib?
- How to plot single data with two Y-axes (two units) in Matplotlib?
- How to hide axes but keep axis-labels in 3D Plot with Matplotlib?
- Showing points coordinate in a plot in Python Matplotlib
- Contour Plot using Python Matplotlib