有谁知道如何修改绘图下方状态栏中的“x”和“y”?
我想把它改成“经度”和“纬度”,在matplotlib中可以吗?
最佳答案
您可以重新分配轴的 format_coord
方法,如以下示例(改编自 here 和 here ):
import matplotlib.pyplot as plt
import numpy as np
fig,ax = plt.subplots(1)
ax.pcolormesh(np.random.rand(20,20))
def format_coord(x, y):
return 'Longitude={:6.3f}, Latitude={:6.3f}'.format(x, y)
ax.format_coord = format_coord
plt.show()
或者,在单行代码中,您可以使用 lambda
函数:
ax.format_coord = lambda x, y: "Longitude={:6.3f}, Latitude={:6.3f}".format(x,y)
关于python - 更改状态栏中坐标文本的格式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35750332/