Python 用matplotlib绘制二维标量速度场

Python 用matplotlib绘制二维标量速度场,python,pandas,numpy,matplotlib,Python,Pandas,Numpy,Matplotlib,我有下面的数据框,我正试图绘制 x,y,u,v -0.157806993154554,-0.05,0.000601310515776,0.003318849951029 -0.374687807296859,-0.35,-0.001057069515809,2.9686838388443E-05 -1,-0.323693574077183,-0.002539682900533,-0.008748378604651 -0.486242955499287,-0.35,-0.0017976944800

我有下面的数据框,我正试图绘制

x,y,u,v
-0.157806993154554,-0.05,0.000601310515776,0.003318849951029
-0.374687807296859,-0.35,-0.001057069515809,2.9686838388443E-05
-1,-0.323693574077183,-0.002539682900533,-0.008748378604651
-0.486242955499287,-0.35,-0.001797694480047,0.000218112021685
-0.54184300562917,-0.05,0.001513708615676,0.001884449273348
0,-0.31108016382718,5.28732780367136E-05,-0.000818025320768
-0.428046308037431,-0.35,-0.001458290731534,8.22432339191437E-05
-0.343159653530217,-0.05,0.00112508633174,0.002580288797617
-0.386254219645565,-0.35,-0.001139726256952,2.6945024728775E-05
-0.600252053226546,-0.05,0.001246933126822,0.00207519903779
-1,-0.061575842243108,-0.000705834245309,0.043682213872671
0,-0.052056831172645,0.009899478405714,-0.003894355148077
-0.903283837058102,-0.35,5.81557396799326E-05,-0.001065131276846
-0.418202966058798,-0.05,0.001158628845587,0.002409461885691
-0.809266339501268,-0.35,0.000290673458949,-2.0977109670639E-05
0,-0.066616962597653,2.92772892862558E-05,0.001737955957651
-0.090282152608,-0.35,0.00151876010932,0.001403901726007
-1,-0.173440678035212,-0.007741978392005,0.006023477762938
-1,-0.155079864747918,-0.00761691480875,0.007886063307524
-0.222728396757266,-0.35,0.000686463201419,0.000264558941126
其中u、v和x、y是位置坐标和该点的速度矢量。(完整数据集-)

我想这样绘制我的数据(不需要等高线和箭头)

我该怎么做

到目前为止,我已经尝试:

import numpy as np
import matplotlib.pyplot as plt
  
# Meshgrid
#x, y = np.meshgrid(box_df['x'], box_df['y'])
x,y = box_df['x'], box_df['y']
  
# Directional vectors

#u, v = np.meshgrid(box_df['u'], box_df['v'])
u = box_df['u']
v = box_df['v']
  
# Plotting Vector Field with QUIVER
plt.quiver(x, y, u, v, color='g')
plt.title('Vector Field')
  
  
# Show plot with gird
plt.grid()

如果要绘制带有不规则数据点的标量场,可以使用和
tricontourf
进行插值以填充

使用
tricontour
您可以尝试:

将numpy导入为np
将matplotlib.pyplot作为plt导入
x、 y=box_df.x,box_df.y
#生成标量场
速度=np.hypot(方盒方向图,方盒方向图)
#用三角图绘制标量场
plt.tricontourf(x、y、速度)
plt.title('标量字段')
#用网格显示绘图
plt.grid()

但是,似乎只有矩形边缘周围的数据,因此矩形内部的插值可能很差


谢谢,看起来我的数据导出方式不太正确