![](/img/trans.png)
[英]Problem to diplay a 3d mesh using alphahull >0 with plotly in jupyter notebook
[英]Plotly: Panning 3D figure programmatically in jupyter notebook
我不知道如何使用代碼平移我的 Plotly 圖像。
我運行以下代碼
# Creating the plot
import plotly.graph_objects as go
surface = go.Surface(x=AddOnMesh, y=CMesh, z=Matrix)
data = [surface]
layout = go.Layout(
title='Depiction of the SA-CCR multiplier function',
scene=dict(
xaxis=dict(
gridcolor='rgb(255, 255, 255)',
zerolinecolor='rgb(255, 255, 255)',
showbackground=True,
backgroundcolor='rgb(230, 230,230)',
autorange='reversed'
),
yaxis=dict(
gridcolor='rgb(255, 255, 255)',
zerolinecolor='rgb(255, 255, 255)',
showbackground=True,
backgroundcolor='rgb(230, 230,230)'
),
zaxis=dict(
gridcolor='rgb(255, 255, 255)',
zerolinecolor='rgb(255, 255, 255)',
showbackground=True,
backgroundcolor='rgb(230, 230,230)'
),
xaxis_title = 'AddOn / V',
yaxis_title = 'C / V',
zaxis_title = 'Multiplier',
)
)
fig = go.Figure(data=data, layout=layout)
fig.show()
這會產生以下圖像:
如您所見,底部已被切斷。 通過手動稍微向上平移它,我可以讓它看起來像這樣:
如何使用代碼實現相同的結果,例如通過更改我正在使用的布局。 手動調整不是一個選項,因為我在下一步中直接使用fig.to_image()
轉換圖像。
您可以通過編輯 eye 參數來自由更改相機 position :
camera = dict(eye=dict(x=2, y=2, z=0.1))
fig.update_layout(scene_camera=camera)
您可以通過將 z 設置為較小的值來降低視點。 下圖將z=1.5
與z=0.1
進行了比較。
我希望這與您的數據集相得益彰。 如果沒有,那么請提供您的數據樣本,我再看看。
就我而言, 3D 相機控件的center
參數產生了我想要的結果。
camera = dict(
center=dict(x=0, y=0, z=-0.1)
)
fig = go.Figure(data=data, layout=layout)
fig.update_layout(scene_camera=camera)
fig.show()
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.