@@ -791,15 +791,15 @@ def format_ticks(self, values):
791791 # offset fmt are for the offset in the upper left of the
792792 # or lower right of the axis.
793793 offsetfmts = self .offset_formats
794+ show_offset = self .show_offset
794795
795796 # determine the level we will label at:
796797 # mostly 0: years, 1: months, 2: days,
797798 # 3: hours, 4: minutes, 5: seconds, 6: microseconds
798799 for level in range (5 , - 1 , - 1 ):
799800 if len (np .unique (tickdate [:, level ])) > 1 :
800- # level is less than 2 so a year is already present in the axis
801- if (level < 2 ):
802- self .show_offset = False
801+ if level < 2 :
802+ show_offset = False
803803 break
804804 elif level == 0 :
805805 # all tickdate are the same, so only micros might be different
@@ -839,11 +839,13 @@ def format_ticks(self, values):
839839 if '.' in labels [nn ]:
840840 labels [nn ] = labels [nn ][:- trailing_zeros ].rstrip ('.' )
841841
842- if self . show_offset :
842+ if show_offset :
843843 # set the offset string:
844844 self .offset_string = tickdatetime [- 1 ].strftime (offsetfmts [level ])
845845 if self ._usetex :
846846 self .offset_string = _wrap_in_tex (self .offset_string )
847+ else :
848+ self .offset_string = ''
847849
848850 if self ._usetex :
849851 return [_wrap_in_tex (l ) for l in labels ]
0 commit comments