How To Make Items Clickable (onpick) In Seaborn Scatterplot?
I'm using sns.scatterplot function to analyze some data. It would be very helpful for me if I could pick an object on the plot by clicking on it and execute a function. Matplotlib
Solution 1:
Just as in any other case, you define the picker
argument and connect the callback function.
import seaborn as sns
import matplotlib.pyplot as plt
def onpick(event):
# ... process selected item
print("Picked!")
tips = sns.load_dataset("tips")
ax = sns.scatterplot(x="total_bill", y="tip", hue="time", data=tips, picker=4)
ax.figure.canvas.mpl_connect("pick_event", onpick)
plt.show()
Post a Comment for "How To Make Items Clickable (onpick) In Seaborn Scatterplot?"