I am trying to plot data on tkinter canvas using matplotlib "imshow()" function. When I am running the code the data is getting plotted onto the canvas and in the navigation toolbar pixel coordinates (x and y coordinates) are getting displayed along with pixel values (in bracket). Issue is I want to display only the pixel coordinates and hide pixel values which is getting displayed in the navigation toolbar.
The code which I am using is:
import tkinter
import numpy as np
from matplotlib.backends.backend_tkagg import (
FigureCanvasTkAgg, NavigationToolbar2Tk)
from matplotlib.figure import Figure
import matplotlib.pyplot as plt
import tkinter
import numpy as np
from matplotlib.backends.backend_tkagg import (
FigureCanvasTkAgg, NavigationToolbar2Tk)
from matplotlib.figure import Figure
import matplotlib.pyplot as plt
root = tkinter.Tk()
fig = Figure(figsize=(5, 4), dpi=100)
fig.subplots_adjust(bottom=0, right=1, top=1, left=0, wspace=0, hspace=0)
ax = fig.add_subplot(111)
class Formatter(object):
def __init__(self, im):
self.im = im
def __call__(self, x, y):
return 'x={:.01f}, y={:.01f}'.format(x, y)
data = np.random.random((10,10))
im = ax.imshow(data, interpolation='none')
ax.format_coord = Formatter(im)
plt.show()
canvas1 = FigureCanvasTkAgg(fig, master=root)
canvas1.draw()
toolbar = NavigationToolbar2Tk(canvas1,root)
toolbar.update()
toolbar.pack(side=tkinter.TOP, fill=tkinter.X, padx=8)
canvas1.get_tk_widget().pack(side=tkinter.TOP, fill=tkinter.BOTH, expand=1, padx=10, pady=5)
canvas1._tkcanvas.pack(side=tkinter.TOP, fill=tkinter.BOTH, expand=1, padx=10, pady=5)
root.mainloop()
Kindly suggest how to hide pixel values getting displayed in the navigation toolbar (inside brackets) and display only pixel coordinates (x & y coordinates).