【Plotly-驯化】一文教你通过plotly画出动态可视化多变量分析:create_scatterplotmatrix

【Plotly-驯化】一文教你通过plotly画出动态可视化多变量分析:create_scatterplotmatrix
 
本次修炼方法请往下查看
在这里插入图片描述

🌈 欢迎莅临我的个人主页 👈这里是我工作、学习、实践 IT领域、真诚分享 踩坑集合,智慧小天地!
🎇 免费获取相关内容文档关注:微信公众号,发送 pandas 即可获取
🎇 相关内容视频讲解 B站

🎓 博主简介:AI算法驯化师,混迹多个大厂搜索、推荐、广告、数据分析、数据挖掘岗位 个人申请专利40+,熟练掌握机器、深度学习等各类应用算法原理和项目实战经验

🔧 技术专长: 在机器学习、搜索、广告、推荐、CV、NLP、多模态、数据分析等算法相关领域有丰富的项目实战经验。已累计为求职、科研、学习等需求提供近千次有偿|无偿定制化服务,助力多位小伙伴在学习、求职、工作上少走弯路、提高效率,近一年好评率100%

📝 博客风采: 积极分享关于机器学习、深度学习、数据分析、NLP、PyTorch、Python、Linux、工作、项目总结相关的实用内容。

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 


下滑查看解决方法

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

  

🎯 1. 基本介绍

  create_scatterplotmatrix 是 Plotly 中的一个函数,用于创建散点图矩阵,它允许用户在一个图表中可视化数据集中多个变量之间的两两关系。这对于初步的数据探索和理解变量间的相关性非常有用。

🔍 2. 原理介绍

  散点图矩阵背后的数学原理是简单的:对于每一对变量,它绘制一个散点图,其中一变量作为 x 轴,另一变量作为 y 轴。没有特定的公式推导,但是理解散点图中的相关性、趋势和异常值对于分析是有帮助的。

🔍 3. 画图实践

3.1 数据准备

   我们准备的数据格式如下所示:

# plotly standard imports
import plotly.graph_objs as go
import chart_studio.plotly as py

# Cufflinks wrapper on plotly
import cufflinks

# Data science imports
import pandas as pd
import numpy as np

# Options for pandas
pd.options.display.max_columns = 30

# Display all cell outputs
from IPython.core.interactiveshell import InteractiveShell

InteractiveShell.ast_node_interactivity = "all"

from plotly.offline import iplot
import time
cufflinks.go_offline()

# Set global theme
cufflinks.set_config_file(world_readable=True, theme="pearl")


	claps	days_since_publication	fans	link	num_responses	publication	published_date	read_ratio	read_time	reads	started_date	tags	text	title	title_word_count	type	views	word_count	claps_per_word	editing_days	<tag>Education	<tag>Data Science	<tag>Towards Data Science	<tag>Machine Learning	<tag>Python
119	2	574.858594	2	https://medium.com/p/screw-the-environment-but...	0	None	2017-06-10 14:25:00	41.98	7	68	2017-06-10 14:24:00	[Climate Change, Economics]	Screw the Environment, but Consider Your Walle...	Screw the Environment, but Consider Your Wallet	8	published	162	1859	0.001076	0	0	0	0	0	0
118	18	567.540639	3	https://medium.com/p/the-vanquishing-of-war-pl...	0	None	2017-06-17 22:02:00	32.93	14	54	2017-06-17 22:02:00	[Climate Change, Humanity, Optimism, History]	The Vanquishing of War, Plague and Famine Part...	The Vanquishing of War, Plague and Famine	8	published	164	3891	0.004626	0	0	0	0	0	0
121	50	554.920762	19	https://medium.com/p/capstone-project-mercedes...	0	None	2017-06-30 12:55:00	20.19	42	215	2017-06-30 12:00:00	[Machine Learning, Python, Udacity, Kaggle]	Capstone Project: Mercedes-Benz Greener Manufa...	Capstone Project: Mercedes-Benz Greener Manufa...	7	published	1065	12025	0.004158	0	0	0	0	1	1
122	0	554.078160	0	https://medium.com/p/home-of-the-scared-5af0fe...	0	None	2017-07-01 09:08:00	35.85	9	19	2017-06-30 18:21:00	[Politics, Books, News, Media Criticism]	Home of the Scared A review of A Culture of Fe...	Home of the Scared	4	published	53	2533	0.000000	0	0	0	0	0	0
114	0	550.090507	0	https://medium.com/p/the-triumph-of-peace-f485...	0

3.2 画图实践

   我们根据上述的数据画出不同种类的统计柱状图,具体的代码如下所示:

import plotly.figure_factory as ff

figure = ff.create_scatterplotmatrix(
    df[["claps", "publication", "views", "read_ratio", "word_count"]],
    height=1000,
    width=1000,
    text=df["title"],
    diag="histogram",
    index="publication",
)
iplot(figure)

在这里插入图片描述

🔍 4. 注意事项

  • create_scatterplotmatrix 函数是 Plotly Express 模块的一部分,它提供了一个高级接口来绘制散点图矩阵。
  • 通过 dimensions 参数指定要包含在散点图矩阵中的变量。
  • color 参数用于指定一个分类变量,以便在散点图中以不同颜色区分不同的类别。
  • 散点图矩阵可以变得相当复杂,特别是当变量数量较多时。确保图表的可读性,可能需要调整大小、颜色和标签。

🔍 5. 总结

  Plotly 的 create_scatterplotmatrix 函数是一个强大的工具,用于快速探索多个变量之间的关系。通过本博客的代码示例,我们学习了如何使用这个函数绘制散点图矩阵,并分析了数据集中变量间的相互作用。希望这篇博客能够帮助你更好地利用 Plotly 进行多变量数据的可视化分析。

  • 17
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

算法驯化师

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值