本文整理匯總了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
#.........這裏部分代碼省略.........