From ef94ce4fd997b6b93f37b99469182cb845f1c5a5 Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade <quantum.analyst@gmail.com>
Date: Tue, 27 Jul 2021 02:23:49 -0400
Subject: [PATCH] Add an example showing alternate mouse cursors.

---
 examples/widgets/mouse_cursor.py | 46 ++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)
 create mode 100644 examples/widgets/mouse_cursor.py

diff --git a/examples/widgets/mouse_cursor.py b/examples/widgets/mouse_cursor.py
new file mode 100644
index 000000000000..1b0a1b2c57c3
--- /dev/null
+++ b/examples/widgets/mouse_cursor.py
@@ -0,0 +1,46 @@
+"""
+============
+Mouse Cursor
+============
+
+This example sets an alternative cursor on a figure canvas.
+
+Note, this is an interactive example, and must be run to see the effect.
+"""
+
+import matplotlib.pyplot as plt
+from matplotlib.backend_tools import Cursors
+
+
+fig, axs = plt.subplots(len(Cursors), figsize=(6, len(Cursors) + 0.5),
+                        gridspec_kw={'hspace': 0})
+fig.suptitle('Hover over an Axes to see alternate Cursors')
+
+for cursor, ax in zip(Cursors, axs):
+    ax.cursor_to_use = cursor
+    ax.text(0.5, 0.5, cursor.name,
+            horizontalalignment='center', verticalalignment='center')
+    ax.set(xticks=[], yticks=[])
+
+
+def hover(event):
+    if fig.canvas.widgetlock.locked():
+        # Don't do anything if the zoom/pan tools have been enabled.
+        return
+
+    fig.canvas.set_cursor(
+        event.inaxes.cursor_to_use if event.inaxes else Cursors.POINTER)
+
+
+fig.canvas.mpl_connect('motion_notify_event', hover)
+
+plt.show()
+
+#############################################################################
+#
+# .. admonition:: References
+#
+#    The use of the following functions, methods, classes and modules is shown
+#    in this example:
+#
+#    - `matplotlib.backend_bases.FigureCanvasBase.set_cursor`