从 Matplotlib 图形的工具栏中禁用坐标 [英] Disable coordinates from the toolbar of a Matplotlib figure
问题描述
我在一个使用 PyQt4 和 Matplotlib 库的项目中工作.我创建了一个 matplotlib 图并添加了一个工具栏.
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:
我想这样做,因为我要在工具栏中添加一些按钮,并且我需要这个空间.
I want to do this, because i am going to add some buttons in the toolbar and I need this space.
这是matplotlib图的代码:
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)
我是python的新手,所以希望您能为我提供帮助.谢谢您的回答.
I am new in python, so i hope you can help me. Thank you for your answers.
推荐答案
您可以重新分配坐标轴 format_coord
以显示您喜欢的任何内容(例如,参见此答案 或 这个答案).
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: ""
这篇关于从 Matplotlib 图形的工具栏中禁用坐标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!