本文整理汇总了Python中pyqtgraph.PlotWidget.updateGL方法的典型用法代码示例。如果您正苦于以下问题:Python PlotWidget.updateGL方法的具体用法?Python PlotWidget.updateGL怎么用?Python PlotWidget.updateGL使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyqtgraph.PlotWidget
的用法示例。
在下文中一共展示了PlotWidget.updateGL方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from pyqtgraph import PlotWidget [as 别名]
# 或者: from pyqtgraph.PlotWidget import updateGL [as 别名]
#.........这里部分代码省略.........
""" Plot 1D histogram
The mode defines the way the data are presented,
'histogram' is displayed with steps
'function' with continuus line
'errorbar' with yerrorbars
The norm (normalization factor) and bin_size are given
for the display purposes only. The histogram is not altered.
"""
histo = plot.histogram
self._widget = PlotWidget(viewBox=self.vb)
plt = self._widget.plotItem
plt.setTitle(histo.title)
plt.plot(histo.x_axis, histo.weights)
self._widget.show()
# if plot.mode == 'histogram':
# current_plot.plot()
# win.show()
# app.processEvents()
def _repr_png_(self):
self._widget.hide()
QtGui.QApplication.processEvents()
try:
self.image = QImage(self._widget.viewRect().size().toSize(),
QImage.Format_RGB32)
except AttributeError:
self._widget.updateGL()
self.image = self._widget.grabFrameBuffer()
painter = QPainter(self.image)
self._widget.render(painter)
byte_array = QByteArray()
buffer = QBuffer(byte_array)
buffer.open(QIODevice.ReadWrite)
self.image.save(buffer, 'PNG')
buffer.close()
return bytes(byte_array)
def xlim(self, x_range):
"""
Set x range of plot preserving y limits.
"""
if x_range==None:
yar=self._widget.plotItem.getViewBox().autoRangeEnabled()[1]
if yar==False:
yr=self._widget.viewRange()[1]
else:
yr=None
# self._widget.plotItem.autoRange()
self._widget.plotItem.enableAutoRange()
self._widget.plotItem.setAutoVisible(x=True,y=True)
if yr!=None:
self._widget.plotItem.setRange(yRange=yr,padding=None)
return None
else:
if x_range[0]==None: