gpt4 book ai didi

plotly - 是否可以在绘图中执行 "pair plot"?

转载 作者:行者123 更新时间:2023-12-03 08:02:07 25 4
gpt4 key购买 nike

在Python的plotly中,是否有办法在x轴上使用多个变量对y轴上的单个变量进行绘图? scatter_matrix 函数使用每个变量组合,但我正在寻找 y 轴上的单个变量。在seaborn中,下面的图很容易用pairplot生成,但是可以用plotly完成吗?

enter image description here

最佳答案

您可以使用px.scatter_matrix

Plotly scatter_matrix Documentation

编辑:抱歉,错过了 x 轴部分。

最简单的方法是使用 facet_col 参数。

import plotly.express as px
from plotly.subplots import make_subplots

df = px.data.iris()

fig = px.scatter(df,
x = 'sepal_length',
y = 'petal_length',
color = 'species',
facet_col= 'species',
template = 'plotly_dark'
)

fig.show()

enter image description here

关于plotly - 是否可以在绘图中执行 "pair plot"?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73823919/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com