【发布时间】:2013-06-23 09:49:56
【问题描述】:
我正在尝试使用 mplot3d 模块在 3d 中绘制 2D 曲面图。
我知道如何“手动”找到最大值及其位置(就行和列而言),这对我正在做的事情非常重要。有没有办法将这些信息绘制到峰值上?也就是在峰值旁边写(maxval,row,col)?
附:当我问这个的时候。也许有一种简单的方法可以识别第二个峰值(或任何其他峰值?)。我目前正在使用掩码,以掩盖第一个峰并找到第二个峰,但我必须非常小心选择侧面,因为如果我碰巧掩盖的太少,一些非峰的东西会被识别出来作为一个峰值,真正的第二个峰值将不会被识别,从而扰乱了称为“峰峰值”信噪比的测量。
我目前使用的代码是:
frame_a = gdal.Open( "frame_{0:05d}.tif".format(274) ).ReadAsArray()
# in case this helps, this is how the images are read, they are 16-bit GS tiffs.
frame_b = gdal.Open( "frame_{0:05d}.tif".format(287) ).ReadAsArray()
#this does some clever stuff but basically it returns a 2-D 32x32 array.
corr = correlate_windows( windows_a[99], windows_b[99], corr_method = corr_method, nfftx=nfftx, nffty=nffty )
#this is how I find the position of max value.
column = np.argmax(np.max(corr, axis=0))
row = np.argmax(np.max(corr, axis=1))
maximum = corr.max()
print 'column = ' + str(column)
print 'row = ' +str(row)
print 'peak_1 = ' + str(maximum)
import matplotlib.cm as cmps
from mpl_toolkits.mplot3d import Axes3D
from matplotlib.ticker import LinearLocator, FormatStrFormatter
fig = pl.figure()
ax = Axes3D(fig)
# window size is 32 in this case
nx, ny = window_size*2, window_size*2
xx = range(nx)
yy = range(ny)
X, Y = np.meshgrid(xx, yy)
ax.plot_surface(X , Y , corr , rstride = 1, cstride = 1 )
pl.show()
【问题讨论】:
-
作为内务记录,您不能包含图片,除非您有更高的声誉并且有足够的代表您可以编辑其他帖子。
-
“松散对齐”是什么意思?你能在某个地方放第二张图片吗?您应该将问题的第二部分和第三部分分成各自的问题。理想的 SO 主题只有一个问题,这使得回答更容易,对未来的读者更有用。
-
感谢 cmets tcaswell !我编辑了这个问题。我认为我在问题的另一部分(现已删除)中寻找的实际上是固定情节上的“观点”(在上图中,您无法真正看到零在哪里)。我认为这应该很容易找到。
-
我没有时间写一个真正的答案,但我认为你可以用
annotate做你想做的事
标签: python-2.7 matplotlib max axes mplot3d