Increase significant digits in pyplot cursor

孤人 提交于 2020-12-26 11:00:54

问题


I have a function plotted using pyplot. When I move the cursor over the window, I can see the values for X and Y of the location of the cursor at the bottom-left of the window (display as, for example, x = 4.27567e+06 y = 6.98764e-09).

How can I change the number of significant digits of those values? I've tried playing with the axis settings and tick settings, but it doesn't seem to help.

As you can see in the example I gave above, right now the resolution is 6 significant digits, but I need resolution of 8 or more digits.

FYI, the array I am plotting has points separated by intervals much smaller than what I need to display, so that's not the issue.

Is there a command in matplotlib to do this?

Thanks.


回答1:


You can entirely customize the text that displays info about the cursor's current location:

ax = plt.gca()
ax.format_coord = lambda x,y: '%10d, %10d' % (x,y)


来源:https://stackoverflow.com/questions/31360360/increase-significant-digits-in-pyplot-cursor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!