Plotly:如何用白色背景显示 x 轴和 y 轴的线?
Plotly: How to show line for x and y axes with white background?
我在隐藏背景的同时使用plotly
paper_bgcolor='rgba(255,255,255,1)',
plot_bgcolor='rgba(255,255,255,1)',
不幸的是,阅读布局的参考指南,我无法添加轴(只有左侧和底部的 xy 线。
完整代码:
fig = px.box(pd_data, x="Epoch", y="Cosine similarity", color="Type",
notched=True, # used notched shape
title="Box plot of Cos similarity",
hover_data=["Pair"] # add day column to hover data
)
fig.update_layout(title_text="",
paper_bgcolor='rgba(255,255,255,1)',\
plot_bgcolor='rgba(255,255,255,1)',\
title_font_size=30)
结果:
您尚未共享数据样本,因此我将不得不使用 box-plots/ 中的设置。在任何情况下,您所要做的就是为两个轴设置 showline=True
,如下所示:
fig.update_xaxes(showline=True, linewidth=2, linecolor='black')
fig.update_yaxes(showline=True, linewidth=2, linecolor='black')
剧情:
代码:
import plotly.express as px
df = px.data.tips()
fig = px.box(df, x="time", y="total_bill", points="all")
f = fig.full_figure_for_development(warn=False)
fig.update_layout(title_text="",
paper_bgcolor='rgba(255,255,255,1)',\
plot_bgcolor='rgba(255,255,255,1)',\
title_font_size=30)
fig.update_xaxes(showline=True, linewidth=2, linecolor='black')
fig.update_yaxes(showline=True, linewidth=2, linecolor='black')
fig.show()
我在隐藏背景的同时使用plotly
paper_bgcolor='rgba(255,255,255,1)',
plot_bgcolor='rgba(255,255,255,1)',
不幸的是,阅读布局的参考指南,我无法添加轴(只有左侧和底部的 xy 线。 完整代码:
fig = px.box(pd_data, x="Epoch", y="Cosine similarity", color="Type",
notched=True, # used notched shape
title="Box plot of Cos similarity",
hover_data=["Pair"] # add day column to hover data
)
fig.update_layout(title_text="",
paper_bgcolor='rgba(255,255,255,1)',\
plot_bgcolor='rgba(255,255,255,1)',\
title_font_size=30)
结果:
您尚未共享数据样本,因此我将不得不使用 box-plots/ 中的设置。在任何情况下,您所要做的就是为两个轴设置 showline=True
,如下所示:
fig.update_xaxes(showline=True, linewidth=2, linecolor='black')
fig.update_yaxes(showline=True, linewidth=2, linecolor='black')
剧情:
代码:
import plotly.express as px
df = px.data.tips()
fig = px.box(df, x="time", y="total_bill", points="all")
f = fig.full_figure_for_development(warn=False)
fig.update_layout(title_text="",
paper_bgcolor='rgba(255,255,255,1)',\
plot_bgcolor='rgba(255,255,255,1)',\
title_font_size=30)
fig.update_xaxes(showline=True, linewidth=2, linecolor='black')
fig.update_yaxes(showline=True, linewidth=2, linecolor='black')
fig.show()