亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何在 Plotly 中增加平面的大小

如何在 Plotly 中增加平面的大小

MM們 2023-02-07 13:56:54
得到以下代碼import pandas as pdimport plotly.graph_objects as goimport numpy as npdf = pd.read_csv('https://raw.githubusercontent.com/tiago-peres/immersion/master/Platforms_dataset.csv')fig = px.scatter_3d(df, x='Functionality ', y='Accessibility', z='Immersion', color='Platforms')grey = [[0,'#C0C0C0'],[1,'#C0C0C0']]zero_pt = pd.Series([0])z = zero_pt.append(df['Immersion'], ignore_index = True).reset_index(drop = True)y = zero_pt.append(df['Accessibility'], ignore_index = True).reset_index(drop = True)x = zero_pt.append(df['Functionality '], ignore_index = True).reset_index(drop = True)length_data = len(z)z_plane_pos = 66.5*np.ones((length_data,length_data))fig.add_trace(go.Surface(x=x, y=y, z=z_plane_pos, colorscale=grey,  showscale=False))fig.add_trace(go.Surface(x=x.apply(lambda x: 15.69), y=y, z = np.array([z]*length_data), colorscale= grey, showscale=False))fig.add_trace(go.Surface(x=x, y= y.apply(lambda x: 55), z =  np.array([z]*length_data).transpose(), colorscale=grey, showscale=False))fig.update_layout(scene = dict(        xaxis = dict(nticks=4, range=[0,31.38],),        yaxis = dict(nticks=4, range=[0,110],),        zaxis = dict(nticks=4, range=[0,133],),),        legend_orientation="h",margin=dict(l=0, r=0, b=0, t=0))可以在產生以下輸出的 Google Colab 中打開如您所見,平面沒有填滿整個軸空間,它們應該符合軸范圍。換句話說,飛機z=66.5 - 應該存在于 x 的 [0, 31.38] 和 y 的 [0, 110] 之間x=15.59 - 應該存在于 y 中的 [0, 110] 和 z 中的 [0, 133] 之間y=55 - 應該存在于 x 的 [0, 31.38] 和 z 的 [0, 133] 之間那怎么辦?
查看完整描述

1 回答

?
慕雪6442864

TA貢獻1812條經驗 獲得超5個贊

問題是我繪制的陣列形狀不正確。

通過適當地拆分創建輸入數組和繪圖的位,能夠發現這一點,并因此制作了正確大小和適當內容的輸入數組(用于繪圖)。

http://img1.sycdn.imooc.com//63e1e8560001051d06550424.jpg

import plotly.express as px

import pandas as pd

import plotly.graph_objects as go

import numpy as np


df = pd.read_csv('https://raw.githubusercontent.com/tiago-peres/immersion/master/Platforms_dataset.csv')


zero_pt = pd.Series([0])

z1 = np.arange(0, 134, 1)

y1 = np.arange(0, 111, 1)

x1 = np.arange(0, 32.38, 1)

z = zero_pt.append(df['Immersion'], ignore_index = True).reset_index(drop = True)

y = zero_pt.append(df['Accessibility'], ignore_index = True).reset_index(drop = True)

x = zero_pt.append(df['Functionality '], ignore_index = True).reset_index(drop = True)


test1 = pd.Series([133])

test = z.append(test1)


length_data1 = len(z1)

z_plane_pos = 66.5*np.ones((length_data1,length_data1))

length_data2 = len(y1)

y_plane_pos = 55*np.ones((length_data2,length_data2))

length_data3 = len(x1)

x_plane_pos = 15.69*np.ones((length_data3,length_data3))


xvals = x.apply(lambda x: 15.69)

xvals2 = x1

yvals = y1

yvals2 = y.apply(lambda x: 55)

zvals = np.zeros((len(yvals), len(xvals)))

zvals[:, -1] = 133 #  np.array([test]*length_data2)

zvals2 = np.zeros((len(yvals2), len(xvals2)))

zvals2[-1, :] = 133


fig = px.scatter_3d(df, x='Functionality ', y='Accessibility', z='Immersion', color='Platforms')

grey = [[0,'#C0C0C0'],[1,'#C0C0C0']]


fig.add_trace(go.Surface(x=x1, y=y1, z=z_plane_pos, colorscale=grey,  showscale=False))

fig.add_trace(go.Surface(x=xvals, y=yvals, z = zvals, colorscale= grey, showscale=False))

fig.add_trace(go.Surface(x=xvals2, y=yvals2, z = zvals2, colorscale=grey, showscale=False))


fig.update_layout(scene = dict(

        xaxis = dict(nticks=4, range=[0,31.38],),

        yaxis = dict(nticks=4, range=[0,110],),

        zaxis = dict(nticks=4, range=[0,133],),),

        legend_orientation="h",margin=dict(l=0, r=0, b=0, t=0))

看這里。



查看完整回答
反對 回復 2023-02-07
  • 1 回答
  • 0 關注
  • 158 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號