gpt4 book ai didi

python - Plotly - 在 plotly 上绘制 k-means 集群是行不通的

转载 作者:太空宇宙 更新时间:2023-11-04 04:28:38 26 4
gpt4 key购买 nike

我有一个 900k+ 行和 28 列的数据框。我正在使用我在 at this example 中找到的代码片段在 plotly 官网:

import plotly.plotly as py
import pandas as pd

scatter = dict(
mode = "markers",
name = "y",
type = "scatter3d",
x = col1, y = col2, z = col3,
marker = dict( size=2, color="rgb(23, 190, 207)" )
)
clusters = dict(
alphahull = 7,
name = "y",
opacity = 0.1,
type = "mesh3d",
x = col1, y = col2, z = col3
)
layout = dict(
title = '3d point clustering',
scene = dict(
xaxis = dict( zeroline=False ),
yaxis = dict( zeroline=False ),
zaxis = dict( zeroline=False ),
)
)
fig = dict( data=[scatter, clusters], layout=layout )
# Use py.iplot() for IPython notebook
py.plot(fig, filename='3d point clustering')

我的 df 已经加载了。请注意,col2 具有 'object' 数据类型。

我在 jupyter notebook 中运行它。当我运行这段代码时,一切似乎都很顺利,但我却出现了这个警告:

UserWarning:

Woah there! Look at all those points! Due to browser limitations, the Plotly SVG drawing functions have a hard time graphing more than 500k data points for line charts, or 40k points for other types of charts. Here are some suggestions:
(1) Use the `plotly.graph_objs.Scattergl` trace object to generate a WebGl graph.
(2) Trying using the image API to return an image instead of a graph URL
(3) Use matplotlib
(4) See if you can create your visualization with fewer data points

If the visualization you're using aggregates points (e.g., box plot, histogram, etc.) you can disregard this warning.

此警告连续出现 7 次。看起来必须有一些限制才能在基于 Web 浏览器的 UI(如 jupyter 笔记本)中绘制此图。

我试图导入模块“plotly.graph_objs.Scattergl”,但它说在 pyplot 中没有这样的模块。

我只是不知道如何解决此限制。如果无法做到这一点,我如何使用 matplotlib 制作类似的图?任何帮助将不胜感激。

非常感谢

最佳答案

也许你错误地调用了Scattergl...检查here .

我认为这就是您要查找的内容(示例取自文档):

import plotly.graph_objs as go
trace = go.Scattergl(...)

希望对你有帮助

关于python - Plotly - 在 plotly 上绘制 k-means 集群是行不通的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53073256/

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