File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -169,10 +169,14 @@ def apply_custom_style(ax, **kwargs):
169169 ax .legend (prop = {'size' : kwargs .pop ('legend_size' , LEGEND_SIZE )},
170170 loc = kwargs .pop ('legend_loc' , LEGEND_LOC ))
171171
172- # Apply tight layout to the figure object
173- # This should be equivalent to `plt.tight_layout()`, but seems to raise fewer warnings...
174- fig = plt .gcf ()
175- fig .set_layout_engine ('tight' )
172+ # Apply tight layout to the figure object, if matplotlib is new enough
173+ # If available, `.set_layout_engine` should be equivalent to
174+ # `plt.tight_layout()`, but seems to raise fewer warnings...
175+ try :
176+ fig = plt .gcf ()
177+ fig .set_layout_engine ('tight' )
178+ except :
179+ plt .tight_layout ()
176180
177181
178182def apply_style (ax , axis_styler = apply_axis_style , line_styler = apply_line_style ,
You can’t perform that action at this time.
0 commit comments