我试图分别设置轴和标题的字体/大小。对于标题:字体= Ariel和大小= 12。对于Axis:字体= Times和size = 20。我使用下面的代码来完成它。
fig.update_layout(font=dict(family='Times New Roman',size=20,\
title=dict(font=dict(family='Ariel', size=12)))当我这样做,只有字体改变将生效,它将改变一切,但标题从来不做任何事情。谢谢你,祝你今天愉快
发布于 2022-07-27 02:23:13
在官方引用中有更改标题、轴标等的例子。基于这个例子,我进一步更改了标题的部分颜色和大小。此技巧将引用这里。
import plotly.express as px
df = px.data.iris()
fig = px.scatter(df, x="sepal_length", y="sepal_width", color="species",
title="Playing with <span style='font-size:22px;color:black;'>Fonts</span>")
fig.update_layout(
font_family="Courier New",
font_color="blue",
title_font_family="Times New Roman",
title_font_color="red",
legend_title_font_color="green"
)
fig.update_xaxes(title_font_family="Arial")
fig.show()

发布于 2022-11-12 09:21:48
若要设置轴刻度属性,可以提供包含以下一个或多个键的dict:
fig.update_xaxes(tickfont=dict(family="CMU Sans Serif Demi Condensed",
size=<SIZE>,
color=<COLOUR>) )
fig.update_yaxes(tickfont=dict(family="Lucida Console",
size=<SIZE>,
color=<COLOUR>) )https://stackoverflow.com/questions/73130052
复制相似问题