1、设定样式前可先查看matplotlib有哪些样式,使用函数plt.style.available查看可用的样式,结果列出了27种style,如下图。

2、设定样式需要使用函数:plt.衡痕贤伎style.use(),在括号中指定需要的样式:例如:plt.style.use('ggplot&垆杪屑丝#39;)然后再运行绘图代码:x = np.linspace(0,2*np.pi,200)y = np.cos(x)plt.plot(x,y)plt.title('cos函数')

3、再尝试seaborn风格:plt.style.use('seaborn')

4、下面是bmh风格:plt.style.use('bmh')

5、下面是classic风格:plt.style.use('classic')
