From b98a092a8d72bec6f7d5ac7f41ec6dd3a1e534fc Mon Sep 17 00:00:00 2001 From: LinnRooden <163526508+LinnRooden@users.noreply.github.com> Date: Fri, 15 Mar 2024 12:51:37 +0100 Subject: [PATCH] Update base - fix crashing when drawing a 2d plot --- visual/base.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/visual/base.py b/visual/base.py index 82f84b6..b90d9a1 100644 --- a/visual/base.py +++ b/visual/base.py @@ -55,6 +55,9 @@ def print_event_2d(event, tracks=[], x=2, y=0, track_color=0, filename="visual.p for i in modules: m = event.modules[i] + if len(event.modules[i].hits()) == 0: + continue + # if there are no hits skip drawing rectangle for this module limit = limits[i % 2] rect = mpatches.Rectangle((min(m.z)-shift,limit[0]),max(m.z)-min(m.z)+2*shift,limit[1],edgecolor=grey_color,facecolor=grey_color,alpha=0.4) ax.add_patch(rect) @@ -71,6 +74,9 @@ def print_event_2d(event, tracks=[], x=2, y=0, track_color=0, filename="visual.p for i, m in enumerate(event.modules): limit = limits[i % 2] + if len(event.modules[i].hits()) == 0: + continue + # if there are no hits skip drawing rectangle for this module rect = mpatches.Rectangle((min(m.z)-shift,limit[0]),max(m.z)-min(m.z)+2*shift,limit[1],edgecolor=grey_color,facecolor=grey_color,alpha=0.4) ax.add_patch(rect)