本文整理匯總了Python中silx.gui.plot.PlotWidget.setLimits方法的典型用法代碼示例。如果您正苦於以下問題:Python PlotWidget.setLimits方法的具體用法?Python PlotWidget.setLimits怎麽用?Python PlotWidget.setLimits使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類silx.gui.plot.PlotWidget
的用法示例。
在下文中一共展示了PlotWidget.setLimits方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: TestLimitConstaints
# 需要導入模塊: from silx.gui.plot import PlotWidget [as 別名]
# 或者: from silx.gui.plot.PlotWidget import setLimits [as 別名]
class TestLimitConstaints(unittest.TestCase):
"""Tests setLimitConstaints class"""
def setUp(self):
self.plot = PlotWidget()
def tearDown(self):
self.plot = None
def testApi(self):
"""Test availability of the API"""
self.plot.getXAxis().setLimitsConstraints(minPos=1, maxPos=10)
self.plot.getXAxis().setRangeConstraints(minRange=1, maxRange=1)
self.plot.getYAxis().setLimitsConstraints(minPos=1, maxPos=10)
self.plot.getYAxis().setRangeConstraints(minRange=1, maxRange=1)
def testXMinMax(self):
"""Test limit constains on x-axis"""
self.plot.getXAxis().setLimitsConstraints(minPos=0, maxPos=100)
self.plot.setLimits(xmin=-1, xmax=101, ymin=-1, ymax=101)
self.assertEqual(self.plot.getXAxis().getLimits(), (0, 100))
self.assertEqual(self.plot.getYAxis().getLimits(), (-1, 101))
def testYMinMax(self):
"""Test limit constains on y-axis"""
self.plot.getYAxis().setLimitsConstraints(minPos=0, maxPos=100)
self.plot.setLimits(xmin=-1, xmax=101, ymin=-1, ymax=101)
self.assertEqual(self.plot.getXAxis().getLimits(), (-1, 101))
self.assertEqual(self.plot.getYAxis().getLimits(), (0, 100))
def testMinXRange(self):
"""Test min range constains on x-axis"""
self.plot.getXAxis().setRangeConstraints(minRange=100)
self.plot.setLimits(xmin=1, xmax=99, ymin=1, ymax=99)
limits = self.plot.getXAxis().getLimits()
self.assertEqual(limits[1] - limits[0], 100)
limits = self.plot.getYAxis().getLimits()
self.assertNotEqual(limits[1] - limits[0], 100)
def testMaxXRange(self):
"""Test max range constains on x-axis"""
self.plot.getXAxis().setRangeConstraints(maxRange=100)
self.plot.setLimits(xmin=-1, xmax=101, ymin=-1, ymax=101)
limits = self.plot.getXAxis().getLimits()
self.assertEqual(limits[1] - limits[0], 100)
limits = self.plot.getYAxis().getLimits()
self.assertNotEqual(limits[1] - limits[0], 100)
def testMinYRange(self):
"""Test min range constains on y-axis"""
self.plot.getYAxis().setRangeConstraints(minRange=100)
self.plot.setLimits(xmin=1, xmax=99, ymin=1, ymax=99)
limits = self.plot.getXAxis().getLimits()
self.assertNotEqual(limits[1] - limits[0], 100)
limits = self.plot.getYAxis().getLimits()
self.assertEqual(limits[1] - limits[0], 100)
def testMaxYRange(self):
"""Test max range constains on y-axis"""
self.plot.getYAxis().setRangeConstraints(maxRange=100)
self.plot.setLimits(xmin=-1, xmax=101, ymin=-1, ymax=101)
limits = self.plot.getXAxis().getLimits()
self.assertNotEqual(limits[1] - limits[0], 100)
limits = self.plot.getYAxis().getLimits()
self.assertEqual(limits[1] - limits[0], 100)
def testChangeOfConstraints(self):
"""Test changing of the constraints"""
self.plot.getXAxis().setRangeConstraints(minRange=10, maxRange=10)
# There is no more constraints on the range
self.plot.getXAxis().setRangeConstraints(minRange=None, maxRange=None)
self.plot.setLimits(xmin=-1, xmax=101, ymin=-1, ymax=101)
self.assertEqual(self.plot.getXAxis().getLimits(), (-1, 101))
def testSettingConstraints(self):
"""Test setting a constaint (setLimits first then the constaint)"""
self.plot.setLimits(xmin=-1, xmax=101, ymin=-1, ymax=101)
self.plot.getXAxis().setLimitsConstraints(minPos=0, maxPos=100)
self.assertEqual(self.plot.getXAxis().getLimits(), (0, 100))