简体   繁体   English

Plotly 库未在 3D 散点图 plot 中显示标记

[英]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 ):在 plotly 提供的默认教程中,以下生成了一个很好的图像,并且在 plot 上出现了标记(根据Z5E056C500A1C4B6A7110B50D807BADE-scatter-5Z://plotly.com/dpython-scatter-d-3 -情节表达):

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:但是,如果我尝试 plot 一些随机分散如下:

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.如果您将数组展平,它将起作用,例如,如果您在 plot 之前添加x = x.flatten()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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