@@ -541,6 +541,7 @@ def _get_tick_position(obj, axes_obj):
541
541
if len (set (major_ticks_top )) == 1 and major_ticks_top [0 ] is True :
542
542
major_ticks_top_show_all = True
543
543
544
+ position_string = None
544
545
major_ticks_position = None
545
546
if not major_ticks_bottom_show_all and not major_ticks_top_show_all :
546
547
position_string = f"{ axes_obj } majorticks=false"
@@ -562,31 +563,38 @@ def _get_ticks(data, xy, ticks, ticklabels):
562
563
necessary axis options for the given configuration.
563
564
"""
564
565
axis_options = []
565
- pgfplots_ticks = []
566
- pgfplots_ticklabels = []
566
+
567
+ # Check if the label is necessary. If one of the labels is, then all of them must
568
+ # appear in the TikZ plot.
567
569
is_label_required = False
568
570
for tick , ticklabel in zip (ticks , ticklabels ):
569
571
# store the label anyway
570
572
label = ticklabel .get_text ()
571
- if "," in label :
572
- label = "{" + label + "}"
573
573
574
- if ticklabel .get_visible ():
575
- pgfplots_ticklabels .append (_common_texification (label ))
576
- else :
574
+ if not ticklabel .get_visible ():
577
575
is_label_required = True
576
+ break
577
+
578
+ if not label :
579
+ continue
578
580
579
- # Check if the label is necessary. If one of the labels is, then all of them
580
- # must appear in the TikZ plot.
581
- if label :
582
- try :
583
- label_float = float (label .replace ("\N{MINUS SIGN} " , "-" ))
584
- except ValueError :
581
+ try :
582
+ label_float = float (label .replace ("\N{MINUS SIGN} " , "-" ))
583
+ except ValueError :
584
+ is_label_required = True
585
+ break
586
+ else :
587
+ if abs (label_float - tick ) > 1.0e-10 + 1.0e-10 * abs (tick ):
585
588
is_label_required = True
586
- else :
587
- is_label_required = is_label_required or (
588
- label and abs (label_float - tick ) > 1.0e-10 + 1.0e-10 * abs (tick )
589
- )
589
+ break
590
+
591
+ pgfplots_ticks = []
592
+ pgfplots_ticklabels = []
593
+ for tick , ticklabel in zip (ticks , ticklabels ):
594
+ label = ticklabel .get_text ()
595
+ if "," in label :
596
+ label = "{" + label + "}"
597
+ pgfplots_ticklabels .append (_common_texification (label ))
590
598
591
599
# note: ticks may be present even if labels are not, keep them for grid lines
592
600
for tick in ticks :
0 commit comments