A.E*_*kie 2 python matplotlib python-2.7
有谁知道如何在图表下方的状态栏中修改“ x”和“ y”?
我想将其更改为“经度”和“纬度”,在matplotlib中可以吗?

您可以重新分配format_coord轴的方法,如以下示例所示(从此处和此处改编):
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()
Run Code Online (Sandbox Code Playgroud)
或者,在单行代码中,您可以使用一个lambda函数:
ax.format_coord = lambda x, y: "Longitude={:6.3f}, Latitude={:6.3f}".format(x,y)
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
989 次 |
| 最近记录: |