简体   繁体   中英

Plotly library not showing markers in 3D scatter plot

In the default tutorial provided by plotly, the following produces a nice image, and has markers appearing on the plot (in accordance with https://plotly.com/python/3d-scatter-plots/#3d-scatter-plot-with-plotly-express ):

import plotly.graph_objects as go
import numpy as np

# Helix equation
t = np.linspace(0, 10, 50)
x, y, z = np.cos(t), np.sin(t), t

fig = go.Figure(data=[go.Scatter3d(x=x, y=y, z=z,mode='markers')])
fig.show()

However if I try to plot some random scatter as follows:

import plotly.graph_objects as go
import numpy as np

x = np.random.randn(10,1)
fig = go.Figure(data=[go.Scatter3d(x=x, y=x, z=x,mode='markers')])
fig.show()

Nothing shows. It is a blank axis with no markers appearing. Would anyone happen to know why?

I've tried to change dimensions, transpose, variable names etc, but still nothing?

It will work if you flatten the array, eg if you add x = x.flatten() before the plot.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM