0

This is my code (I am running it in a jupyter notebook on OS X )

% matplotlib inline
import matplotlib.pyplot as plt
fig = plt.figure()
fig.set_facecolor('gray')
ax = fig.add_axes([0.2, 0.2, 0.2, 0.2])
print fig.get_figwidth()

I was expecting to see a large gray figure box with a small white axes box in the bottom left hand corner. What I get is a small white axes box with a small gray box surrounding it.

I am obviously missing some setting or other. How do I get what I was expecting?

What I see

pheon
  • 2,867
  • 3
  • 26
  • 33

1 Answers1

0

After some more experimentation and digging I found the answer in the matplotlib magic documentation referenced from here.

The ipython magics are enforcing bbox_inches='tight' by default. which causes the figure bbox to shrink to fit the axes.

The trick is to add the magic line

% config InlineBackend.print_figure_kwargs = {'bbox_inches':None}

Community
  • 1
  • 1
pheon
  • 2,867
  • 3
  • 26
  • 33