For some reason the tight_layout() function from pyplot stopped working on machine. I've been using it in one of my programs for months and its decided to stop working out of the blue (I realize I probably made an accidental change somewhere that's caused this but I don't know where it would be). Any other matplotlib or pyplot function works a-okay, but whenever I call tight_layout I get
module 'matplotlib.pyplot' has no attribute 'tight_layout'
Which is obviously not true.
For example, even this code coming from the offical tight_layout guide (https://matplotlib.org/users/tight_layout_guide.html)
from matplotlib import pyplot as plt
plt.rcParams['savefig.facecolor'] = "0.8"
def example_plot(ax, fontsize=12):
ax.plot([1, 2])
ax.locator_params(nbins=3)
ax.set_xlabel('x-label', fontsize=fontsize)
ax.set_ylabel('y-label', fontsize=fontsize)
ax.set_title('Title', fontsize=fontsize)
plt.close('all')
fig, ax = plt.subplots()
example_plot(ax, fontsize=24)
plt.tight_layout()
will produce the error.
I've reinstalled the matplotlib package a couple times and reinstalled my IDE (Spyder) to no avail. I'm pretty clueless at this point so any input would be great.