删除标题python

问题描述

如何删除下图中的标题

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

enter image description here

这是我正在使用的代码

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,mirror=True)

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

fig.show()

解决方法

您将不得不遍历标签以将文本更新为空的“”。 将此包含在您的代码中:

  <span class="material-icons md-48">
    ...
  </span>

这里是similar question responded