网站首页 美食营养 游戏数码 手工爱好 生活家居 健康养生 运动户外 职场理财 情感交际 母婴教育 时尚美容

设置matplotlib的绘图风格

时间:2024-10-11 19:50:04

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

设置matplotlib的绘图风格

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函数')

设置matplotlib的绘图风格

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

设置matplotlib的绘图风格

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

设置matplotlib的绘图风格

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

设置matplotlib的绘图风格
© 2025 小知经验
信息来自网络 所有数据仅供参考
有疑问请联系站长 site.kefu@gmail.com