1

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() 

enter image description here

2
  • I believe if you save the file (as .png, or .pdf) they grey is all gone. Use plt.savefig('output_name.pdf') to do it. Commented Apr 20, 2015 at 1:31
  • @TravisJ. You are correct, but I'm not trying to get a file out of it, I am dumping it in a Tkinter window. Commented Apr 20, 2015 at 1:32

1 Answer 1

1

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]) 

enter image description here

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.)

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.