我如何在Python中绘制这样的2D地图

2024-09-29 23:15:48 发布

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

Plot that I want to achieve using the data that I post here

我试图使用data attached here创建一个类似于图像的绘图,但是当我试图绘制网格数据时,我遇到了内存错误。在

我只能使用matplotlib中的scatter选项打印文件,如下例所示:

%matplotlib inline

import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
from scipy.interpolate import griddata

dffold = pd.read_csv('foldmap.toc', delimiter='\t',encoding='latin1',usecols=['Inline','Crossline','X','Y','Fold'])
x1 = np.array(dffold.X)
y1 = np.array(dffold.Y)
zf = np.array(dffold.Fold)
xi = np.linspace(min(x1), max(x1))
yi = np.linspace(min(y1), max(y1))
A, B = np.meshgrid(xi, yi, copy=False)
zi = griddata((x1, y1), zf , (xi, yi), method='nearest')
plt.scatter(x1,y1,zf)
plt.show()

Tags: importmatplotlibasnppltarraypdx1

热门问题