Setting background color in Seaborn

I use Seaborn to build some data in Pandas.

I make very large graphs ( factorplot s).

To see them, I use some visualization tools at my university. I use the Compound screen, which consists of 4 monitors with a small (but non-zero) bevel - the gap between the screens. This space is black. To minimize the gap between the screen, I want the graphic overlay to be black. I dig documentation and play, and I cannot solve it. Of course it is simple.

I can get a gray background with set_style('darkgrid')

Do I need to directly access graphics in matplotlib?

+7
python matplotlib pandas plot seaborn
source share
2 answers

seaborn.set accepts and rc argument, which accepts a dictionary of valid matplotlib rcparams . Therefore, we need to set two things: axes.facecolor , which is the color of the area where the data is displayed, and figure.facecolor , which is part of the part of the figure outside the axes object.

(edited by @mwaskom tip)

So, if you do:

 %matplotlib inline import matplotlib.pyplot as plt import seaborn seaborn.set(rc={'axes.facecolor':'cornflowerblue', 'figure.facecolor':'cornflowerblue'}) fig, ax = plt.subplots() 

You get:

enter image description here

And this will work with your FacetGrid .

+14
source share

I am not familiar with the seabed, but it looks like you can change the background by setting the focus of the axes. It can set any of ax.set_* elements.

 import seaborn as sns import pandas as pd import numpy as np import matplotlib.pyplot as plt m=pd.DataFrame({'x':['1','1','2','2','13','13'], 'y':np.random.randn(6)}) facet = sns.factorplot('x','y',data=m) facet.set(axis_bgcolor='k') plt.show() 
+8
source share

All Articles