sns.set(style="darkgrid", palette="muted", color_codes=True)
时间: 2023-11-09 08:08:05 浏览: 40
这是一个用于设置Seaborn绘图风格的代码,style参数设置为“darkgrid”表示绘图风格为深色网格线条,palette参数为“muted”表示使用柔和的颜色调色板,color_codes参数设置为True表示使用颜色代码。Seaborn是一个Python数据可视化库,它建立在matplotlib库之上,提供了更加美观和高级的图形绘制功能。
相关问题
import pandas as pd import numpy as np import matplotlib.pyplot as plt import seaborn as sns plt.style.use('fivethirtyeight')#样式美化 import matplotlib.pyplot as plt from sklearn.metrics import classification_reportdata=pd.read_csv('ex2data.txt',names=['exam1','exam2','admitted']) data.head()data.describe()sns.set(context='notebook',style='darkgrid',palette=sns.color_palette("RdBu",2)) sns.lmplot('exam1','exam2',hue='admitted',data=data, size=6, fit_reg=False, scatter_kws={"s":50}) plt.show()NameError Traceback (most recent call last) Cell In[16], line 2 1 sns.set(context='notebook',style='darkgrid',palette=sns.color_palette("RdBu",2)) ----> 2 sns.lmplot('exam1','exam2',hue='admitted',datb=datb, 3 size=6, 4 fit_reg=False, 5 scatter_kws={"s":50}) 6 plt.show() --------------------------------------------------------------------------- TypeError Traceback (most recent call last) Cell In[17], line 2 1 sns.set(context='notebook',style='darkgrid',palette=sns.color_palette("RdBu",2)) ----> 2 sns.lmplot('exam1','exam2',hue='admitted',data=data, 3 size=6, 4 fit_reg=False, 5 scatter_kws={"s":50}) 6 plt.show() TypeError: lmplot() got multiple values for argument 'data'怎么修改
在代码中,第17行中的参数 'datb' 应该是 'data',所以需要将其修改为 'data'。
修改后的代码如下:
```python
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import seaborn as sns
plt.style.use('fivethirtyeight')#样式美化
from sklearn.metrics import classification_report
data=pd.read_csv('ex2data.txt',names=['exam1','exam2','admitted'])
data.head()
data.describe()
sns.set(context='notebook',style='darkgrid',palette=sns.color_palette("RdBu",2))
sns.lmplot('exam1','exam2',hue='admitted',data=data,
size=6,
fit_reg=False,
scatter_kws={"s":50})
plt.show()
```
seaborn.set(context='notebook',style='darkgrid',palette='deep',font='sans-serif',font_scale=1,color_codes=True,rc=None)什么意思
这段代码是用于设置 Seaborn 图形库的全局参数的。该函数可以接受多个参数:
- context:表示 Seaborn 图形的上下文,可以是 "paper"、"notebook"、"talk"、"poster" 等,不同的上下文会影响 Seaborn 图形元素的大小、线条粗细等属性;
- style:表示 Seaborn 图形的风格,可以是 "white"、"dark"、"whitegrid"、"darkgrid"、"ticks" 等,不同的风格会影响 Seaborn 图形中线条、坐标轴、背景色等属性;
- palette:表示 Seaborn 图形的颜色调色板,可以是 "deep"、"muted"、"bright"、"pastel"、"dark" 等,不同的调色板会影响 Seaborn 图形中颜色的选择和搭配;
- font:表示 Seaborn 图形中使用的字体;
- font_scale:表示 Seaborn 图形中字体大小的缩放比例;
- color_codes:表示 Seaborn 是否使用颜色代码,可以是 True 或 False;
- rc:表示 Seaborn 其他参数的字典,可以用来设置 Seaborn 图形的其他参数。
该函数的调用可以用于设置全局的 Seaborn 图形属性,使得后续绘制的所有 Seaborn 图形都具有相同的属性风格。
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)