@@ -1710,6 +1710,41 @@ def get_tick_space(self):
17101710 # Must be overridden in the subclass
17111711 raise NotImplementedError ()
17121712
1713+ def _get_ticks_position (self ):
1714+ """
1715+ Helper for `XAxis.get_ticks_positions` and `YAxis.get_ticks_position`.
1716+
1717+ Check the visibility of tick1line, label1, tick2line, and label2 on
1718+ the first major and the first minor ticks, and return
1719+
1720+ - 1 if only tick1line and label1 are visible;
1721+ - 2 if only tick2line and label2 are visible;
1722+ - "default" if only tick1line, tick2line and label1 are visible;
1723+ - "unknown" otherwise.
1724+ """
1725+ major = self .majorTicks [0 ]
1726+ minor = self .minorTicks [0 ]
1727+ if all (tick .tick1line .get_visible ()
1728+ and not tick .tick2line .get_visible ()
1729+ and tick .label1 .get_visible ()
1730+ and not tick .label2 .get_visible ()
1731+ for tick in [major , minor ]):
1732+ return 1
1733+ elif all (tick .tick2line .get_visible ()
1734+ and not tick .tick1line .get_visible ()
1735+ and tick .label2 .get_visible ()
1736+ and not tick .label1 .get_visible ()
1737+ for tick in [major , minor ]):
1738+ return 2
1739+ elif all (tick .tick1line .get_visible ()
1740+ and tick .tick2line .get_visible ()
1741+ and tick .label1 .get_visible ()
1742+ and not tick .label2 .get_visible ()
1743+ for tick in [major , minor ]):
1744+ return "default"
1745+ else :
1746+ return "unknown"
1747+
17131748 def get_label_position (self ):
17141749 """
17151750 Return the label position (top or bottom)
@@ -2002,30 +2037,11 @@ def tick_bottom(self):
20022037
20032038 def get_ticks_position (self ):
20042039 """
2005- Return the ticks position (top, bottom, default or unknown)
2040+ Return the ticks position (" top", " bottom", " default", or " unknown").
20062041 """
2007- major = self .majorTicks [0 ]
2008- minor = self .minorTicks [0 ]
2009- if all (tick .tick1line .get_visible ()
2010- and not tick .tick2line .get_visible ()
2011- and tick .label1 .get_visible ()
2012- and not tick .label2 .get_visible ()
2013- for tick in [major , minor ]):
2014- return "bottom"
2015- elif all (tick .tick2line .get_visible ()
2016- and not tick .tick1line .get_visible ()
2017- and tick .label2 .get_visible ()
2018- and not tick .label1 .get_visible ()
2019- for tick in [major , minor ]):
2020- return "top"
2021- elif all (tick .tick1line .get_visible ()
2022- and tick .tick2line .get_visible ()
2023- and tick .label1 .get_visible ()
2024- and not tick .label2 .get_visible ()
2025- for tick in [major , minor ]):
2026- return "default"
2027- else :
2028- return "unknown"
2042+ return {1 : "bottom" , 2 : "top" ,
2043+ "default" : "default" , "unknown" : "unknown" }[
2044+ self ._get_ticks_position ()]
20292045
20302046 def get_view_interval (self ):
20312047 'return the Interval instance for this axis view limits'
@@ -2383,33 +2399,11 @@ def tick_left(self):
23832399
23842400 def get_ticks_position (self ):
23852401 """
2386- Return the ticks position (left, right, both or unknown)
2387- """
2388- majt = self .majorTicks [0 ]
2389- mT = self .minorTicks [0 ]
2390-
2391- majorRight = ((not majt .tick1On ) and majt .tick2On and
2392- (not majt .label1On ) and majt .label2On )
2393- minorRight = ((not mT .tick1On ) and mT .tick2On and
2394- (not mT .label1On ) and mT .label2On )
2395- if majorRight and minorRight :
2396- return 'right'
2397-
2398- majorLeft = (majt .tick1On and (not majt .tick2On ) and
2399- majt .label1On and (not majt .label2On ))
2400- minorLeft = (mT .tick1On and (not mT .tick2On ) and
2401- mT .label1On and (not mT .label2On ))
2402- if majorLeft and minorLeft :
2403- return 'left'
2404-
2405- majorDefault = (majt .tick1On and majt .tick2On and
2406- majt .label1On and (not majt .label2On ))
2407- minorDefault = (mT .tick1On and mT .tick2On and
2408- mT .label1On and (not mT .label2On ))
2409- if majorDefault and minorDefault :
2410- return 'default'
2411-
2412- return 'unknown'
2402+ Return the ticks position ("left", "right", "default", or "unknown").
2403+ """
2404+ return {1 : "left" , 2 : "right" ,
2405+ "default" : "default" , "unknown" : "unknown" }[
2406+ self ._get_ticks_position ()]
24132407
24142408 def get_view_interval (self ):
24152409 'return the Interval instance for this axis view limits'
0 commit comments