I have the following code. Without the line %matplotlib inline, jupyter notebook pops out an extra window to display the plot and it is interactive (the right bottom corner updates the x and y values as you move the mouse). With the line %matplotlib inline, the plot is not interactive.
Anything I can do to make it interactive within the notebook?
import pandas as pd
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
from numpy.random import randn
%matplotlib inline
origins = ['China','Brazil','India','USA','Canada','UK','Germany',
'Iraq','Chile','Mexico']
df = pd.DataFrame({'height':
np.random.rand(10),'weight':np.random.rand(10),
'origin':origins})
plt.figure()
plt.scatter(df['height'],df['weight'],picker=5)
plt.gca().set_ylabel('Weight')
plt.gca().set_xlabel('Height')
def onpick(event):
origin = df.iloc[event.ind[0]]['origin']
plt.gca().set_title('came from {}'.format(origin))
plt.gcf().canvas.mpl_connect('pick_event',onpick)
plt.show()