@@ -188,7 +188,9 @@ def build(self, df, options, show=True):
188188 ymax_left = math .ceil (max (ymax_left , max (data_array )))
189189 ymin_left = math .floor (min (ymin_left , min (data_array )))
190190 if vax == "right" :
191- ymax_right = math .ceil (max (ymax_right , max (data_array )))
191+ ymax_right = (
192+ math .ceil (max (ymax_right , max (data_array )) * 10 ) / 10
193+ )
192194 ymin_right = math .floor (min (ymin_right , min (data_array )))
193195 if s_type == "bar" or s_type == "stacked" :
194196 nr_bar += 1
@@ -313,8 +315,15 @@ def build(self, df, options, show=True):
313315 # axis.legend(loc = 'center left', bbox_to_anchor=(1, 0.5))
314316
315317 if axis_right :
316- ylim = math .ceil (
317- max (np .max (stacked_plus_right ), - np .min (stacked_neg_right ))
318+ ylim = (
319+ math .ceil (
320+ max (
321+ max (np .max (stacked_plus_right ), ymax_right ),
322+ - min (np .min (stacked_neg_right ), ymin_right ),
323+ )
324+ * 10
325+ )
326+ / 10
318327 )
319328 if ylim > 0 :
320329 if np .min (stacked_neg_right ) < 0 :
@@ -324,9 +333,19 @@ def build(self, df, options, show=True):
324333 else :
325334 axis_right .set_ylim ([min (0 , ymin_right ), ymax_right ])
326335 axis_right .set_ylabel (g_options ["vaxis" ][1 ]["title" ])
336+ if "format" in g_options ["vaxis" ][1 ]:
337+ f_str = g_options ["vaxis" ][1 ]["format" ]
338+ axis_right .yaxis .set_major_formatter (
339+ ticker .FormatStrFormatter (f_str )
340+ )
327341
328342 if stacked_plus is not None :
329- ylim = math .ceil (max (np .max (stacked_plus ), - np .min (stacked_neg )))
343+ ylim = math .ceil (
344+ max (
345+ max (np .max (stacked_plus ), ymax_left ),
346+ - min (np .min (stacked_neg ), ymin_left ),
347+ )
348+ )
330349 if ylim > 0 :
331350 if np .min (stacked_neg ) < 0 :
332351 ax .set_ylim ([- ylim , ylim ])
@@ -345,5 +364,4 @@ def build(self, df, options, show=True):
345364
346365 if show :
347366 plt .show ()
348- else :
349- return fig
367+ return fig
0 commit comments