I have two (or more) 3d scatter plots in subplots, each showing different 3 variables of a data set. When I hover over a data in one subplot, I’d like other subplots to also automatically show the same data sample. Currently, I am able to show annotation (on hover) for one plot using mplcursors module (in jupyter notebook), but I’d like the hover annotation to be linked between all subplots.
Below is the sample image generated with the current implementation:
Minimal working code:
%matplotlib ipympl
import plotly.express as px
import matplotlib.pyplot as plt
import mplcursors
df = px.data.iris()
fig = plt.figure(figsize=(12, 8))
ax = fig.add_subplot(121, projection='3d')
ax.scatter(df['sepal_length'], df['sepal_width'], df['petal_length'], marker='.')
ax.set_xlabel('Sepal Length')
ax.set_ylabel('Sepal Width')
ax.set_zlabel('Petal Length')
ax.set_title("Scatter plot of sepal length, sepal width, and petal length")
ax2 = fig.add_subplot(122, projection='3d')
ax2.scatter(df['sepal_length'], df['sepal_width'], df['petal_width'], marker='.')
ax2.set_xlabel('Sepal Length')
ax2.set_ylabel('Sepal Width')
ax2.set_zlabel('Petal Width')
ax2.set_title("Scatter plot of sepal length, sepal width, and petal width")
mplcursors.cursor(hover=True)
plt.show()
Thank you in advance.