Show Sidebar Hide Sidebar

Hover Events in Python

How to add custom hover effects to Python charts with JavaScript.

import plotly.plotly as py
import plotly.graph_objs as go

data = [
    go.Bar(
        x=['Bob Dylan', 'The Beatles', 'David Bowie', 'Randy Newman', 'The Rolling Stones', 'Madonna', 'Frank Sinatra', 'The Beach Boys', 'Marvin Gaye', 'Prince', 'The Kinks', 'Elvis Presley', 'Tom Waits', 'U2', 'The Clash', 'Johnny Cash', 'Kate Bush', 'The Supremes', 'The Smiths', 'Al Green', 'Pulp', 'Chuck Berry', 'Elvis Costello and the Attractions', 'Neil Young', 'Stevie Wonder', 'Ray Charles', 'The Pogues', 'Grace Jones', 'Bill Withers', 'The Who', 'Paul Simon', 'Roy Orbison', 'Arctic Monkeys', 'Bruce Springsteen', 'The Police', 'Rod Stewart', 'Steve Earle'],
        y=[24, 19, 9, 8, 8, 6, 6, 6, 6, 6, 6, 6, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4],
        name='Number of songs per artist',
        marker=Marker(
            color='#2ca02c'
        )
    )
]

layout = go.Layout(
    title="Number of songs listed in the Guardian's<br><em>Top 1,000 Songs to Hear Before You Die</em> per artist with 4 or more songs",
    font=dict(
        family='Georgia, serif',
        color='#635F5D'
    ),
    plot_bgcolor='#EFECEA'
)
fig = go.Figure(data=data, layout=layout)
plot_url = py.plot(fig)
Still need help?
Contact Us

For guaranteed 24 hour response turnarounds, upgrade to a Developer Support Plan.