I'm displaying an image using imshow
inside a tkinter GUI and I have added a NavigationToolbar2TkAgg
(python3.5). Very similarly to this question (check it out for visuals), I want to change the formatting of the coordinates and z values (in particular, all my z values are between 0-10000, so I want to write them out instead of using scientific notation).
For x and y this was pretty easy to do by changing the format_coord
handle, but I can't seem to find anything to change the final bit [xxx]
. I have tried format_cursor_data
, but doesn't seem to be it either.
Anyone know a solution?
It seems that the [z]
value is only shown for imshow
, not for regular plots.
Here goes a minimal code sample to reproduce the problem
import sys
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.figure import Figure
import tkinter as tk
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg,NavigationToolbar2TkAgg
top = tk.Tk()
fig = plt.figure()
plt.imshow(np.array([[0,1],[1,2]]))
ax = fig.gca()
ax.format_coord = lambda x,y: "x:%4u, y:%4u" % (x,y)
ax.format_cursor_data = lambda z: "Hello" % (z) # does nothing
canvas = FigureCanvasTkAgg(fig,master=top)
canvas.get_tk_widget().pack(side=tk.TOP, fill=tk.BOTH, expand=1)
canvas.show()
toolbar = NavigationToolbar2TkAgg(canvas, top)
toolbar.update()
top.mainloop()