在Python中从坐标表绘制三维曲面

2024-05-23 17:18:12 发布

您现在位置:Python中文网/ 问答频道 /正文

我还没有找到答案:我在一个文本文件中定义了一个网格,它有四列:(lon,lat,depth,slip)。每行都是一个网格点。你知道吗

我可以使用以下简单代码生成这些点的散点图:

# Main imports:
import numpy as np
from pylab import *
from mpl_toolkits.mplot3d import Axes3D

# Read the grid:
points = np.loadtxt("grid.txt")

# Retrieve parameters from the grid:
lon = points[:,0]
lat = points[:,1]
depth = points[:,2]
slip = points[:,3]

# 3-D plot of the model:
fig = figure(1)
ax = fig.add_subplot(111, projection='3d')
p = ax.scatter(lon, lat, depth, c=slip, vmin=0, vmax=max(slip), s=30, edgecolor='none', marker='o')
fig.colorbar(p)
title("Published finite fault in 3-D")
ax.set_xlabel("Longitude [degrees]")
ax.set_ylabel("Latitude [degrees]")
ax.set_zlabel("Depth [km]")
ax.invert_zaxis()
jet()
grid()
show()

我得到如下图: Grid in 3-D. The color of each point represents the "slip" values. 我想做的是能够插值这些点,以创建一个“连续”的曲面网格,并在二维和三维绘图它。因此,我不得不考虑插值中的所有(lon,lat,depth,slip)。我很感激你的建议。提前谢谢!你知道吗


Tags: thefromimport网格npfigaxpoints