Bring Drag & Drop to Dash with Dashboard Engine. 💫 Learn how at our next webinar!

Customize ticks with and without labels

How can I remove the labelling but not the ticks from the non-integers, i.e. 4.5, 5.5, 6.5 …, but keep both the labelling and the ticks on the integers, i.e. 4, 5, 6 …, in the example below?

import plotly.express as px
df = px.data.iris()

fig = px.scatter(df, x="sepal_width", y="sepal_length", facet_col="species")

fig.update_yaxes(linewidth=0.5,
                ticks="outside", tickwidth=0.5, tickcolor='black', ticklen=5, dtick=0.5,
                tickfont_size=22, 
                )

fig.show()

With tickvals and ticktext:

fig.update_yaxes(linewidth=0.5,
                ticks="outside", tickwidth=0.5, tickcolor='black', ticklen=5, dtick=0.5,
                tickfont_size=22, 
                tickvals = [4.5,5,5.5,6,6.5,7,7.5,8],
                ticktext=[" ",5," ",6," ",7," ",8]
                )

Great, thanks a lot!

You are welcome! :slight_smile: