私はこのコードを持って:
これは度Z後とx、yおよびz値を表示します。
あなたは簡単にそれを変更したり、関連する機能をコピーしてあなたの側で動作させることができるはずです。
あなたはすでにformat_coord
を試していたと言っていますが、機能を設定していないことがありますか? (最後から二番目のライン)
"""
Show how to modify the coordinate formatter to report the image "z"
value of the nearest pixel given x and y
"""
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.cm as cm
X = 10*np.random.rand(5, 3)
fig, ax = plt.subplots()
ax.imshow(X, cmap=cm.jet, interpolation='nearest')
numrows, numcols = X.shape
def format_coord(x, y):
col = int(x + 0.5)
row = int(y + 0.5)
if col >= 0 and col < numcols and row >= 0 and row < numrows:
#get z from your data, given x and y
z = X[row, col]
#this only leaves two decimal points for readability
[x,y,z]=map("{0:.2f}".format,[x,y,z])
#change return string of x,y and z to whatever you want
return 'x='+str(x)+', y='+str(y)+', z='+str(z)+" degrees"
else:
return 'x=%1.4f, y=%1.4f' % (x, y)
#Set the function as the one used for display
ax.format_coord = format_coord
plt.show()
出典
2016-03-27 07:29:38
JeD
奇妙なことは、通常、それはあなたがすでにそのための機能を持っている必要がありますので、でも、x、y座標を示し、」doesnのこと..です – JeD