@@ -1179,8 +1179,12 @@ def maxLabelWidth(self, font):
11791179 if not ticks :
11801180 return 0
11811181 if self .labelAutoSize ():
1182- return np .ceil (max ([self .labelSize (font , v ).width ()
1183- for v in ticks if self .scaleDiv ().contains (v )]))
1182+ vmax = sorted ([v for v in ticks if self .scaleDiv ().contains (v )],
1183+ key = lambda obj : len (QLocale ().toString (obj )))[- 1 ]
1184+ return np .ceil (self .labelSize (font , vmax ).width ())
1185+ ## Original implementation (closer to Qwt's C++ code, but slower):
1186+ #return np.ceil(max([self.labelSize(font, v).width()
1187+ # for v in ticks if self.scaleDiv().contains(v)]))
11841188 else :
11851189 return self ._get_max_label_size (font ).width ()
11861190
@@ -1193,8 +1197,12 @@ def maxLabelHeight(self, font):
11931197 if not ticks :
11941198 return 0
11951199 if self .labelAutoSize ():
1196- return np .ceil (max ([self .labelSize (font , v ).height ()
1197- for v in ticks if self .scaleDiv ().contains (v )]))
1200+ vmax = sorted ([v for v in ticks if self .scaleDiv ().contains (v )],
1201+ key = lambda obj : len (QLocale ().toString (obj )))[- 1 ]
1202+ return np .ceil (self .labelSize (font , vmax ).height ())
1203+ ## Original implementation (closer to Qwt's C++ code, but slower):
1204+ #return np.ceil(max([self.labelSize(font, v).height()
1205+ # for v in ticks if self.scaleDiv().contains(v)]))
11981206 else :
11991207 return self ._get_max_label_size (font ).height ()
12001208
0 commit comments