Plotly 布局 Z 轴配置
Plotly layout Z-axes config
如何在graph_object.layout
中设置Z轴的高度
我试过使用
zaxis: {
showgrid: true,
zeroline: true,
linecolor: '#d7d7d7',
linewidth: 1,
tickfont: {size: 12},
ticks: 'outside',
tickcolor: '#d7d7d7',
tickformat: '.0f',
scaleanchor: 'x',
range: 5,
rangemode: 'normal',
dtick: 'tick0'
}
您需要设置aspectmode
和aspectratio
。例如:
import plotly.graph_objects as go
import numpy as np
x = np.random.uniform(0, 1, 100)
y = np.random.uniform(0, 1, 100)
z = np.random.uniform(0, 1, 100)
fig1 = go.Figure([
go.Scatter3d(x=x, y=y, z=z, marker_size=3)
])
fig2 = go.Figure([
go.Scatter3d(x=x, y=y, z=z, marker_size=3)
], layout={"scene": {"aspectmode": "manual", "aspectratio": {"x": 1, "y": 1, "z": 0.25}}})
如何在graph_object.layout
中设置Z轴的高度我试过使用
zaxis: {
showgrid: true,
zeroline: true,
linecolor: '#d7d7d7',
linewidth: 1,
tickfont: {size: 12},
ticks: 'outside',
tickcolor: '#d7d7d7',
tickformat: '.0f',
scaleanchor: 'x',
range: 5,
rangemode: 'normal',
dtick: 'tick0'
}
您需要设置aspectmode
和aspectratio
。例如:
import plotly.graph_objects as go
import numpy as np
x = np.random.uniform(0, 1, 100)
y = np.random.uniform(0, 1, 100)
z = np.random.uniform(0, 1, 100)
fig1 = go.Figure([
go.Scatter3d(x=x, y=y, z=z, marker_size=3)
])
fig2 = go.Figure([
go.Scatter3d(x=x, y=y, z=z, marker_size=3)
], layout={"scene": {"aspectmode": "manual", "aspectratio": {"x": 1, "y": 1, "z": 0.25}}})