Skip to content

Commit 97f360a

Browse files
authored
Merge pull request #10690 from anntzer/lazyticks
Improve lazy-ticks realization.
2 parents 4391fe9 + 90c30a0 commit 97f360a

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

lib/matplotlib/axis.py

+11-2
Original file line numberDiff line numberDiff line change
@@ -677,11 +677,20 @@ def __get__(self, instance, cls):
677677
if instance is None:
678678
return self
679679
else:
680+
# instance._get_tick() can itself try to access the majorTicks
681+
# attribute (e.g. in certain projection classes which override
682+
# e.g. get_xaxis_text1_transform). In order to avoid infinite
683+
# recursion, first set the majorTicks on the instance to an empty
684+
# list, then create the tick and append it.
680685
if self._major:
681-
instance.majorTicks = [instance._get_tick(major=True)]
686+
instance.majorTicks = []
687+
tick = instance._get_tick(major=True)
688+
instance.majorTicks.append(tick)
682689
return instance.majorTicks
683690
else:
684-
instance.minorTicks = [instance._get_tick(major=False)]
691+
instance.minorTicks = []
692+
tick = instance._get_tick(major=False)
693+
instance.minorTicks.append(tick)
685694
return instance.minorTicks
686695

687696

0 commit comments

Comments
 (0)