pythonmatplotlibpyqt

Disable coordinates from the toolbar of a Matplotlib figure


I am working in a project using PyQt4 and Matplotlib libraries.I created a matplotlib figure and i added a toolbar.

Is there any way to disable the coordinates that are shown in it? I mean these:

enter image description here

I want to do this, because i am going to add some buttons in the toolbar and I need this space.

This is the code of the matplotlib figure:

class Figure(QMainWindow):
  def __init__(self):
    QMainWindow.__init__(self)

    self.linedit = SelectData(self)

    self.mainWidget = QWidget()
    self.setCentralWidget(self.mainWidget)

    layout = QVBoxLayout()
    self.mainWidget.setLayout(layout)

    self.figure_canvas = FigureCanvas(Figure())
    layout.addWidget(self.figure_canvas, 10)

    self.axes = self.figure_canvas.figure.add_subplot(211)
    self.axes.grid(False)

    #I added this toolbar
    self.navigation_toolbar = NavigationToolbar2(self.figure_canvas, self)
    self.addToolBar(Qt.TopToolBarArea, self.navigation_toolbar)

I am new in python, so i hope you can help me. Thank you for your answers.


Solution

  • You can reassign the axes format_coord to show anything you like (see, for example this answer or this answer).

    So to disable it altogether, you could set it to an empty string, like this:

    self.axes.format_coord = lambda x, y: ""