您可以在 matplotlib 中使用鼠标单击事件来轻松确定刻度的坐标,而不是猜测它。
import numpy as np
import matplotlib.pyplot as plt
def tell_click_coordinates(event):
print "X: %.0f, Y: %.0f" % (event.xdata, event.ydata)
fig = plt.figure("Ti Zr")
fig.canvas.mpl_connect("button_press_event", tell_click_coordinates)
ax = plt.subplot(111)
im = plt.imshow(np.flipud(plt.imread('14675002_in.png')),
origin='lower',
extent=[0, 800, 1000, 32700])
plt.xticks([10,15, 43, 95, 215,542,800])
plt.yticks([1000, 1860, 2670, 8600, 16600,32700])
plt.axis('normal')
plt.show()
单击一个后一个勾号将为您提供:
X: 6, Y: 1576
X: 6, Y: 6902
X: 10, Y: 13037
X: 8, Y: 20415
X: 11, Y: 26383
X: 76, Y: 2177
X: 260, Y: 1846
X: 494, Y: 1846
X: 594, Y: 1680
X: 715, Y: 1928
然后,您可以使用以下值调整绘图:
import numpy as np
import matplotlib.pyplot as plt
fig = plt.figure("Ti Zr")
ax = plt.subplot(111)
im = plt.imshow(np.flipud(plt.imread('14675002_in.png')),
origin='lower',
extent=[0, 800, 1000, 32700])
plt.xticks([76,260,494,594,715,800],[10,15, 43, 95, 215,542,800])
plt.yticks([1576,6902, 13037, 20415, 26383, 32700],[1000, 1860, 2670, 8600, 16600,32700])
plt.axis('normal')
plt.show()
你得到