2

How can I remove the titles in the following pic?

I would like to remove top axis titles since they are redundant and too long for the pic.

enter image description here

This is the code I am using:

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()
JohanC
  • 71,591
  • 8
  • 33
  • 66
Newbie
  • 451
  • 1
  • 3
  • 14
  • I think the question is answered in this [question](https://stackoverflow.com/questions/61693014/how-to-hide-plotly-yaxis-title-in-python). – flaxel Aug 29 '20 at 21:56

1 Answers1

1

You will have to iterate over the labels to update the text to empty " ". Include this in your code:

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

Here is a similar question responded

gurezende
  • 176
  • 9