我有900k +行和28列的数据框。我正在使用我在密谋官方网站的at this example中找到的以下代码段:
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'
dtype。我正在jupyter笔记本中运行它。当我运行此代码时,一切似乎都正常,但我却显示以下警告:
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次。在基于网络浏览器的用户界面(如jupyter笔记本)中进行绘图时,似乎存在一些限制。
我试图导入模块'plotly.graph_objs.Scattergl',但是它说pyplot中没有这样的模块。
我只是不知道如何解决此限制。万一无法做到这一点,我该如何使用
matplotlib
进行类似的绘图?任何帮助都感激不尽。非常感谢你
最佳答案
也许您打错电话Scattergl
...检查here。
我认为这是您要寻找的(示例摘自文档):
import plotly.graph_objs as go
trace = go.Scattergl(...)
希望能帮助到你
关于python - 密谋-在密谋上绘制k均值聚类将不起作用,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/53073256/