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

Hi,
I have a problem like this:

  • I dont wanna see x axis name and text value when i move the mouse icon. Example picture:
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.show()

I wanna set a text and I wanna see this only in the graph, but I don’t wanna see it when I move the mouse.
At the same time, I don’t wanna see x-axis labels when I move the mouse.

I only wanna see y-axis name and hover data value when I move the mouse icon?

Is this possible? How can I set this?
If you can show on the same codes I would be appreciated about this.
Thanks in advance!!

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

This is what I need. Thank you so much!!