简体   繁体   English

plotly 渲染错误与 python 3d plot

[英]plotly rendering bug with python 3d plot

I am using plotly and python to visualize 3D data and I encoutered a strange phenomenon when plotting some data.我正在使用plotlypython来可视化 3D 数据,并且在绘制一些数据时遇到了一个奇怪的现象。 The following code visualizes data of the form (3,20) each for the direction x,y and z.以下代码可视化 x、y 和 z 方向的(3,20)形式的数据。

import numpy as np
import plotly.io as pio
import plotly.graph_objects as go

data = np.array([
    [4.41568822e+05, 4.41568474e+05, 4.41567958e+05, 4.41567603e+05,
     4.41567249e+05, 4.41566952e+05, 4.41566619e+05, 4.41566324e+05,
     4.41566021e+05, 4.41565737e+05, 4.41565435e+05, 4.41565098e+05,
     4.41564807e+05, 4.41564472e+05, 4.41564121e+05, 4.41563860e+05,
     4.41563538e+05, 4.41563226e+05, 4.41562933e+05, 4.41562641e+05],
    [5.71148897e+06, 5.71148909e+06, 5.71148928e+06, 5.71148942e+06,
     5.71148955e+06, 5.71148967e+06, 5.71148981e+06, 5.71148993e+06,
     5.71149006e+06, 5.71149019e+06, 5.71149032e+06, 5.71149047e+06,
     5.71149060e+06, 5.71149076e+06, 5.71149093e+06, 5.71149106e+06,
     5.71149122e+06, 5.71149137e+06, 5.71149153e+06, 5.71149168e+06],
    [1.86559470e+02, 1.86547226e+02, 1.86529120e+02, 1.86516642e+02,
     1.86504156e+02, 1.86493615e+02, 1.86481706e+02, 1.86471064e+02,
     1.86460026e+02, 1.86449593e+02, 1.86438417e+02, 1.86425803e+02,
     1.86414828e+02, 1.86402073e+02, 1.86388572e+02, 1.86378511e+02,
     1.86366018e+02, 1.86353893e+02, 1.86342497e+02, 1.86331154e+02]])

fig = go.Figure(data=[go.Scatter3d(x=data[0,:], y=data[1,:], z=data[2,:],
                                   mode='markers',
                                   marker=dict(size=3),
                                   )])

pio.show(fig, renderer='browser')

I have compared the result (top) below with a matplotlib plot of the same data (bottom).我将下面的结果(顶部)与相同数据(底部)的 matplotlib plot 进行了比较。

The points that represent a relatively straight line are represented in Plotly in steps rather than in a line, and I don't really understand why.代表一条相对直线的点在 Plotly 中是按步骤而不是在一条线中表示的,我真的不明白为什么。

Can someone explain to me why the points are displayed like this in plotly and how I can fix this problem?有人可以向我解释为什么这些点在 plotly 中会这样显示,我该如何解决这个问题? I appreciate any help I can get!我很感激我能得到的任何帮助!

It looks like an issue with how Plotly is interpreting your numpy array. Plotly 如何解释您的 numpy 数组似乎存在问题。 Your arrays look to be nested which would explain why instead of plotly drawing the plot as a continuous line they are being rendered as steps.您的 arrays 看起来是嵌套的,这可以解释为什么不是 plotly 将 plot 绘制为连续线,而是将它们呈现为步骤。

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

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