Setting plot background colour in Seaborn

后端 未结 3 1510
深忆病人
深忆病人 2021-02-05 13:51

I am using Seaborn to plot some data in Pandas.

I am making some very large plots (factorplots).

To see them, I am using some visualisation faciliti

3条回答
  •  甜味超标
    2021-02-05 14:21

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

    (edited with advice from @mwaskom)

    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 that'll work with your FacetGrid as well.

提交回复
热议问题