本文整理汇总了Python中pyqtgraph.PlotWidget.setImage方法的典型用法代码示例。如果您正苦于以下问题:Python PlotWidget.setImage方法的具体用法?Python PlotWidget.setImage怎么用?Python PlotWidget.setImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyqtgraph.PlotWidget
的用法示例。
在下文中一共展示了PlotWidget.setImage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from pyqtgraph import PlotWidget [as 别名]
# 或者: from pyqtgraph.PlotWidget import setImage [as 别名]
#.........这里部分代码省略.........
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:
x_range[0]=0
if x_range[1]==None:
self._widget.plotItem.setAutoVisible(x=True,y=False)
xr=self._widget.viewRange()[0]
x_range[1]=xr[1]
self._widget.plotItem.setXRange(x_range[0],x_range[1])
self._widget.plotItem.setAutoVisible(x=False,y=True)
def ylim(self, y_range):
"""
Set y range of plot preserving x limits.
"""
if y_range==None:
xar=self._widget.plotItem.getViewBox().autoRangeEnabled()[0]
if xar==False:
xr=self._widget.viewRange()[0]
else:
xr=None
self._widget.plotItem.enableAutoRange()
self._widget.plotItem.setAutoVisible(x=True,y=True)
if xr!=None:
self._widget.plotItem.setRange(xRange=xr,padding=None)
return None
else:
if y_range[0]==None:
y_range[0]=0
if y_range[1]==None:
self._widget.plotItem.setAutoVisible(y=True,x=False)
yr=self._widget.viewRange()[1]
y_range[1]=yr[1]
self._widget.plotItem.setYRange(y_range[0],y_range[1])
self._widget.plotItem.setAutoVisible(y=False,x=True)
# def plot1d_4panel(self, plot, ranges):
"""
Special 1D histogram plot. The plot is broken into 4 panels (stacked verically)
the ranges variable should be given in a (x0, x1, x2, x3, x4) format, where
xi defines the ranges of the subplots (x0-x1, x1-x2, x2-x3, x3-x4)
"""
def plot2d(self, plot, xc=None, yc=None, logz=False):
"""Plot 2D histogram
xc is x range, yc is y range
"""
if plot.histogram.dim != 2:
raise GeneralError('plot2d function needs a 2D histogram!')
x = plot.histogram.x_axis
y = plot.histogram.y_axis
w = plot.histogram.weights
if xc is not None:
x = x[xc[0]:xc[1]]
w = w[xc[0]:xc[1],:]
if yc is not None:
y = y[yc[0]:yc[1]]
w = w[:, yc[0]:yc[1]]
title = plot.histogram.title
# If logaritmic scale is used, mask values <= 0
if logz:
w = numpy.ma.masked_where(w <= 0, numpy.log10(w))
title += ' (log10)'
self._widget = pg.ImageView(view=pg.PlotItem(title=title))
gv = self._widget.getView()
gv.invertY(False)
self._widget.setImage(w,pos=[x[0]-0.5,y[0]-0.5])
self._widget.show()