多面 px.line 图中 y 轴的大小不起作用
Size of y axis in faceted px.line graph not working
我正在尝试修改每个方面子图的 y 轴标签的大小
fig.update_yaxes(matches=None, title_font=dict(size=17), row=5, title='abc', title_standoff=0)
fig.update_yaxes(matches=None, title_font=dict(size=7), row=6, title='abc', title_standoff=0)
但大小似乎没有改变:
- 已生成样本数据以创建多面线图
- 关键是每个方面都有自己的 yaxis
- 使用
update_layout()
根据您的代码示例统一修改。除字体大小外,一切都是不变的。
df = pd.concat(
[
pd.DataFrame(
{"x": np.linspace(0, 99, 100), "y": np.random.uniform(1, 3, 100)}
).assign(facet=f)
for f in range(2)
]
)
px.line(df, x="x", y="y", facet_row="facet").update_layout(
{
ax: {"matches": None, "title": {"text": "abc", "font": {"size": s}, "standoff":0}}
for ax, s in zip(["yaxis", "yaxis2"], [17, 7])
}
)
我正在尝试修改每个方面子图的 y 轴标签的大小
fig.update_yaxes(matches=None, title_font=dict(size=17), row=5, title='abc', title_standoff=0)
fig.update_yaxes(matches=None, title_font=dict(size=7), row=6, title='abc', title_standoff=0)
但大小似乎没有改变:
- 已生成样本数据以创建多面线图
- 关键是每个方面都有自己的 yaxis
- 使用
update_layout()
根据您的代码示例统一修改。除字体大小外,一切都是不变的。
df = pd.concat(
[
pd.DataFrame(
{"x": np.linspace(0, 99, 100), "y": np.random.uniform(1, 3, 100)}
).assign(facet=f)
for f in range(2)
]
)
px.line(df, x="x", y="y", facet_row="facet").update_layout(
{
ax: {"matches": None, "title": {"text": "abc", "font": {"size": s}, "standoff":0}}
for ax, s in zip(["yaxis", "yaxis2"], [17, 7])
}
)