I’m trying to create 3d graphs of large data sets(~10 million data points), but for some reason the graph won’t render in plotly
, so I was wondering if anyone knew why and/or how to fix it.
To generate some sample data, I use:
import numpy as np
COUNT = 1_000_000
z = np.arange(COUNT)
x = np.cos(z/1000)
y = np.sin(z/1000)
To render in plotly
I run
import plotly
import plotly.graph_objs as go
plotly.offline.init_notebook_mode()
import plotly.io as pio
pio.renderers.default = 'iframe'
trace = go.Scatter3d(
x=x,
y=y,
z=z,
mode='markers',
marker={
'size': 10,
'opacity': 0.7,
}
)
layout = go.Layout(
margin={'l': 0, 'r': 0, 'b': 0, 't': 0}
)
data = [trace]
plot_figure = go.Figure(data=data, layout=layout)
# Render the plot.
plotly.offline.iplot(plot_figure)
which gets me a beautifully rendered, empty cube.
If I instead use matplotlib
:
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(projection='3d')
ax.scatter(x,y,z)
plt.show()
It renders fine, if a little ugly:
with COUNT = 100_000
, both render fine, showing that the problem is the amount of data.[!
I previously posted this to stack overflow, to no avail.