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 ...
随机推荐
- 剑指Offer-48.不用加减乘除做加法(C++/Java)
题目: 写一个函数,求两个整数之和,要求在函数体内不得使用+.-.*./四则运算符号. 分析: 将加法还原成最原始的计算方法,也就是分别计算进位和非进位的和,最后再将这两部分合起来,便是和.我们可以利 ...
- 使用 ClickHouse 做日志分析
原作:Monika Singh & Pradeep Chhetri 这是我们在 Monitorama 2022 上发表的演讲的改编稿.您可以在此处找到包含演讲者笔记的幻灯片和此处的视频. 当 ...
- 开源高性能结构化日志模块NanoLog
最近在写数据库程序,需要一个高性能的结构化日志记录组件,简单研究了一下Microsoft.Extensions.Logging和Serilog,还是决定重造一个轮子. 一.使用方法 直接参考以 ...
- unsupported operand type(s) for +: 'function' and 'str'
unsupported operand type(s) for +: 'function' and 'str' 报错解释:这个错误表明你尝试将一个函数和一个字符串进行加法操作,在Python中,加法不 ...
- Python做点击率数据预测
点击率(Click-Through Rate, CTR)预测是推荐系统.广告系统和搜索引擎中非常重要的一个环节.在这个场景中,我们通常需要根据用户的历史行为.物品的特征.上下文信息等因素来预测用户点击 ...
- spark高级分析2的数据集地址
第二章 数据分析 wget https://archive.ics.uci.edu/ml/machine-learning-databases/00210/donation.zip 第三章 音乐推 ...
- 使用 TensorRT C++ API 调用GPU加速部署 YOLOv10 实现 500FPS 推理速度——快到飞起!!
NVIDIA TensorRT 是一款用于高性能深度学习推理的 SDK,包含深度学习推理优化器和运行时,可为推理应用程序提供低延迟和高吞吐量.YOLOv10是清华大学研究人员近期提出的一种实时目标 ...
- C# pythonnet(1)_传感器数据清洗算法
Python代码如下 import pandas as pd # 读取数据 data = pd.read_csv('data_row.csv') # 检查异常值 def detect_outliers ...
- 开源一个RAG大模型本地知识库问答机器人
弹指间,2009年大学毕业到现在2024年,已经15年过去了. 前2天,看到自己14年在博客园写的一个博客,哪个时候是工作之余创业 感兴趣的朋友可以看看我10年前发的一篇博客https://www.c ...
- 国芯新作 | 四核Cortex-A53@1.4GHz,仅168元起?含税?哇!!!
获取更多T507全国产平台资料可在评论区留言或关注官方公众号~