0

I want to use mpld3's MousePosition plugin to display the pixel location of my cursor. This works great, but I can't figure out how to turn off scientific notation in the plugin. Pixels > 1000 are displayed in scientific notation.

My code:

import mpld3
from mpld3 import plugins
mpld3.enable_notebook()
fig, ax = plt.subplots()
cross = cv2.imread("cross.png", 0)
img = cv2.imread('frame_400.png', 0)
res = cv2.matchTemplate(img[2500:, :1200], cv2.resize(cross, (0,0), fx = 2, fy = 2), 3)
pylab.rcParams['figure.figsize'] = (10.0, 10.0)
imshow(res, origin='lower', cmap = cm.gray)
plugins.connect(fig, plugins.MousePosition(fontsize=14))
DanGoodrick
  • 2,818
  • 6
  • 28
  • 52

1 Answers1

0

There is a property for display format

plugins.connect(fig, plugins.MousePosition(fmt="f")) 

This will display the mouse position in integer format (a float with no decimal units of precision). fmt=".1f" will display the location with 1 decimal place of precision.

Ref: https://mpld3.github.io/_modules/mpld3/plugins.html

DanGoodrick
  • 2,818
  • 6
  • 28
  • 52