From d522504b54dd2ab52a01a91324ce484b2fcaf3fb Mon Sep 17 00:00:00 2001 From: Raphael Quast Date: Tue, 26 Apr 2022 20:18:17 +0200 Subject: [PATCH 1/2] fix QuadMesh get_cursor_data if no array is set --- lib/matplotlib/collections.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/matplotlib/collections.py b/lib/matplotlib/collections.py index a7c8b631c26d..89121273e959 100644 --- a/lib/matplotlib/collections.py +++ b/lib/matplotlib/collections.py @@ -2218,6 +2218,7 @@ def get_cursor_data(self, event): contained, info = self.contains(event) if len(info["ind"]) == 1: ind, = info["ind"] - return self.get_array()[ind] + array = self.get_array() + return self.get_array()[ind] if array else None else: return None From 2b10e529d71ce9c8ed2f5eb0632f06816e4b33ca Mon Sep 17 00:00:00 2001 From: Raphael Quast Date: Thu, 28 Apr 2022 08:33:03 +0200 Subject: [PATCH 2/2] avoid re-using get_array() --- lib/matplotlib/collections.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/matplotlib/collections.py b/lib/matplotlib/collections.py index d522b087da1d..0aa37376a477 100644 --- a/lib/matplotlib/collections.py +++ b/lib/matplotlib/collections.py @@ -2202,6 +2202,6 @@ def get_cursor_data(self, event): if len(info["ind"]) == 1: ind, = info["ind"] array = self.get_array() - return self.get_array()[ind] if array else None + return array[ind] if array else None else: return None