The following code gives me a plot with significant margins above and below the figure. I don\'t know how to eliminate the noticeable margins. subplots_adjust
does
I think the subplot_adjust
call is irrelevant here since the adjustment is overridden by tight_layout
. Anyway, this only change the size of the axes inside the figure.
As tcaswell pointed it, you need to change the size of the figure. Either at creation (my proposition below) or after, using fig.set_size_inches
. I'm here creating a figure with a 1:1 aspect ratio using the figsize=(6,6)
argument (of course 6 inches is an arbitrary choice):
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure(figsize=(6,6))
ax = fig.add_subplot(111)
ax.plot(range(10),range(10))
ax.set_aspect('equal')
plt.tight_layout()