天天看点

Python之seaborn:利用seaborn的color_palette()函数改变绘图界面风格

利用seaborn的color_palette()函数改变绘图界面风格

实现结果

sns.set_style('ticks')   #默认五种风格:darkgrid,whitegrid,dark,white,ticks

Python之seaborn:利用seaborn的color_palette()函数改变绘图界面风格
Python之seaborn:利用seaborn的color_palette()函数改变绘图界面风格
Python之seaborn:利用seaborn的color_palette()函数改变绘图界面风格
Python之seaborn:利用seaborn的color_palette()函数改变绘图界面风格

源代码解释

def set_style Found at: seaborn.rcmod

def set_style(style=None, rc=None):

   """Set the aesthetic style of the plots.

   This affects things like the color of the axes, whether a grid is enabled by default, and other aesthetic elements.

   Parameters

   ----------

   style : dict, None, or one of {darkgrid, whitegrid, dark, white, ticks}. A dictionary of parameters or the name of a preconfigured set.

   rc : dict, optional. Parameter mappings to override the values in the preset seaborn style dictionaries. This only updates parameters that are considered part of the style definition.

设定了绘图的美学风格。

这将影响轴的颜色、是否默认启用网格以及其他美学元素。

参数

----------

style : dict,无,或一个{darkgrid,暗网格,whitegrid白格子,dark黑,white白,ticks}。参数的字典或预先配置的参数集的名称。

rc: dict,可选。参数映射,以覆盖预设的seaborn样式字典中的值。这只更新被认为是样式定义的一部分的参数。

   Examples

   --------

   >>> set_style("whitegrid")

   >>> set_style("ticks", {"xtick.major.size": 8, "ytick.major.size": 8})

   See Also

   axes_style : return a dict of parameters or use in a ``with`` statement to temporarily set the style.

   set_context : set parameters to scale plot elements

   set_palette : set the default color palette for figures

   """

   style_object = axes_style(style, rc)

   mpl.rcParams.update(style_object)

axes_style: 返回一组参数或在' ' with ' '语句中使用来临时设置样式。

set_context: 设置参数来缩放图形元素。

set_palette: 设置图形的默认调色板。