Python数据可视化-matplotlib and seaborn

作者:vinyyu
声明:版权所有,转载请注明出处,谢谢。

鸢尾花iris.csv文件

在这里插入图片描述

numpy, matplotlib, seaborn, pandas

#准备好需要的库
import numpy as np
import matplotlib.pyplot as plt  
import seaborn as sns 
import pandas as pd

plt.rcParams['font.sans-serif'] = ['SimHei']  # 解决中文显示问题-设置字体为黑体
plt.rcParams['axes.unicode_minus'] = False  # 解决保存图像是负号'-'显示为方块的问题

1 画线,set_style( ) set( )

sns.set_style("whitegrid")  
plt.plot(np.arange(10))  
plt.show() 

在这里插入图片描述

#set( )通过设置参数可以用来设置背景,调色板等,更加常用。
sns.set(style="white", palette="muted", color_codes=True)     #set( )设置主题,调色板更常用  
plt.plot(np.arange(10))  
plt.show() 

在这里插入图片描述

2 distplot( )直方图加强版,kdeplot( )密度曲线图

plt.rcParams['font.sans-serif'] = ['SimHei']  # 解决中文显示问题-设置字体为黑体
plt.rcParams['axes.unicode_minus'] = False  # 解决保存图像是负号'-'显示为方块的问题
df_iris = pd.read_csv('d:/iris.csv')  
fig, axes = plt.subplots(1,2)  
sns.distplot(df_iris['petal length'], ax = axes[0], kde = True, rug = True)        # kde 密度曲线  rug 边际毛毯  
sns.kdeplot(df_iris['petal length'], ax = axes[1], shade=True)                     # shade  阴影   
axes[0].set_title("加强直方图")
axes[1].set_title
  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值