本文整理汇总了Python中silx.gui.plot.PlotWidget.addCurve方法的典型用法代码示例。如果您正苦于以下问题:Python PlotWidget.addCurve方法的具体用法?Python PlotWidget.addCurve怎么用?Python PlotWidget.addCurve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类silx.gui.plot.PlotWidget
的用法示例。
在下文中一共展示了PlotWidget.addCurve方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: addCurve
# 需要导入模块: from silx.gui.plot import PlotWidget [as 别名]
# 或者: from silx.gui.plot.PlotWidget import addCurve [as 别名]
def addCurve(self, *var, **kw):
if "replot" in kw:
if kw["replot"]:
kw["resetzoom"] = True
del kw["replot"]
result = PlotWidget.addCurve(self, *var, **kw)
allCurves = self.getAllCurves(just_legend=True)
if len(allCurves) == 1:
self.setActiveCurve(allCurves[0])
return result
示例2: TestSaveActionSaveCurvesAsSpec
# 需要导入模块: from silx.gui.plot import PlotWidget [as 别名]
# 或者: from silx.gui.plot.PlotWidget import addCurve [as 别名]
class TestSaveActionSaveCurvesAsSpec(unittest.TestCase):
def setUp(self):
self.plot = PlotWidget(backend='none')
self.saveAction = SaveAction(plot=self.plot)
self.tempdir = tempfile.mkdtemp()
self.out_fname = os.path.join(self.tempdir, "out.dat")
def tearDown(self):
os.unlink(self.out_fname)
os.rmdir(self.tempdir)
def testSaveMultipleCurvesAsSpec(self):
"""Test that labels are properly used."""
self.plot.setGraphXLabel("graph x label")
self.plot.setGraphYLabel("graph y label")
self.plot.addCurve([0, 1], [1, 2], "curve with labels",
xlabel="curve0 X", ylabel="curve0 Y")
self.plot.addCurve([-1, 3], [-6, 2], "curve with X label",
xlabel="curve1 X")
self.plot.addCurve([-2, 0], [8, 12], "curve with Y label",
ylabel="curve2 Y")
self.plot.addCurve([3, 1], [7, 6], "curve with no labels")
self.saveAction._saveCurves(self.plot,
self.out_fname,
SaveAction.DEFAULT_ALL_CURVES_FILTERS[0]) # "All curves as SpecFile (*.dat)"
with open(self.out_fname, "rb") as f:
file_content = f.read()
if hasattr(file_content, "decode"):
file_content = file_content.decode()
# case with all curve labels specified
self.assertIn("#S 1 curve0 Y", file_content)
self.assertIn("#L curve0 X curve0 Y", file_content)
# graph X&Y labels are used when no curve label is specified
self.assertIn("#S 2 graph y label", file_content)
self.assertIn("#L curve1 X graph y label", file_content)
self.assertIn("#S 3 curve2 Y", file_content)
self.assertIn("#L graph x label curve2 Y", file_content)
self.assertIn("#S 4 graph y label", file_content)
self.assertIn("#L graph x label graph y label", file_content)
示例3: ColormapDialog
# 需要导入模块: from silx.gui.plot import PlotWidget [as 别名]
# 或者: from silx.gui.plot.PlotWidget import addCurve [as 别名]
#.........这里部分代码省略.........
#vlayout.addWidget(hbox3)
vboxlimitslayout.addWidget(hbox3)
hlayout3.addStretch(10)
self.maxLabel = qt.QLabel(hbox3)
self.maxLabel.setText("Maximum")
hlayout3.addWidget(self.maxLabel)
hlayout3.addSpacing(5)
hlayout3.addStretch(1)
self.maxText = MyQLineEdit(hbox3)
self.maxText.setFixedWidth(150)
self.maxText.setAlignment(qt.Qt.AlignRight)
self.maxText.returnPressed[()].connect(self.maxTextChanged)
hlayout3.addWidget(self.maxText)
# Graph widget for color curve...
self.c = PlotWidget(self, backend=None)
self.c.setGraphXLabel("Data Values")
self.c.setInteractiveMode('select')
self.marge = (abs(self.dataMax) + abs(self.dataMin)) / 6.0
self.minmd = self.dataMin - self.marge
self.maxpd = self.dataMax + self.marge
self.c.setGraphXLimits(self.minmd, self.maxpd)
self.c.setGraphYLimits(-11.5, 11.5)
x = [self.minmd, self.dataMin, self.dataMax, self.maxpd]
y = [-10, -10, 10, 10 ]
self.c.addCurve(x, y,
legend="ConstrainedCurve",
color='black',
symbol='o',
linestyle='-')
self.markers = []
self.__x = x
self.__y = y
labelList = ["","Min", "Max", ""]
for i in range(4):
if i in [1, 2]:
draggable = True
color = "blue"
else:
draggable = False
color = "black"
#TODO symbol
legend = "%d" % i
self.c.addXMarker(x[i],
legend=legend,
text=labelList[i],
draggable=draggable,
color=color)
self.markers.append((legend, ""))
self.c.setMinimumSize(qt.QSize(250,200))
vlayout.addWidget(self.c)
self.c.sigPlotSignal.connect(self.chval)
# colormap window can not be resized
self.setFixedSize(vlayout.minimumSize())
示例4: PlotWidget
# 需要导入模块: from silx.gui.plot import PlotWidget [as 别名]
# 或者: from silx.gui.plot.PlotWidget import addCurve [as 别名]
return comment, "CENTER"
app = qt.QApplication([])
x = numpy.arange(1000)
# first widget has a standalone preview action with custom title and comment
pw1 = PlotWidget()
pw1.setWindowTitle("Widget 1 with standalone print preview")
toolbar1 = qt.QToolBar(pw1)
toolbutton1 = MyPrintPreviewButton(parent=toolbar1, plot=pw1)
pw1.addToolBar(toolbar1)
toolbar1.addWidget(toolbutton1)
pw1.show()
pw1.addCurve(x, numpy.tan(x * 2 * numpy.pi / 1000))
# next two plots share a common standard print preview
pw2 = PlotWidget()
pw2.setWindowTitle("Widget 2 with shared print preview")
toolbar2 = qt.QToolBar(pw2)
toolbutton2 = PrintPreviewToolButton.SingletonPrintPreviewToolButton(
parent=toolbar2, plot=pw2)
pw2.addToolBar(toolbar2)
toolbar2.addWidget(toolbutton2)
pw2.show()
pw2.addCurve(x, numpy.sin(x * 2 * numpy.pi / 1000))
pw3 = PlotWidget()
pw3.setWindowTitle("Widget 3 with shared print preview")
示例5: BackgroundWidget
# 需要导入模块: from silx.gui.plot import PlotWidget [as 别名]
# 或者: from silx.gui.plot.PlotWidget import addCurve [as 别名]
#.........这里部分代码省略.........
:param dict ddict: Input dictionary, must have the same
keys as the dictionary output by :meth:`getParameters`
"""
return self.parametersWidget.setParameters(ddict)
def setData(self, x, y, xmin=None, xmax=None):
"""Set data for the original curve, and _update strip and snip
curves accordingly.
:param x: Array or sequence of curve abscissa values
:param y: Array or sequence of curve ordinate values
:param xmin: Min value to be displayed on the X axis
:param xmax: Max value to be displayed on the X axis
"""
self._x = x
self._y = y
self._xmin = xmin
self._xmax = xmax
self._update(resetzoom=True)
def _slot(self, ddict):
self._update()
def _update(self, resetzoom=False):
"""Compute strip and snip backgrounds, update the curves
"""
if self._y is None:
return
pars = self.getParameters()
# smoothed data
y = numpy.ravel(numpy.array(self._y)).astype(numpy.float)
if pars["SmoothingFlag"]:
ysmooth = filters.savitsky_golay(y, pars['SmoothingWidth'])
f = [0.25, 0.5, 0.25]
ysmooth[1:-1] = numpy.convolve(ysmooth, f, mode=0)
ysmooth[0] = 0.5 * (ysmooth[0] + ysmooth[1])
ysmooth[-1] = 0.5 * (ysmooth[-1] + ysmooth[-2])
else:
ysmooth = y
# loop for anchors
x = self._x
niter = pars['StripIterations']
anchors_indices = []
if pars['AnchorsFlag'] and pars['AnchorsList'] is not None:
ravelled = x
for channel in pars['AnchorsList']:
if channel <= ravelled[0]:
continue
index = numpy.nonzero(ravelled >= channel)[0]
if len(index):
index = min(index)
if index > 0:
anchors_indices.append(index)
stripBackground = filters.strip(ysmooth,
w=pars['StripWidth'],
niterations=niter,
factor=pars['StripThreshold'],
anchors=anchors_indices)
if niter >= 1000:
# final smoothing
stripBackground = filters.strip(stripBackground,
w=1,
niterations=50*pars['StripWidth'],
factor=pars['StripThreshold'],
anchors=anchors_indices)
if len(anchors_indices) == 0:
anchors_indices = [0, len(ysmooth)-1]
anchors_indices.sort()
snipBackground = 0.0 * ysmooth
lastAnchor = 0
for anchor in anchors_indices:
if (anchor > lastAnchor) and (anchor < len(ysmooth)):
snipBackground[lastAnchor:anchor] =\
filters.snip1d(ysmooth[lastAnchor:anchor],
pars['SnipWidth'])
lastAnchor = anchor
if lastAnchor < len(ysmooth):
snipBackground[lastAnchor:] =\
filters.snip1d(ysmooth[lastAnchor:],
pars['SnipWidth'])
self.graphWidget.addCurve(x, y,
legend='Input Data',
replace=True,
resetzoom=resetzoom)
self.graphWidget.addCurve(x, stripBackground,
legend='Strip Background',
resetzoom=False)
self.graphWidget.addCurve(x, snipBackground,
legend='SNIP Background',
resetzoom=False)
if self._xmin is not None and self._xmax is not None:
self.graphWidget.getXAxis().setLimits(self._xmin, self._xmax)