Trăn trường vector 3d

Trong bài viết này, tôi sẽ trình bày cách vẽ các trường vectơ bằng Matplotlib và cách thực hiện với Pyplot. Các ví dụ được đề cập ở đây được lấy từ một trong các khóa học Giải tích đại học [1]. Hãy bắt đầu. Tôi sẽ sử dụng gói run để vẽ các trường vectơ. Trong Matplotlib, chúng tôi gọi rung động để vẽ trường vectơ 2D ở dạng

ống rung [[X, Y], U, V, [C], **kw]

trong đó X và Y xác định vị trí mũi tên [tọa độ, U và V là hướng mũi tên và C đặt màu [tùy chọn]. Thông tin chi tiết có thể được tìm thấy trong các tài liệu Matplotlib chính thức

Hãy xem một ví dụ đơn giản. Trước tiên, chúng ta cần nhập gói Matplotlib

Bước thứ hai là xác định các điểm mà chúng ta muốn tính toán và vẽ đồ thị vectơ. Nếu chúng ta có một trường vectơ được định nghĩa là

F = xi+3yj

sau đó chúng ta có thể muốn trực quan hóa trường vectơ này quanh gốc tọa độ — điểm [0,0], đi từ phạm vi x [-5,5] và y — phạm vi [-5,5]. Vì vậy, đây sẽ là một hình vuông có kích thước 10 x 10 có gốc là tâm. Và chúng ta hãy tính toán các vectơ theo 100 điểm bên trong hình vuông này

Tiếp theo, chúng tôi sẽ cung cấp các giá trị cho u=x và v=3y, ví dụ của chúng tôi

Và bây giờ, chúng ta có thể vẽ đồ thị hàm vectơ này

Kết quả được thể hiện trong Hình 1

ví dụ 2. Tạo nhiều vectơ bằng phương thức quiver[]

Python3




# Vector origin location2

import numpy as np

import matplotlib.pyplot as plt

 

# Vector origin location8

# Vector origin location9= X1_______47 0matplotlib.pyplot as plt9 0matplotlib.pyplot as plt9X7X8

X9=0matplotlib.pyplot as plt7 0matplotlib.pyplot as plt9 0matplotlib.pyplot as plt9X7=7

 

import8

[0= matplotlib.pyplot as plt7[3[4[5[6[6numpy as np2 [9 [3[6[6numpy as np2matplotlib.pyplot as plt0

import05= import07_______94import09[6[6numpy as np2 [9 [3[6[6numpy as np2matplotlib.pyplot as plt0

 

import20

import21=import23matplotlib.pyplot as plt0

matplotlib.pyplot as plt1import26matplotlib.pyplot as plt0

 

import29

matplotlib.pyplot as plt6matplotlib.pyplot as plt7____132matplotlib.pyplot as plt9import32matplotlib.pyplot as plt0

 2______47import32matplotlib.pyplot as plt9import32matplotlib.pyplot as plt0

 

 9

# Vector origin location0

# Vector origin location1

đầu ra

ví dụ 3. Vẽ nhiều vectơ bằng phương thức streamplot[] trong mô-đun matplotlib

Python3




# Vector origin location2

import numpy as np

import matplotlib.pyplot as plt

 

import52

import07= import55matplotlib.pyplot as plt7 0matplotlib.pyplot as plt9 0matplotlib.pyplot as plt9import61matplotlib.pyplot as plt0

[3= import55_______47 0matplotlib.pyplot as plt9 0matplotlib.pyplot as plt9import61matplotlib.pyplot as plt0

 

# Vector origin location8

import75= import77

 

import79

import80= import82[9 numpy as np7matplotlib.pyplot as plt0[4import87[9numpy as np7matplotlib.pyplot as plt0[6[6numpy as np2 [9 import2[6[6numpy as np2matplotlib.pyplot as plt0matplotlib.pyplot as plt7 import82matplotlib.pyplot as plt7 numpy as np7matplotlib.pyplot as plt0[4import87matplotlib.pyplot as plt7numpy as np7matplotlib.pyplot as plt0[6[6numpy as np2 [9 import2[6[6numpy as np2matplotlib.pyplot as plt0

numpy as np19= import2[4import87[9numpy as np7_______40[6[6numpy as np2 [9 import2[6[6numpy as np2matplotlib.pyplot as plt0matplotlib.pyplot as plt7 import2[4import87matplotlib.pyplot as plt7numpy as np7matplotlib.pyplot as plt0[6[6 ___numpy as np2 [9 import2[6[6_____22__matplotlib.pyplot as plt0

 

numpy as np53

numpy as np54=numpy as np56X7matplotlib.pyplot as plt9X7=7

numpy as np61=numpy as np63numpy as np64=numpy as np66numpy as np67=numpy as np69matplotlib.pyplot as plt0

Chủ Đề