簡體   English   中英

刪除標題 plotly python

[英]remove titles plotly python

如何刪除下圖中的標題?

我想刪除頂軸標題,因為它們是多余的並且對於圖片來說太長了。

在此處輸入圖像描述

這是我正在使用的代碼:

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()

您將不得不遍歷標簽以將文本更新為空“”。 將此包含在您的代碼中:

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

這是一個類似的問題回答

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM