0

I want to have a matplotlib figure without ANY padding. Currently I do this manually via the IPython (Spyder3) interactive window and its configure subplots window. As shown in this figure.

I need to automate this process and decided to have a look at the Tight layout options.

fig.set_tight_layout(True)
fig.tight_layout(rect=[0, 0, 1, 1])

This does not result in the intended result as some margins do still remain. As shown here.

How do I force figures to have no padding at all. I expect the setting to exist as I'm able to change it in the GUI of IPython.

2
  • Can you try plt.margins(0,0)? Commented Feb 17, 2019 at 17:51
  • In particular, use this answer. Commented Feb 17, 2019 at 19:21

1 Answer 1

0

The GUI option you're using can be coded with the plt.subplots_adjust command. Something like plt.subplots_adjust(left=0, right=1, top=1, bottom=0) should achieve what you want

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

2 Comments

Thank you very much, this was exactly what I was looking for.
You're welcome. Glad I could help. Please consider marking this answer as accepted.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.