Skip to content

Commit

Permalink
tweak tight layout application for mpl version
Browse files Browse the repository at this point in the history
  • Loading branch information
TomDonoghue committed Jul 18, 2023
1 parent 8d2fd25 commit 70c20e8
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions fooof/plts/style.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,14 @@ def apply_custom_style(ax, **kwargs):
ax.legend(prop={'size': kwargs.pop('legend_size', LEGEND_SIZE)},
loc=kwargs.pop('legend_loc', LEGEND_LOC))

# Apply tight layout to the figure object
# This should be equivalent to `plt.tight_layout()`, but seems to raise fewer warnings...
fig = plt.gcf()
fig.set_layout_engine('tight')
# Apply tight layout to the figure object, if matplotlib is new enough
# If available, `.set_layout_engine` should be equivalent to
# `plt.tight_layout()`, but seems to raise fewer warnings...
try:
fig = plt.gcf()
fig.set_layout_engine('tight')
except:
plt.tight_layout()


def apply_style(ax, axis_styler=apply_axis_style, line_styler=apply_line_style,
Expand Down

0 comments on commit 70c20e8

Please sign in to comment.