Now let's generate the plots that we will be using. The first one will be a scatter plot of cylinyders versus weight. This will be the plot that will listen for, and respond to zoom events. The second plot will be a bar chart plotting mpg and the model for the cars taht you zoomed in on in the scatter plot.

In [3]:

data1=[{'x':df['cyl'],'y':df['wt'],'text':df['model'],'type':'scatter','mode':'markers'}]layout1={'xaxis':{'title':'Cylinders'},'yaxis':{'title':'Weight'},'hovermode':'closest'}url=py.plot({'data':data1,'layout':layout1},filename="mouseevent-scatter1",auto_open=False)data2=[{'x':df['model'],'y':df['mpg'],'text':df['model'],'type':'bar','marker':{'color':'pink'}}]layout2={'xaxis':{'title':'Model'},'yaxis':{'title':'Miles per Gallon'},'hovermode':'closest'}url=py.plot({'data':data2},filename="mouseevent-scatter2",auto_open=False)