Reputation: 9213
How can I extend the plot area to take up the whole canvas and essentially remove the gray area in the image? I've looked around and I haven't found any solutions, although maybe it's because I don't know what to call that area so searching is challenging.
Using fig.tight_layout()
reduces the gray but does not remove it.
from matplotlib import pyplot as plt
y = [1,3,5,6,7,8,12,13,15,15,16,25,26,28,29,36]
x = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]
fig, ax = plt.subplots(figsize=(8,4), dpi=85)
ax.stackplot(x, y, color='w', colors=('#ededed',))
ax.xaxis.set_visible(False)
ax.yaxis.set_visible(False)
ax.set_ylim([0,max(y)*1.2])
ax.set_xlim([0,30])
plt.show()
Upvotes: 1
Views: 722
Reputation: 16249
Specify that the Axes
take up the whole Figure
when you create the Axes
--
fig = plt.figure()
ax = fig.add_axes((0,0,1,1), frameon=False)
ax.plot([2,5,4])
now, there's a lot there isn't room for any more, e.g. external tick labels; and Tkinter may be doing some padding itself; but this is as large as you can make an Axes
. ( (0,0,1,1)
is extent in Figure coordinates.)
Upvotes: 1