2

As read on here and here, they use format_coord to disable coordinates or change format from the toolbar. Using axe.format_coord = lambda x, y: '' as in the linked question, removed the coordinates, which is fine. However, I also want to disable the value of pixels: enter image description here

I then tried to use

axe.format_coord = lambda x, y,z:''

but that gave an error:

    s = event.inaxes.format_coord(event.xdata, event.ydata)
TypeError: <lambda>() takes exactly 3 arguments (2 given)

Please help me to fix it.

Community
  • 1
  • 1
Ivan
  • 1,069
  • 1
  • 9
  • 14

1 Answers1

1

In order to suppress any output in the status bar of the figure window, one may replace the figure toolbar's message method (NavigationToolbar2's .set_message) with a lambda function that returns an empty string:

fig.canvas.toolbar.set_message = lambda x: ""

Complete example:

import matplotlib.pyplot as plt
import numpy as np

fig, ax = plt.subplots()

ax.imshow(np.random.rand(5,5))
fig.canvas.toolbar.set_message = lambda x: ""

plt.show() 
ImportanceOfBeingErnest
  • 321,279
  • 53
  • 665
  • 712
  • I forget to mention that I was doing an GUI on Tkinter, tried your suggestion but wasn't working but then applied that to the toolbar widget with: `self.toolbar = NavigationToolbar2TkAgg(self.canvas, self.plot1_frame1) self.toolbar.set_message=lambda x:""` And works fine, thank you – Ivan Apr 19 '17 at 19:10