箱型图
| import pandas as pd |
| import seaborn as sns |
| |
| titanic=pd.read_csv('C:\\work\\titanic.csv') |
| titanic.head() |
点击查看详情

| |
| sns.boxplot(y=titanic["age"]) |
点击查看详情

| # x轴指定class分类 |
| sns.boxplot(data=titanic,y="age",x="class") |
点击查看详情

| |
| sns.boxplot(data=titanic, x="class", y="age", hue="alive") |
点击查看详情

| |
| sns.boxplot(data=titanic, x="deck", y="age", width=.5) |
点击查看详情

| |
| |
| sns.boxplot(data=titanic, x="deck", y="age", color="0.8", linewidth=.75) |
点击查看详情

热力图
| glue=pd.read_csv('C:\\work\\glue.csv') |
| glue.head() |
点击查看详情

| |
| glue_pivot=glue.pivot(index="Model", columns="Task", values="Score") |
| glue_pivot.head() |
点击查看详情

| sns.heatmap(glue_pivot, annot=True) |
点击查看详情

| |
| |
| sns.heatmap(glue_pivot, annot=True, linewidth=.5, vmin=0, vmax=100) |
点击查看详情

| |
| sns.heatmap(glue_pivot, cmap="crest", annot=True) |
点击查看详情

点击查看详情
| crash=pd.read_csv('C:\\work\\car_crashes.csv') |
| crash_tmp=crash.drop("abbrev",axis=1) |
| crash_tmp.head() |

| |
| crash_relate=crash_tmp.corr() |
| crash_relate |

| |
| sns.heatmap(crash_relate, annot=True, linewidth=0.5) |

多变量联合分布图
| penguins=pd.read_csv('C:\\work\\penguins.csv') |
| penguins.head() |
点击查看详情

点击查看详情

| sns.pairplot(penguins, hue="species") |
点击查看详情

| sns.pairplot(penguins, kind="hist") |
点击查看详情

| |
| sns.pairplot(penguins,height=1.5) |
点击查看详情

| |
| sns.pairplot( |
| penguins, |
| x_vars=["bill_length_mm","bill_depth_mm"], |
| y_vars=["bill_length_mm","bill_depth_mm"] |
| ) |
点击查看详情

| sns.jointplot(data=penguins,x="bill_length_mm", y="bill_depth_mm") |
点击查看详情

| sns.jointplot(data=penguins, x="bill_length_mm", y="bill_depth_mm", hue="sex") |
点击查看详情

| |
| sns.jointplot(data=penguins, x="bill_length_mm", y="bill_depth_mm", kind="reg") |
点击查看详情

| sns.jointplot(data=penguins, x="bill_length_mm", y="bill_depth_mm", kind="hex") |
点击查看详情

| # ['scatter', 'hist', 'hex', 'kde', 'reg', 'resid'] |
| |
| sns.jointplot(data=penguins, x="bill_length_mm", y="bill_depth_mm", kind="scatter") |
点击查看详情

回归图
| mpg=pd.read_csv('C:\\work\\mpg.csv') |
| mpg.head() |
点击查看详情

| |
| sns.regplot(data=mpg, x="weight", y="acceleration") |
点击查看详情

| sns.regplot(data=mpg, x="weight", y="acceleration", order=2) |
点击查看详情

| sns.regplot(data=mpg, x="weight", y="acceleration", order=3) |
点击查看详情

| |
| |
| sns.regplot( |
| data=mpg, x="weight", y="acceleration", |
| marker="x", color=".3", line_kws=dict(color="red") |
| ) |
点击查看详情

| penguins=pd.read_csv('C:\\work\\penguins.csv') |
| penguins.head() |
点击查看详情

| |
| sns.lmplot( |
| data=penguins, x="bill_length_mm", y="bill_depth_mm", |
| col="species",row="sex", height=3 |
| ) |
点击查看详情

| sns.lmplot( |
| data=penguins, x="bill_length_mm", y="bill_depth_mm", |
| hue="species", col="sex", height=4, |
| ) |
点击查看详情

多绘图网格
| tips=pd.read_csv('C:\\work\\tips.csv') |
| tips.head() |
点击查看详情

| sns.FacetGrid(tips, col="time", row="sex") |
点击查看详情

| g = sns.FacetGrid(tips, col="time", row="sex") |
| g.map(sns.scatterplot, "total_bill","tip") |
点击查看详情

| g=sns.FacetGrid(tips, col="time", hue="sex") |
| g.map_dataframe(sns.scatterplot, x="total_bill", y="tip") |
| g.add_legend() |
| |
点击查看详情

【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?