Show Sidebar Hide Sidebar

Click Events in Pandas

How to bind callback functions to click events in Pandas charts with JavaScript.

# Learn about API authentication here: https://plot.ly/pandas/getting-started
# Find your api_key here: https://plot.ly/settings/api

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

trace0 = go.Scatter(
    x=[1, 2, 3, 4, 5],
    y=[1, 6, 3, 6, 1],
    mode='markers',
    name='Team A',
    text=['A-1', 'A-2', 'A-3', 'A-4', 'A-5'],
    marker=dict(
        size=12,
    )
)
trace1 = go.Scatter(
    x=[1.5, 2.5, 3.5, 4.5, 5.5],
    y=[4, 1, 7, 1, 4],
    mode='markers',
    name='Team B',
    text=['B-a', 'B-b', 'B-c', 'B-d', 'B-e'],
    marker=dict(
        size=12,
    )
)
data = [trace0, trace1]
layout = go.Layout(

    xaxis=dict(
        range=[0.75, 5.25],
        autorange=False,
    ),

    yaxis=dict(
        range=[0, 8],
        autorange=False,
    ),
)
fig = go.Figure(data=data, layout=layout)
plot_url = py.plot(fig, filename='text-hover')
Still need help?
Contact Us

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