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()
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
The ax.fmt_xdata
attribute can be set to a function that formats the displayed string.
For example:
ax.fmt_xdata = lambda x: "{0:f}".format(x)
ax.fmt_ydata = lambda x: "{0:f}".format(x)
You can also completely override the default labeling by setting format_coord
ax.format_coord = lambda x, y: "({0:f}, ".format(y) + "{0:f})".format(x)
example, api doc
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With