详解pandas绘制矩阵散点图(scatter_matrix)的方法
作者:王昕 时间:2022-06-09 18:52:34
使用散点图矩阵图,可以两两发现特征之间的联系
pd.plotting.scatter_matrix(frame, alpha=0.5, c,figsize=None, ax=None, diagonal='hist', marker='.', density_kwds=None,hist_kwds=None, range_padding=0.05, **kwds)
1、frame,pandas dataframe对象
2、alpha, 图像透明度,一般取(0,1]
3、figsize,以英寸为单位的图像大小,一般以元组 (width, height) 形式设置
4、ax,可选一般为none
5、diagonal,必须且只能在{‘hist', ‘kde'}中选择1个,'hist'表示直方图(Histogram plot),'kde'表示核密度估计(Kernel Density Estimation);该参数是scatter_matrix函数的关键参数
6、marker,Matplotlib可用的标记类型,如'.',',','o'等
7、density_kwds,(other plotting keyword arguments,可选),与kde相关的字典参数
8、hist_kwds,与hist相关的字典参数
9、range_padding,(float, 可选),图像在x轴、y轴原点附近的留白(padding),该值越大,留白距离越大,图像远离坐标原点
10、kwds,与scatter_matrix函数本身相关的字典参数
11、c,颜色
效果如下图
以 sklearn的iris样本为数据集
import matplotlib.pyplot as plt
from scipy import sparse
import numpy as np
import matplotlib as mt
import pandas as pd
from IPython.display import display
from sklearn.datasets import load_iris
import sklearn as sk
from sklearn.model_selection import train_test_split
iris=load_iris()
#print(iris)
X_train,X_test,y_train,y_test = train_test_split(iris['data'],iris['target'],random_state=0)
iris_dataframe = pd.DataFrame(X_train,columns=iris.feature_names)
grr = pd.plotting.scatter_matrix(iris_dataframe,c=y_train,figsize=(15,15),marker='o',hist_kwds={'bins':20},s=60,alpha=.8)
plt.show()
来源:https://www.cnblogs.com/starcrm/p/11672331.html
标签:pandas,scatter,matrix,矩阵散点图
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
sqlserver 修改列名及表名的sql语句
2012-07-11 15:58:46
简单了解Python3里的一些新特性
2022-09-22 21:32:23
python开发的自动化运维工具ansible详解
2022-12-11 08:40:00
![](https://img.aspxhome.com/file/2023/8/64298_0s.jpg)
Python探索之修改Python搜索路径
2021-06-26 20:47:09
Flask框架单例模式实现方法详解
2023-01-24 17:04:55
Python读取excel指定列生成指定sql脚本的方法
2021-05-06 19:11:13
纯CSS图片预加载
2009-10-28 18:40:00
python list 查询是否存在并且并返回下标的操作
2023-06-20 12:05:43
![](https://img.aspxhome.com/file/2023/5/84105_0s.jpg)
opencv实现图像旋转效果
2023-07-17 13:28:40
![](https://img.aspxhome.com/file/2023/4/61444_0s.jpg)
Python设置Word全局样式和文本样式的示例代码
2022-06-29 05:06:07
![](https://img.aspxhome.com/file/2023/8/82558_0s.jpg)
Python之tkinter组合框Combobox用法及说明
2022-09-27 20:29:59
![](https://img.aspxhome.com/file/2023/4/95854_0s.gif)
Python网络编程之TCP与UDP协议套接字用法示例
2023-12-07 06:34:45
Python中的xlrd模块使用整理
2023-03-30 17:35:04
![](https://img.aspxhome.com/file/2023/7/65997_0s.png)
全面理解javascript的caller,callee,call,apply概念
2007-12-02 17:44:00
python matplotlib:plt.scatter() 大小和颜色参数详解
2021-09-26 04:56:28
![](https://img.aspxhome.com/file/2023/4/93474_0s.jpg)
python人工智能tensorflow常见损失函数LOSS汇总
2023-11-22 18:12:48
![](https://img.aspxhome.com/file/2023/7/64277_0s.png)
python时间与Unix时间戳相互转换方法详解
2023-07-11 02:09:12
python脚本开机自启的实现方法
2023-10-04 17:07:15
Mysql中explain的使用详解
2009-12-08 16:18:00
python中字符串的操作方法大全
2023-10-01 17:47:15