Matplotlib how to change figsize for matshow
By default, plt.matshow()
produces its own figure, so in combination with plt.figure()
two figures will be created and the one that hosts the matshow plot is not the one that has the figsize set.
There are two options:
Use the
fignum
argumentplt.figure(figsize=(10,5)) plt.matshow(d.corr(), fignum=1)
Plot the matshow using
matplotlib.axes.Axes.matshow
instead ofpyplot.matshow
.fig, ax = plt.subplots(figsize=(10,5)) ax.matshow(d.corr())
The solutions did not work for me but I found another way:
plt.figure(figsize=(10,5))
plt.matshow(d.corr(), fignum=1, aspect='auto')