【问题标题】:remove titles plotly python删除标题情节python
【发布时间】:2020-08-30 06:45:56
【问题描述】:

如何删除下图中的标题?

我想删除顶部轴标题,因为它们对于图片来说是多余的并且太长了。

这是我正在使用的代码:

import plotly.express as px

fig = px.box(DF.melt(), y="value", facet_col="variable", boxmode="overlay", color="variable")
fig.update_yaxes(matches=None)

for i in range(len(fig["data"])):
    yaxis_name = 'yaxis' if i == 0 else f'yaxis{i + 1}'
    fig.layout[yaxis_name].showticklabels = True
    #fig.update_layout(showlegend=False)


fig.update_layout(legend = dict(bgcolor = 'white'))
fig.update_layout(plot_bgcolor='white')

fig.update_xaxes(showline=True, linewidth=2, linecolor='black')#, mirror=True)
fig.update_yaxes(showline=True, linewidth=2, linecolor='black')#, mirror=True)

fig.update_xaxes(showgrid=True, gridwidth=1, gridcolor='gray')
fig.update_yaxes(showgrid=True, gridwidth=1, gridcolor='gray')

fig.show()

【问题讨论】:

  • 我认为这个问题在这个question中得到了回答。

标签: python plotly


【解决方案1】:

您必须遍历标签才能将文本更新为空“”。 将其包含在您的代码中:

fig.for_each_annotation(lambda a: a.update(text=""))

这是similar question responded

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-06-18
    • 2012-08-04
    • 2013-03-01
    • 2012-11-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多