简体   繁体   中英

How to customize hover text in plotly?

I'm creating a barplot in plotly (python) with

go.Bar(
    x=[1, 2, 3],
    y=[0.1, 0.2, 0.3],
    text=['10%', '20%', '30%'],
    textposition='inside',
    marker=dict(
        color='rgba(219, 64, 82, 0.7)',
        line=dict(
            color='rgba(219, 64, 82, 1.0)',
            width=2,
        )
    ),
    base=0)

So I'm showing some text inside each bar, now I would also like to add some custom hovertext which is composed of custom strings, so different from either x , y or text .

Is that possible?

Thanks

Please add this:

go.Bar(
    x=[1, 2, 3],
    y=[0.1, 0.2, 0.3],
    text=['10%', '20%', '30%'],
    textposition='inside',
    customdata=['string1','string2', 'string3']
    marker=dict(
        color='rgba(219, 64, 82, 0.7)',
        line=dict(
            color='rgba(219, 64, 82, 1.0)',
            width=2,
        )
    ),
    base=0)

See this part of plotly documentation for reference .

Let me know, if it worked out for you!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM