【问题标题】:Matplotlib: Data cubic interpolation (or FIT) for Contour plotMatplotlib:等高线图的数据三次插值(或 FIT)
【发布时间】:2013-08-26 11:26:58
【问题描述】:

我有一系列来自设备的数据。 我怎样才能为这个图进行三次插值或 FIT?

import matplotlib.pyplot as plt

a = [[1,1,1],[2,2,2],[3,3,3]]
b = [[1,2,3],[1,2,3],[1,2,3]]
c = [[3,2,1],[1,4,2],[4,5,1]]

fig1 = plt.figure()
ax1 = fig1.add_subplot(111)
fig1.set_size_inches(3.54,3.54)
#Create Contour plot
contour=ax1.contour(a,b,c)

plt.show()

【问题讨论】:

标签: python matplotlib scipy interpolation cubic


【解决方案1】:

您可以adapt @Joe Kington's suggestion 并使用scipy.ndimage.zoom,这非常适合您的三次插值:

import matplotlib.pyplot as plt
import numpy as np

from scipy.ndimage import zoom
from mpl_toolkits.mplot3d import axes3d

# Receive standard Matplotlib data for 3d plot
X, Y, Z = axes3d.get_test_data(1) # '1' is a step requested data

#Calculate smooth data
pw = 10 #power of the smooth
Xsm = zoom(X, pw)
Ysm = zoom(Y, pw)
Zsm = zoom(Z, pw)

# Create blank plot
fig = plt.figure()
#Create subplots
ax1 = fig.add_subplot(211)
ax2 = fig.add_subplot(212)
# Plotting
ax1.contour(X, Y, Z)
ax2.contour(Xsm, Ysm, Zsm)

plt.show()

这给出了:

【讨论】:

  • 对不起,这个脚本没有启动,但我找到了我的问题的答案! Tnx!
  • 你想用你必须做的修改来编辑我的答案吗?这对于下一个搜索这个问题的人来说会很好......
  • 当然!我添加了一个完美演示此技术的工作代码。 Tnx!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-09-09
  • 2012-03-25
  • 2011-12-24
  • 2022-08-19
相关资源
最近更新 更多