Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Examples using matplotlib.pyplot.quiver

'''
========================================================
Demonstration of advanced quiver and quiverkey functions
========================================================

Known problem: the plot autoscaling does not take into account
the arrows, so those on the boundaries are often out of the picture.
This is *not* an easy problem to solve in a perfectly general way.
The workaround is to manually expand the axes.
'''
import matplotlib.pyplot as plt
import numpy as np
from numpy import ma

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

plt.figure()
plt.title('Arrows scale with plot width, not view')
Q = plt.quiver(X, Y, U, V, units='width')
qk = plt.quiverkey(Q, 0.9, 0.9, 2, r'$2 frac{m}{s}$', labelpos='E',
                   coordinates='figure')

plt.figure()
plt.title("pivot='mid'; every third arrow; units='inches'")
Q = plt.quiver(X[::3, ::3], Y[::3, ::3], U[::3, ::3], V[::3, ::3],
               pivot='mid', units='inches')
qk = plt.quiverkey(Q, 0.9, 0.9, 1, r'$1 frac{m}{s}$', labelpos='E',
                   coordinates='figure')
plt.scatter(X[::3, ::3], Y[::3, ::3], color='r', s=5)

plt.figure()
plt.title("pivot='tip'; scales with x view")
M = np.hypot(U, V)
Q = plt.quiver(X, Y, U, V, M, units='x', pivot='tip', width=0.022,
               scale=1 / 0.15)
qk = plt.quiverkey(Q, 0.9, 0.9, 1, r'$1 frac{m}{s}$', labelpos='E',
                   coordinates='figure')
plt.scatter(X, Y, color='k', s=5)

plt.show()
Comment

PREVIOUS NEXT
Code Example
Python :: pythagore 
Python :: tkinter triangle 
Python :: pandas previous row 
Python :: install python cap 
Python :: pytube3 
Python :: how to move an item from one list to another python 
Python :: how to represent equation in pytho 
Python :: na in python 
Python :: first non repeating charcter in string ython 
Python :: min() and max() Function in python 
Python :: python subprocess no such file or directory 
Python :: python pandas change column order 
Python :: bytes to Image PIL PY 
Python :: python excel sheet 
Python :: x = 10 x += 12 y = x/4 x = x + y in python 
Python :: hwo to syntax in python 
Python :: import turtle t=turtle.turtle() def star(t): for t in range(5): t.color("red") t.pendown() t.begin_fill() t.forward(100) t.right(144) t.end_fill() 
Python :: david dobrik 
Python :: plant python documentation 
Python :: perchè il metodo reverse return none 
Python :: python openstreetmap multiple latitude 
Python :: compter des valeur consecutives en python 
Shell :: Pyperclip could not find a copy/paste mechanism for your system 
Shell :: docker delete all images 
Shell :: check react version 
Shell :: upgrade pandas version 
Shell :: update angular cli globally 
Shell :: command to install axios 
Shell :: find php.ini ubuntu 
Shell :: find my ip mac terminal 
ADD CONTENT
Topic
Content
Source link
Name
5+8 =