2024-04-23 20:34:26 发布
网友
有人知道如何修改绘图下方状态栏中的“x”和“y”吗?在
我想把它改成“经度”和“纬度”,在matplotlib中可以吗?在
可以重新指定轴的format_coord方法,如下例所示(改编自here和here):
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()
或者,在一行代码中,您可以使用lambda函数:
lambda
可以重新指定轴的
format_coord
方法,如下例所示(改编自here和here):或者,在一行代码中,您可以使用
^{pr2}$lambda
函数:相关问题 更多 >
编程相关推荐