✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
🧬 Learn how to build RNA-Seq data apps with Python & Dash. Register for the May 20 Webinar!

Is selectively formatting tick labels possible? How?

Hi,

Using the basic horizontal bar chart from the plotly site as an example (code below), is it possible to selectively (or individually) format the tick labels? For instance, can I make the text for “giraffes” a larger font, different color, and/or in bold text while leaving the other labels unchanged? If so, how?

I didn’t see any guidance in the axes documentation. I also scanned the API reference, but I may have missed something.

I’m still new to Plotly, so any guidance is appreciated.


import plotly.graph_objects as go

fig = go.Figure(go.Bar(
x=[20, 14, 23],
y=[‘giraffes’, ‘orangutans’, ‘monkeys’],
orientation=‘h’))

fig.show()

Hi @9eqUoa2vHj, the font type, color and size have to be the same for all tick labels. Some labels can be bold since you can change this directly when defining y:

fig = go.Figure(go.Bar(
    x=[20, 14, 23],
    y=[‘<b>giraffes</b>’, ‘orangutans’, ‘monkeys’],
   orientation=‘h’))

If you need more customization, you can add annotations instead of ticklabels, please see the tutorial on annotations for more details.

Hi Emmanuelle,

Got it, thank you very much for your response.