x = np.linspace(0,14,100) y1 = np.sin(x) y2 = np.sin(x+2)*1.25 def sinplot() plt.plot(x,y1) plt.plot(x,y2) plt.show()
123456789 | x = np.linspace(0,14,100)y1 = np.sin(x)y2 = np.sin(x+2)*1.25 def sinplot() plt.plot(x,y1) plt.plot(x,y2) plt.show() |
|---|


seaborn提供可绘图的5种风格主题:’darkgrid’, ‘dark’, ‘white’, ‘whitegrid’, ‘ticks’
可以使用set_style来指定绘图的主题:

方法:axes_style可以显示当前的主题的参数:

比如说在其中,grid.color控制网格颜色,想要修改这个值,可以将这个字典传入set_style中:

但是现在再通过axes_style查看,发现已经修改了其中的值:

也就是说,之后再使用这个主题,边框颜色都会变成红色。
想要恢复默认的风格参数,需要set()

seaborn预设了四种线条风格:’paper’, ‘notebook’, ‘talk’, ‘poster’
set_context方法可以设置线条的粗细:

plotting_context方法可以显示当前线条风格的参数:

和前面一样,假设想要设置线条粗细,可以更改‘lines.linewidth’: 2.8000000000000003,这个参数:
sns.set_context('talk', rc={'grid.linewidth': 1.0})
12 | sns.set_context('talk', rc={'grid.linewidth': 1.0}) |
|---|

和之前略有区别的是,参数字典不是直接传入的,而是赋给rc位置参数 想要恢复默认值可以通过sns.set()进行恢复。