matplotlib坐标格式 [英] matplotlib coordinates format

查看:138
本文介绍了matplotlib坐标格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个简单的图,像这样:

I have simple plot like this:

matplotlib.pyplot as plt

pt_no = [1,2,3]
coord_x = [6035763.111, 6035765.251, 6035762.801]
coord_y = [6439524.100, 6439522.251, 6439518.298]

fig, ax = plt.subplots()
ax.scatter(coord_y, coord_x, marker='x')
ax.axes.get_xaxis().set_visible(False)
ax.axes.get_yaxis().set_visible(False)
for i, txt in enumerate(pt_no):
    ax.annotate(txt, (coord_y[i], coord_x[i]))

plt.show()

但是当您在图形上移动或按住光标时,绘图窗口的底部右角显示的坐标看起来像6.43953 e + 06.

如何完全按原样显示输入坐标,例如

6439518.298而不是6.43953e + 0




预先感谢

but coordinates displayed in bootom-right corner of plot window as you move or hold cursor over the figure look like 6.43953e + 06.
How can I have my input coordinates displayed exactly as-is, for example
6439518.298 instead 6.43953e + 0
?
Thanks in advance

推荐答案

ax.fmt_xdata 属性设置为格式化显示的字符串的函数。

The ax.fmt_xdata attribute can be set to a function that formats the displayed string.

F或示例:

ax.fmt_xdata = lambda x: "{0:f}".format(x)
ax.fmt_ydata = lambda x: "{0:f}".format(x)

这篇关于matplotlib坐标格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆