2016-08-19 134 views
0

我想用下面描述的matplotlib创建一个热图。您可以从轴刻度中看到数据的间隔不均匀。 因此,假设我们有非均匀间隔数据的热图

x = [1, 1.5, 2, 2.5, 3, 3.5, 4, 5, 7] 
y = [.5, 1, 1.5, 2, 2.5, 3, 3.5, 4, 4.5] 
vals = np.random.rand(len(x), len(y)) 

如何这样的插值情节matplotlib产生的?

enter image description here

回答

1

你应该插入丢失的数据,我在我的项目之一使用下列内容:

#create regular grid 
xi, yi = np.linspace(x.min(), x.max(), 100), np.linspace(y.min(), y.max(), 100) 
xi, yi = np.meshgrid(xi, yi) 

#interpolate missing data 
rbf = scipy.interpolate.Rbf(x, y, z, function='linear') 
zi = rbf(xi, yi)