我试着去理解这到底意味着什么,但没能做到这一点
我使用下面的代码来理解它。如果删除所有覆盖参数,则只会显示第四个。如果我删除其中一个,则只有该轴可见。我不能对这种行为发表任何声明。不
If set a same-letter axis id, this axis is overlaid on top of the corresponding same-letter axis, with traces and axes visible for both axes. If "False", this axis does not overlay any same-letter axes. In this case, for axes with overlapping domains only the highest-numbered axis will be visible.
文档对我来说也没什么意义。有人能解密这个解释吗?谢谢
import plotly.graph_objects as go
fig = go.Figure()
fig.add_trace(go.Scatter(
x=[1, 2, 3],
y=[4, 5, 6],
name="yaxis1 data"
))
fig.add_trace(go.Scatter(
x=[2, 3, 4],
y=[40, 50, 60],
name="yaxis2 data",
yaxis="y2"
))
fig.add_trace(go.Scatter(
x=[4, 5, 6],
y=[40000, 50000, 60000],
name="yaxis3 data",
yaxis="y3"
))
fig.add_trace(go.Scatter(
x=[5, 6, 7],
y=[400000, 500000, 600000],
name="yaxis4 data",
yaxis="y4"
))
# Create axis objects
fig.update_layout(
xaxis=dict(
domain=[0.3, 0.7]
),
yaxis=dict(
title="yaxis title",
titlefont=dict(
color="#1f77b4"
),
tickfont=dict(
color="#1f77b4"
)
),
yaxis2=dict(
title="yaxis2 title",
titlefont=dict(
color="#ff7f0e"
),
tickfont=dict(
color="#ff7f0e"
),
anchor="free",
overlaying="y",
side="left",
position=0.15
),
yaxis3=dict(
title="yaxis3 title",
titlefont=dict(
color="#d62728"
),
tickfont=dict(
color="#d62728"
),
anchor="x",
overlaying="y",
side="right"
),
yaxis4=dict(
title="yaxis4 title",
titlefont=dict(
color="#9467bd"
),
tickfont=dict(
color="#9467bd"
),
anchor="free",
overlaying="y",
side="right",
position=0.85
)
)
# Update layout properties
fig.update_layout(
title_text="multiple y-axes example",
width=800,
)
fig.show()
下面是我删除所有“覆盖”参数时的结果演示。 还有一件事需要注意,我已经看到多个散射迹线在同一个图中,没有提到叠加。我知道这与轴有关,但也许我错过了一些关于当有多个轴时会发生什么的基本知识,甚至可能是轴重叠的意义?这到底是什么意思?谢谢
我认为这是它的工作方式。创建第二个轴(例如,第二个y轴)时,基本上创建一个新的子图,该子图在与第一个y轴的子图相同的位置进行渲染
因此,只有第二个(或最后一个)子批次可见。在您的例子中,这意味着当删除
overlaying
参数时,您只会看到最后一个散点,即附加到y轴#4的散点。但是,这不是你通常想要的。在大多数情况下,您希望来自所有重叠子地块的所有散射体在同一时间可见。这就是为什么要指定overlaying=
参数。它告诉plotly不要“隐藏”较低的子图,而是使除底部子图之外的所有子图都“透明”——因此,所有子图都覆盖并可见希望这有帮助
关于重叠here的含义有一个长时间的讨论
顺便说一句,有人可能会问,为什么不把所有的东西都覆盖起来呢。非覆盖也有一个用例:
相关问题 更多 >
编程相关推荐