在Seaborn中设置情节背景颜色 [英] Setting plot background colour in Seaborn

查看:460
本文介绍了在Seaborn中设置情节背景颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Seaborn在熊猫中绘制一些数据.

我正在绘制一些非常大的图(factorplot s).

要查看它们,我在大学使用了一些可视化工具. 我正在使用由4 x 4监视器组成的复合屏幕,这些监视器的斜角较小(但非零),即屏幕之间的间隙. 这个缝隙是黑色的. 为了最大程度地减少屏幕之间的断开,我希望图形背景为黑色. 我一直在研究文档并四处浏览,但无法解决. 当然,这很简单.

我可以使用set_style('darkgrid')

获得灰色背景

我需要直接在matplotlib中访问图吗?

解决方案

seaborn.set接受rc参数,该参数接受有效matplotlib rcparams的字典.因此,我们需要设置两件事:axes.facecolor,它是绘制数据的区域的颜色;和figure.facecolor,它是图形中除axes对象之外的所有部分. /p>

(在@mwaskom的建议下编辑)

因此,如果您这样做:

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

fig, ax = plt.subplots()

您得到:

这也将与您的FacetGrid一起使用.

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 facilities at my university. I am using a Compound screen made up of 4 by 4 monitors with small (but nonzero) bevel -- the gap between the screens. This gap is black. To minimise the disconnect between the screen i want the graph backgound to be black. I have been digging around the documentation and playing around and I can't work it out.. Surely this is simple.

I can get grey background using set_style('darkgrid')

do i need to access the plot in matplotlib directly?

解决方案

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:

And that'll work with your FacetGrid as well.

这篇关于在Seaborn中设置情节背景颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆