Learn how to use Dash Bio for next-gen sequencing & quality control. 🧬 Register for the Oct 27 webinar.

How to replace text on xaxis ticks

Hi,
I saw some code , somewhere, a while ago that allowed for replacing text values on the x-axis with other text values??

I have a bar chart and the categories have long text … and I want to shorten the text by replacing it with something simpler…

Ie: change “I do not have access to the information” to be “No Access”

I thought the code I saw was like

labels: {"I do not have access to the information":"No Access"}

So was I dreaming?

Thanks

I think you need to set the layout.xaxis.tickmode to “array” and provide a list of tickvals and their corresponding ticktext. So you don’t translate existing labels, but provide new labels (ticktext) and their location on the axis (tickvals). You can find a better explanation here: https://plotly.com/python/reference/#layout-xaxis