-1

I would like to change the color of the background for the whole plot (including axes, titles, legend etc). Actually there are no problems with making different the part of background that lies beyond the plot itself.

How can I do the same with the margins?

enter image description here

All white areas on the picture should become gray.

BartoszKP
  • 34,786
  • 15
  • 102
  • 130
Vitaly Isaev
  • 5,392
  • 6
  • 45
  • 64

2 Answers2

0

Guessing a bit (as you have posted no code), but this should do it

plt.clf()
fig=plt.gcf()
fig.patch.set_facecolor('white')
plt.plot(yourdata)
Lee
  • 29,398
  • 28
  • 117
  • 170
0

Starting from scratch,

import matplotlib.pyplot as plt
fig = plt.figure(facecolor='gray')
ax = fig.add_subplot(111, axisbg='gray')
ax.plot(<your data>)

You can set the shade of gray by passing floats between 0 and 1 as a 3-tuple instead of the string gray (e.g. (0.5, 0.5, 0.5)).

xnx
  • 24,509
  • 11
  • 70
  • 109