本文整理汇总了Python中silx.gui.plot.PlotWindow.clear方法的典型用法代码示例。如果您正苦于以下问题:Python PlotWindow.clear方法的具体用法?Python PlotWindow.clear怎么用?Python PlotWindow.clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类silx.gui.plot.PlotWindow
的用法示例。
在下文中一共展示了PlotWindow.clear方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: SimpleFitGui
# 需要导入模块: from silx.gui.plot import PlotWindow [as 别名]
# 或者: from silx.gui.plot.PlotWindow import clear [as 别名]
#.........这里部分代码省略.........
if fname in [None, "None", "NONE"]:
idx = 0
else:
idx = newConfig['fit']['functions'].index(fname) + 1
self.topWidget.fitFunctionCombo.setCurrentIndex(idx)
fname = self.fitModule.getBackgroundFunction()
if fname in [None, "None", "NONE"]:
idx = 0
else:
idx = newConfig['fit']['functions'].index(fname) + 1
idx = self.topWidget.backgroundCombo.findText(fname)
self.topWidget.backgroundCombo.setCurrentIndex(idx)
_logger.debug("TABLE TO BE CLEANED")
#self.estimate()
def setFitFunction(self, fname):
current = self.fitModule.getFitFunction()
if current != fname:
self.fitModule.setFitFunction(fname)
idx = self.topWidget.fitFunctionCombo.findText(fname)
self.topWidget.fitFunctionCombo.setCurrentIndex(idx)
def setBackgroundFunction(self, fname):
current = self.fitModule.getBackgroundFunction()
if current != fname:
self.fitModule.setBackgroundFunction(fname)
idx = self.topWidget.backgroundCombo.findText(fname)
self.topWidget.backgroundCombo.setCurrentIndex(idx)
def setData(self, *var, **kw):
returnValue = self.fitModule.setData(*var, **kw)
if self.__useTab:
if hasattr(self.graph, "addCurve"):
self.graph.clear()
self.graph.addCurve(self.fitModule._x,
self.fitModule._y,
legend='Data')
self.graph.setActiveCurve('Data')
elif hasattr(self.graph, "newCurve"):
# TODO: remove if not used
self.graph.clearCurves()
self.graph.newCurve('Data',
self.fitModule._x,
self.fitModule._y)
self.graph.replot()
return returnValue
def estimate(self):
self.setStatus("Estimate started")
self.statusWidget.chi2Line.setText("")
try:
x = self.fitModule._x
y = self.fitModule._y
self.graph.clear()
self.graph.addCurve(x, y, 'Data')
self.graph.setActiveCurve('Data')
self.fitModule.estimate()
self.setStatus()
self.parametersTable.fillTableFromFit(self.fitModule.paramlist)
except:
if _logger.getEffectiveLevel() == logging.DEBUG:
raise
text = "%s:%s" % (sys.exc_info()[0], sys.exc_info()[1])
msg = qt.QMessageBox(self)
msg.setIcon(qt.QMessageBox.Critical)
msg.setText(text)
示例2: TestCurveLegendsWidget
# 需要导入模块: from silx.gui.plot import PlotWindow [as 别名]
# 或者: from silx.gui.plot.PlotWindow import clear [as 别名]
class TestCurveLegendsWidget(TestCaseQt, ParametricTestCase):
"""Tests for CurveLegendsWidget class"""
def setUp(self):
super(TestCurveLegendsWidget, self).setUp()
self.plot = PlotWindow()
self.legends = CurveLegendsWidget.CurveLegendsWidget()
self.legends.setPlotWidget(self.plot)
dock = qt.QDockWidget()
dock.setWindowTitle('Curve Legends')
dock.setWidget(self.legends)
self.plot.addTabbedDockWidget(dock)
self.plot.show()
self.qWaitForWindowExposed(self.plot)
def tearDown(self):
del self.legends
self.qapp.processEvents()
self.plot.setAttribute(qt.Qt.WA_DeleteOnClose)
self.plot.close()
del self.plot
super(TestCurveLegendsWidget, self).tearDown()
def _assertNbLegends(self, count):
"""Check the number of legends in the CurveLegendsWidget"""
children = self.legends.findChildren(CurveLegendsWidget._LegendWidget)
self.assertEqual(len(children), count)
def testAddRemoveCurves(self):
"""Test CurveLegendsWidget while adding/removing curves"""
self.plot.addCurve((0, 1), (1, 2), legend='a')
self._assertNbLegends(1)
self.plot.addCurve((0, 1), (2, 3), legend='b')
self._assertNbLegends(2)
# Detached/attach
self.legends.setPlotWidget(None)
self._assertNbLegends(0)
self.legends.setPlotWidget(self.plot)
self._assertNbLegends(2)
self.plot.clear()
self._assertNbLegends(0)
def testUpdateCurves(self):
"""Test CurveLegendsWidget while updating curves """
self.plot.addCurve((0, 1), (1, 2), legend='a')
self._assertNbLegends(1)
self.plot.addCurve((0, 1), (2, 3), legend='b')
self._assertNbLegends(2)
# Activate curve
self.plot.setActiveCurve('a')
self.qapp.processEvents()
self.plot.setActiveCurve('b')
self.qapp.processEvents()
# Change curve style
curve = self.plot.getCurve('a')
curve.setLineWidth(2)
for linestyle in (':', '', '--', '-'):
with self.subTest(linestyle=linestyle):
curve.setLineStyle(linestyle)
self.qapp.processEvents()
self.qWait(1000)
for symbol in ('o', 'd', '', 's'):
with self.subTest(symbol=symbol):
curve.setSymbol(symbol)
self.qapp.processEvents()
self.qWait(1000)
示例3: TestProfileToolBar
# 需要导入模块: from silx.gui.plot import PlotWindow [as 别名]
# 或者: from silx.gui.plot.PlotWindow import clear [as 别名]
class TestProfileToolBar(TestCaseQt, ParametricTestCase):
"""Tests for ProfileToolBar widget."""
def setUp(self):
super(TestProfileToolBar, self).setUp()
profileWindow = PlotWindow()
self.plot = PlotWindow()
self.toolBar = Profile.ProfileToolBar(
plot=self.plot, profileWindow=profileWindow)
self.plot.addToolBar(self.toolBar)
self.plot.show()
self.qWaitForWindowExposed(self.plot)
profileWindow.show()
self.qWaitForWindowExposed(profileWindow)
self.mouseMove(self.plot) # Move to center
self.qapp.processEvents()
def tearDown(self):
self.qapp.processEvents()
self.plot.setAttribute(qt.Qt.WA_DeleteOnClose)
self.plot.close()
del self.plot
del self.toolBar
super(TestProfileToolBar, self).tearDown()
def testAlignedProfile(self):
"""Test horizontal and vertical profile, without and with image"""
# Use Plot backend widget to submit mouse events
widget = self.plot.getWidgetHandle()
for method in ('sum', 'mean'):
with self.subTest(method=method):
# 2 positions to use for mouse events
pos1 = widget.width() * 0.4, widget.height() * 0.4
pos2 = widget.width() * 0.6, widget.height() * 0.6
for action in (self.toolBar.hLineAction, self.toolBar.vLineAction):
with self.subTest(mode=action.text()):
# Trigger tool button for mode
toolButton = getQToolButtonFromAction(action)
self.assertIsNot(toolButton, None)
self.mouseMove(toolButton)
self.mouseClick(toolButton, qt.Qt.LeftButton)
# Without image
self.mouseMove(widget, pos=pos1)
self.mouseClick(widget, qt.Qt.LeftButton, pos=pos1)
# with image
self.plot.addImage(
numpy.arange(100 * 100).reshape(100, -1))
self.mousePress(widget, qt.Qt.LeftButton, pos=pos1)
self.mouseMove(widget, pos=pos2)
self.mouseRelease(widget, qt.Qt.LeftButton, pos=pos2)
self.mouseMove(widget)
self.mouseClick(widget, qt.Qt.LeftButton)
def testDiagonalProfile(self):
"""Test diagonal profile, without and with image"""
# Use Plot backend widget to submit mouse events
widget = self.plot.getWidgetHandle()
for method in ('sum', 'mean'):
with self.subTest(method=method):
self.toolBar.setProfileMethod(method)
# 2 positions to use for mouse events
pos1 = widget.width() * 0.4, widget.height() * 0.4
pos2 = widget.width() * 0.6, widget.height() * 0.6
for image in (False, True):
with self.subTest(image=image):
if image:
self.plot.addImage(
numpy.arange(100 * 100).reshape(100, -1))
# Trigger tool button for diagonal profile mode
toolButton = getQToolButtonFromAction(
self.toolBar.lineAction)
self.assertIsNot(toolButton, None)
self.mouseMove(toolButton)
self.mouseClick(toolButton, qt.Qt.LeftButton)
self.toolBar.lineWidthSpinBox.setValue(3)
# draw profile line
self.mouseMove(widget, pos=pos1)
self.mousePress(widget, qt.Qt.LeftButton, pos=pos1)
self.mouseMove(widget, pos=pos2)
self.mouseRelease(widget, qt.Qt.LeftButton, pos=pos2)
if image is True:
profileCurve = self.toolBar.getProfilePlot().getAllCurves()[0]
if method == 'sum':
self.assertTrue(profileCurve.getData()[1].max() > 10000)
elif method == 'mean':
self.assertTrue(profileCurve.getData()[1].max() < 10000)
self.plot.clear()
示例4: TestScatterProfileToolBar
# 需要导入模块: from silx.gui.plot import PlotWindow [as 别名]
# 或者: from silx.gui.plot.PlotWindow import clear [as 别名]
class TestScatterProfileToolBar(TestCaseQt, ParametricTestCase):
"""Tests for ScatterProfileToolBar class"""
def setUp(self):
super(TestScatterProfileToolBar, self).setUp()
self.plot = PlotWindow()
self.profile = profile.ScatterProfileToolBar(plot=self.plot)
self.plot.addToolBar(self.profile)
self.plot.show()
self.qWaitForWindowExposed(self.plot)
def tearDown(self):
del self.profile
self.qapp.processEvents()
self.plot.setAttribute(qt.Qt.WA_DeleteOnClose)
self.plot.close()
del self.plot
super(TestScatterProfileToolBar, self).tearDown()
def testNoProfile(self):
"""Test ScatterProfileToolBar without profile"""
self.assertEqual(self.profile.getPlotWidget(), self.plot)
# Add a scatter plot
self.plot.addScatter(
x=(0., 1., 1., 0.), y=(0., 0., 1., 1.), value=(0., 1., 2., 3.))
self.plot.resetZoom(dataMargins=(.1, .1, .1, .1))
self.qapp.processEvents()
# Check that there is no profile
self.assertIsNone(self.profile.getProfileValues())
self.assertIsNone(self.profile.getProfilePoints())
def testHorizontalProfile(self):
"""Test ScatterProfileToolBar horizontal profile"""
nPoints = 8
self.profile.setNPoints(nPoints)
self.assertEqual(self.profile.getNPoints(), nPoints)
# Add a scatter plot
self.plot.addScatter(
x=(0., 1., 1., 0.), y=(0., 0., 1., 1.), value=(0., 1., 2., 3.))
self.plot.resetZoom(dataMargins=(.1, .1, .1, .1))
self.qapp.processEvents()
# Activate Horizontal profile
hlineAction = self.profile.actions()[0]
hlineAction.trigger()
self.qapp.processEvents()
# Set a ROI profile
roi = roi_items.HorizontalLineROI()
roi.setPosition(0.5)
self.profile._getRoiManager().addRoi(roi)
# Wait for async interpolator init
for _ in range(20):
self.qWait(200)
if not self.profile.hasPendingOperations():
break
self.assertIsNotNone(self.profile.getProfileValues())
points = self.profile.getProfilePoints()
self.assertEqual(len(points), nPoints)
# Check that profile has same limits than Plot
xLimits = self.plot.getXAxis().getLimits()
self.assertEqual(points[0, 0], xLimits[0])
self.assertEqual(points[-1, 0], xLimits[1])
# Clear the profile
clearAction = self.profile.actions()[-1]
clearAction.trigger()
self.qapp.processEvents()
self.assertIsNone(self.profile.getProfileValues())
self.assertIsNone(self.profile.getProfilePoints())
self.assertEqual(self.profile.getProfileTitle(), '')
def testVerticalProfile(self):
"""Test ScatterProfileToolBar vertical profile"""
nPoints = 8
self.profile.setNPoints(nPoints)
self.assertEqual(self.profile.getNPoints(), nPoints)
# Add a scatter plot
self.plot.addScatter(
x=(0., 1., 1., 0.), y=(0., 0., 1., 1.), value=(0., 1., 2., 3.))
self.plot.resetZoom(dataMargins=(.1, .1, .1, .1))
self.qapp.processEvents()
# Activate vertical profile
vlineAction = self.profile.actions()[1]
vlineAction.trigger()
self.qapp.processEvents()
# Set a ROI profile
#.........这里部分代码省略.........