本文整理汇总了Python中silx.gui.plot.PlotWindow.addScatter方法的典型用法代码示例。如果您正苦于以下问题:Python PlotWindow.addScatter方法的具体用法?Python PlotWindow.addScatter怎么用?Python PlotWindow.addScatter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类silx.gui.plot.PlotWindow
的用法示例。
在下文中一共展示了PlotWindow.addScatter方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestScatterProfileToolBar
# 需要导入模块: from silx.gui.plot import PlotWindow [as 别名]
# 或者: from silx.gui.plot.PlotWindow import addScatter [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
#.........这里部分代码省略.........