'How can I hide automatic x axis title in plotly to set my own, updating is also an option

I want to set a fitting x and y axis name on my px. box() graph, the problème is that the automatic name doesn't disappear:

fig1 = px.box(birth_price_box1["price"],
             log_x=False,
             color = birth_price_box1["birth"])

fig1.update_traces(hoverinfo='skip', 
                  hovertemplate = None
                 )

fig1.update_layout(
    title={
        'text': "montant total des achats en fonction de l'année de naissance",
        'y':0.95,
        'x':0.5,
        'xanchor': 'center',
        'yanchor': 'top'
    },
    
    xaxis_title = "année",
    yaxis_title = "montant total (€)",
)

fig1.show()

the result : boxplot

enter image description here



Solution 1:[1]

Building on this example, you can just include:

fig.update_xaxes(title_text = 'New x-axis title')

Or in your specifc example, replace:

xaxis_title =  "année"

with:

xaxis_title_text =  "année"

Plot

enter image description here

Complete code:

import plotly.express as px

df = px.data.tips()

fig = px.box(df, x="day", y="total_bill", color="smoker")
fig.update_traces(quartilemethod="exclusive") # or "inclusive", or "linear" by default
f = fig.full_figure_for_development(warn=False)

fig.update_xaxes(title_text = 'New x-axis title')
fig.show()

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 vestland