Check for tight_layout before applying it in plot function (#2504)

This commit is contained in:
Al-Ekram Elahee Hridoy 2023-10-07 07:56:46 -06:00 committed by GitHub
parent 53b9b1a6be
commit 279d8d6a30
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -63,6 +63,7 @@ def plot(
------- -------
A matplotlib figure. A matplotlib figure.
""" """
user_provided_ax = False if ax is None else True
if ax is None: if ax is None:
fig = plt.figure(facecolor='w', figsize=figsize) fig = plt.figure(facecolor='w', figsize=figsize)
ax = fig.add_subplot(111) ax = fig.add_subplot(111)
@ -89,7 +90,8 @@ def plot(
ax.set_ylabel(ylabel) ax.set_ylabel(ylabel)
if include_legend: if include_legend:
ax.legend() ax.legend()
fig.tight_layout() if not user_provided_ax:
fig.tight_layout()
return fig return fig