本文整理汇总了Python中matplotlib.backends.backend_qt4.NavigationToolbar2QT.setFixedWidth方法的典型用法代码示例。如果您正苦于以下问题:Python NavigationToolbar2QT.setFixedWidth方法的具体用法?Python NavigationToolbar2QT.setFixedWidth怎么用?Python NavigationToolbar2QT.setFixedWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.backends.backend_qt4.NavigationToolbar2QT
的用法示例。
在下文中一共展示了NavigationToolbar2QT.setFixedWidth方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PlotWidget
# 需要导入模块: from matplotlib.backends.backend_qt4 import NavigationToolbar2QT [as 别名]
# 或者: from matplotlib.backends.backend_qt4.NavigationToolbar2QT import setFixedWidth [as 别名]
class PlotWidget(QtGui.QWidget):
"""This class represents the plot view for plotting graphs.
:returns: an instance of *PlotWidget*
"""
def __init__(self,):
QtGui.QWidget.__init__(self)
self.figure = Figure(facecolor=(1, 1, 1), tight_layout=True)
self.ax = self.figure.add_subplot(111)
# Canvas
self.canvas = FigureCanvas(self.figure)
self.canvas.setSizePolicy(QtGui.QSizePolicy.Expanding,
QtGui.QSizePolicy.Expanding)
self.canvas.updateGeometry()
# Navigation
self.navi_toolbar = NavigationToolbar(self.canvas, self)
self.navi_toolbar.setOrientation(QtCore.Qt.Vertical)
# Fixed with, otherwise navigation bar resize arbitrary
self.navi_toolbar.setFixedWidth(40)
self.vbl = QtGui.QHBoxLayout()
self.vbl.addWidget(self.navi_toolbar)
self.vbl.addWidget(self.canvas)
self.setLayout(self.vbl)
def plot(self, x_data_1, y_data_1, x_data_2, y_data_2):
"""Plot given data on *PlotWidget*.
:param x_data_1: X-axis data for plot 1
:type x_data_1: array_like
:param y_data_1: Y-axis data for plot 1
:type y_data_1: array_like
:param x_data_2: X-axis data for plot 2
:type x_data_2: array_like
:param y_data_2: Y-axis data for plot 2
:type y_data_2: array_like
"""
self.ax.clear()
self.ax.grid(True)
self.ax.plot(x_data_1, y_data_1, 'b^', label='Input Data')
self.ax.plot(x_data_2, y_data_2, 'b-', label='Fitted Data')
self.ax.legend()
self.canvas.draw()