本文整理汇总了Python中matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg.width方法的典型用法代码示例。如果您正苦于以下问题:Python FigureCanvasQTAgg.width方法的具体用法?Python FigureCanvasQTAgg.width怎么用?Python FigureCanvasQTAgg.width使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg
的用法示例。
在下文中一共展示了FigureCanvasQTAgg.width方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PerformanceResultsAnalysisWidget
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import width [as 别名]
#.........这里部分代码省略.........
self.load_button = QtGui.QPushButton("&Load")
self.connect(self.load_button, QtCore.SIGNAL('clicked()'),
self._reload) #self._load_results_collection_from_file)
self.draw_button = QtGui.QPushButton("&Draw or Toggle")
self.connect(self.draw_button, QtCore.SIGNAL('clicked()'),
self._draw_plot)
self.hist_button = QtGui.QPushButton("&Histogram")
self.connect(self.hist_button, QtCore.SIGNAL('clicked()'),
self._draw_histogram)
self.project_button = QtGui.QPushButton("&Filter")
self.connect(self.project_button, QtCore.SIGNAL('clicked()'),
self._project_popup)
self.save_button = QtGui.QPushButton("&Save")
self.connect(self.save_button, QtCore.SIGNAL('clicked()'), self._save)
self.reset_button = QtGui.QPushButton("&Reset")
self.connect(self.reset_button, QtCore.SIGNAL('clicked()'), self._reset)
# Create matplotlib canvas
self.fig = Figure((12.0, 8.0), dpi=100)
self.canvas = FigureCanvas(self.fig)
self.canvas.setParent(self)
# Create axes for plot
self.axes = self.fig.add_subplot(111)
# Text showing projection parameters
self.project_params_label = QtGui.QLabel("No filtering.")
self.project_params_label.setWordWrap(1)
self.project_params_label.setFixedWidth(self.canvas.width())
# Create layout of widget
vlayout1 = QtGui.QVBoxLayout()
hlayout1 = QtGui.QHBoxLayout()
vlayout2 = QtGui.QVBoxLayout()
vlayout2.addWidget(self.variables_view)
vlayout2.addWidget(self.metrics_view)
vlayout2.addWidget(self.fpcost_label)
vlayout2.addWidget(self.fpcost_line_edit)
vlayout2.addWidget(self.fncost_label)
vlayout2.addWidget(self.fncost_line_edit)
hlayout1.addLayout(vlayout2)
hlayout1.addWidget(self.canvas)
vlayout1.addLayout(hlayout1)
hlayout2 = QtGui.QHBoxLayout()
hlayout2.addWidget(self.load_button)
hlayout2.addWidget(self.draw_button)
hlayout2.addWidget(self.hist_button)
hlayout2.addWidget(self.project_button)
hlayout2.addWidget(self.save_button)
hlayout2.addWidget(self.reset_button)
vlayout1.addWidget(self.project_params_label)
vlayout1.addLayout(hlayout2)
self.setLayout(vlayout1)
def _project_onto(self, selected_variable, selected_values):
""" Project onto the data where selected_variable has the values selected_values."""
self.current_collection = \
self.current_collection.project_onto(selected_variable,
示例2: StatsDialog
# 需要导入模块: from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg [as 别名]
# 或者: from matplotlib.backends.backend_qt4agg.FigureCanvasQTAgg import width [as 别名]
class StatsDialog(QDialog):
def __init__(self, standalone=True):
QDialog.__init__(self)
self.setWindowIcon(QIcon("img/32x32/view-statistics.png"))
self.setWindowTitle("Statistics")
layout = QVBoxLayout()
self.canvas_width = 0
self.canvas_height = 0
self.canvas = None
self.standalone = standalone
self.page = 0
self.len_page = 100
self.fig = None
self.tabs = QTabWidget()
self.stats_image = QWidget()
self.tabs.addTab(self.stats_image, QIcon("img/32x32/view-investment.png"), "Statistics")
self.list_container = QWidget()
list_layout = QVBoxLayout()
self.list_pager = QWidget()
pager_layout = QHBoxLayout()
self.page_num_label = QLabel()
first_button = QPushButton(QIcon.fromTheme("arrow-left-double", QIcon.fromTheme("go-first")), "")
prev_button = QPushButton(QIcon.fromTheme("arrow-left", QIcon.fromTheme("go-previous")), "")
next_button = QPushButton(QIcon.fromTheme("arrow-right", QIcon.fromTheme("go-next")), "")
last_button = QPushButton(QIcon.fromTheme("arrow-right-double", QIcon.fromTheme("go-last")), "")
self.connect(prev_button, SIGNAL("clicked()"), self.prev_page)
self.connect(next_button, SIGNAL("clicked()"), self.next_page)
self.connect(first_button, SIGNAL("clicked()"), self.first_page)
self.connect(last_button, SIGNAL("clicked()"), self.last_page)
pager_layout.addStretch()
pager_layout.addWidget(first_button)
pager_layout.addWidget(prev_button)
pager_layout.addWidget(self.page_num_label)
pager_layout.addWidget(next_button)
pager_layout.addWidget(last_button)
pager_layout.addStretch()
self.list_widget = QTableWidget()
self.list_widget.insertColumn(0)
self.list_widget.insertColumn(0)
self.list_widget.insertColumn(0)
self.list_widget.setColumnWidth(0, 150)
self.list_widget.setColumnWidth(2, 150)
self.list_widget.setHorizontalHeaderItem(0, QTableWidgetItem("Name"))
self.list_widget.setHorizontalHeaderItem(1, QTableWidgetItem("Price"))
self.list_widget.setHorizontalHeaderItem(2, QTableWidgetItem("Time/Date"))
self.list_pager.setLayout(pager_layout)
list_layout.addWidget(self.list_pager)
list_layout.addWidget(self.list_widget)
self.list_container.setLayout(list_layout)
self.tabs.addTab(self.list_container, QIcon("img/32x32/view-income-categories.png"), "List")
layout.addWidget(self.tabs)
if self.standalone:
button_box = QDialogButtonBox()
ok_button = button_box.addButton(button_box.Ok)
self.connect(ok_button, SIGNAL("clicked()"), self.ok_clicked)
layout.addWidget(button_box)
self.setLayout(layout)
def update(self, transactions):
self.transactions = transactions
self.page = 0
self.update_list(self.transactions)
fig = renderPlot(self.transactions)
if self.canvas:
self.canvas.setParent(None)
self.canvas.destroy()
try:
self.canvas = FigureCanvasQTAgg(fig)
self.hide()
self.canvas.setParent(self.stats_image)
self.show()
self.resize(self.canvas.width(), self.canvas.height() + 100)
except AttributeError:
# pass if there are still no transactions
pass
def update_list(self, transactions):
self.transactions = transactions
self.list_widget.clear()
self.list_widget.setRowCount(0)
reverse_transactions = transactions.reverse()
self.page_num_label.setText(str(self.page + 1) + "/" + str(len(transactions) / self.len_page + 1))
for idx, transaction in enumerate(transactions[self.page * self.len_page : (self.page + 1) * self.len_page]):
self.list_widget.insertRow(idx)
self.list_widget.setCellWidget(idx, 0, QLabel(transaction.customer.name))
self.list_widget.setCellWidget(idx, 1, QLabel(str(transaction.price) + u" \u20AC"))
self.list_widget.setCellWidget(idx, 2, QLabel(transaction.time.strftime("%H:%M:%S, %d.%m.%Y")))
def first_page(self):
if self.page != 0:
self.page = 0
self.update_list(self.transactions)
def prev_page(self):
if self.page > 0:
self.page -= 1
#.........这里部分代码省略.........