【4.1】seaborn修改各种参数

一、参数说明

seaborn.set(context='notebook', style='darkgrid', palette='deep', font='sans-serif', font_scale=1, color_codes=True, rc=None)

可以直接或临时设置每组参数,有关详细信息,请参阅下面的参考函数。

Parameters:

context : string or dict

Plotting context parameters, see plotting_context()

style : string or dict

Axes style parameters, see axes_style()

palette : string or sequence

Color palette, see color_palette()

font : string

Font family, see matplotlib font manager.

font_scale : float, optional

Separate scaling factor to independently scale the size of the font elements.

color_codes : bool

If True and palette is a seaborn palette, remap the shorthand color codes (e.g. “b”, “g”, “r”, etc.) to the colors from this palette.

rc : dict or None

Dictionary of rc parameter mappings to override the above.

二、案例解读

修改坐标轴的labelsize

sns.set(rc = {'axes.labelsize': 20})

更多例子:

rcParams['grid.linewidth'] = lineWidth
rcParams['font.sans-serif'] = ['Helvetica']
rcParams['font.serif'] = ['Helvetica']
rcParams['font.family'] = ['Times New Roman']
rc('font', size=fontSize, family='serif', weight='bold')
rc('axes', linewidth=lineWidth, labelsize=labelSize)
rc('legend', borderpad=0.1, markerscale=1., fancybox=False)
rc('text', usetex=True)
rc('image', aspect='auto')
rc('ps', useafm=True, fonttype=3)
rcParams['xtick.major.size'] = tickmajorsize
rcParams['xtick.minor.size'] = tickminorsize
rcParams['ytick.major.size'] = tickmajorsize
rcParams['ytick.minor.size'] = tickminorsize
rcParams['text.latex.preamble'] = ["\\usepackage{amsmath}"] 

获得当前例子的写法

import matplotlib.pyplot as plt
plt.style.use('presentation')

参考资料

药企,独角兽,苏州。团队长期招人,感兴趣的都可以发邮件聊聊:tiehan@sina.cn
个人公众号,比较懒,很少更新,可以在上面提问题,如果回复不及时,可发邮件给我: tiehan@sina.cn