本文整理匯總了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()