How can I make invisible the xaxis labels and text value in mouse box?

Hello!

I think that what you are looking to do is modify the hovertemplate of your figure. The documentation for this can be found at Hover Text and Formatting | Python | Plotly.

Here is a code snippet for you:

import plotly.express as px

data_canada = px.data.gapminder().query("country == 'Canada'")

data_canada['idontwannaseethisone'] = 'i DONT wanna see this one'

data_canada['iwannaseethisone'] = 'i wanna see this one'

fig = px.bar(data_canada, x='year', y='pop', hover_data=['iwannaseethisone'], text= 'idontwannaseethisone')

fig.update_traces(hovertemplate='pop=%{y}<br>iwannaseethisone=%{customdata[0]}')

fig.show()

1 Like