python画图报错:OSError: 'seaborn-whitegrid' is not a valid package style
解决方法:
代码:
import matplotlib.pyplot as plt
plt.style.available
效果:

这个问题说明对应的样式package不存在,查询到存在的package都有哪些然后对应修改即可。
plt.style.use("seaborn-v0_8-whitegrid")
示例:
import numpy as np
import matplotlib.pyplot as plt
from matplotlib import pyplot
# plt.style.use('seaborn-whitegrid')
plt.style.use('seaborn-v0_8-whitegrid')
palette = pyplot.get_cmap('Set1')
font1 = {'family' : 'Times New Roman',
'weight' : 'normal',
'size' : 32,
}
fig=plt.figure(figsize=(20,10))
iters=list(range(7))
#这里随机给了alldata1和alldata2数据用于测试
alldata1=[]#算法1所有纵坐标数据
data=np.array([2,4,5,8,11,13,15])#单个数据
alldata1.append(data)
data=np.array([2,3,6,12,13,13,15])
alldata1.append(data)
data=np.array([2,2,7,9,13,14,16])
alldata1.append(data)
alldata1=np.array(alldata1)
alldata2=[]#算法2所有纵坐标数据
data=np.array([2,4,5,8,10,10,11])#单个数据
alldata2.append(data)
data=np.array([3,3,3,6,7,8,10])
alldata2.append(data)
data=np.array([3,3,5,5,6,7,9])
alldata2.append(data)
alldata2=np.array(alldata2)
def draw_line(name_of_alg,color_index,datas):
color=palette(color_index)
avg=np.mean(datas,axis=0)
std=np.std(datas,axis=0)
r1 = list(map(lambda x: x[0]-x[1], zip(avg, std)))#上方差
r2 = list(map(lambda x: x[0]+x[1], zip(avg, std)))#下方差
plt.plot(iters, avg, color=color,label=name_of_alg,linewidth=3.5)
plt.fill_between(iters, r1, r2, color=color, alpha=0.2)
draw_line("alg1",1,alldata1)
draw_line("alg2",2,alldata2)
plt.xticks(fontsize=22)
plt.yticks(fontsize=22)
plt.xlabel('Time(s)',fontsize=32)
plt.ylabel('metric',fontsize=32)
plt.legend(loc='upper left',prop=font1)
plt.title("instance",fontsize=34)
plt.show()
效果:

python画图报错:OSError: 'seaborn-whitegrid' is not a valid package style的更多相关文章
- [Error]Python虚拟环境报错 OSError: setuptools pip wheel failed with error code 2
mkvirtualenv py35 python新建虚拟环境报错,setuptools pip wheel failed with error code 2 刚好昨天在CentOS安装的时候也总是报s ...
- pyinstaller打包Python程序报错OSError: Python library not found: libpython3.8.so, libpython3.8m.so
重新编译python(不影响原来安装的库文件),加入--enable-shared ./configure --prefix=/usr/local/python3 --enable-shared然后m ...
- Python创建文件报错OSError:[Errno 22] Invalid argument处理
问题: windows平台下使用python open函数w模式打开文件报错“OSError: [Errno 22] Invalid argument: '../news/“消费升维”成零售业新风口? ...
- pandas.read_csv() 报错 OSError: Initializing from file failed,报错原因分析和解决方法
今天调用pandas读取csv文件时,突然报错“ OSError: Initializing from file failed ”,我是有点奇怪的,以前用的好好的,read_csv(path)方法不是 ...
- captcha库报错"OSError: cannot open resource"
问题描述 在win平台上python虚拟环境下使用captcha库生成验证码报错OSError: cannot open resource 代码 from captcha.image import I ...
- mac 上python编译报错No module named MySQLdb
mac 上python编译报错No module named MySQLdb You installed python You did brew install mysql You did expor ...
- 调用python脚本报错/usr/bin/env: python : No such file or directory
一.调用python脚本报错 /usr/bin/env: python: No such file or directory 二.解决方法 原因是在windows上编写的脚本,使用dos2unix对脚 ...
- 第一次打开pycharm运行python文件报错”No Python interpreter selected“问题的解决办法
前面没有细讲,这里细述一下安装pycharm后,第一次打开pycharm运行python文件报错"No Python interpreter selected"问题的解决办法. 出 ...
- Linux Python import jenkins 报错 oserror: /usr/lib/python2.7/site-packages/lookup3.so
安装了jenkins和Python-jenkins后,在脚本中import jenkins会报错:oserror: /usr/lib/python2.7/site-packages/lookup3.s ...
- pip 安装mysqlclient报错OSError: mysql_config not found
执行 pip install mysqlclient 报错信息如下: [root@CentOS7-demo bin]# pip install mysqlclient Collecting mysql ...
随机推荐
- LeetCode 675. Cut Off Trees for Golf Event 为高尔夫比赛砍树 (C++/Java)
题目: You are asked to cut off trees in a forest for a golf event. The forest is represented as a non- ...
- DS Record
八云蓝自动机 Ⅰ 首先我们对于操作 \(1\) 转换,我们给 \(k\) 单独再开一个点 \(a_c\),这样我们就可以把操作 \(1\) 转换成操作 \(2\) 了. 对于区间问题,我们考虑使用莫队 ...
- 喜讯!极限科技再次中标中国移动云 Elasticsearch 自研版技术开发服务项目!
喜讯!极限科技 再次中标 中国移动云 Elasticsearch 自研版技术开发服务项目! 近日,极限科技再次成功中标中国移动苏州研发中心 <云能力中心 2023-2024 年移动云 Elast ...
- windows 命令行调整跃点数
先用 route print -4 命令找到接口号: 接口列表10...00 ff 51 c4 53 b4 ......TAP-Windows Adapter V918...18 c0 4d 29 5 ...
- 使用 OpenTelemetry 构建可观测性 05 - 传播和行李(Propagation & Baggage)
我们开发的应用程序可能具有不同的形态和架构:有些是单体应用,有些是微服务.为单体应用程序添加遥测数据相对来说简单,因为所有数据都在同一进程中.然而对于微服务应用程序,情况可能会更具挑战性. 通常,分布 ...
- 一种复习flex布局的方法
方法论 flex布局有多个属性,时常会忘记.我们复习的话,单纯看一些博客文章,不能直观的理解,也比较枯燥. 因此如果有一种用写代码闯关的方式来复习(学习)flex布局,那也许会更有意思. FLEXBO ...
- Freertos学习:在Posix环境仿真FreeRTOS
--- title: rtos-freertos-在Posix环境仿真FreeRTOS date: 2020-06-11 16:22:34 categories: tags: - freertos - ...
- 【论文阅读】IROS2021: PILOT: Efficient Planning by Imitation Learning and Optimisation for Safe Autonomous Driving
参考与前言 完整题目:PILOT: Efficient Planning by Imitation Learning and Optimisation for Safe Autonomous Driv ...
- 在Mac上使用Emacs初步
其他操作系统估计也差不多. 安装 如果使用brew就是brew install emacs.安装后不会在Applications里面显示一个程序,需要在命令行里执行emacs. 使用 进入和退出 上面 ...
- SpringBoot 整合模板引擎 jetbrick-template
添加依赖 <dependency> <groupId>com.github.subchen</groupId> <artifactId>jetbrick ...