From 665aebc3ac365ff18847a6032e604a35eeee7297 Mon Sep 17 00:00:00 2001 From: rht Date: Sun, 21 Jan 2024 02:23:12 -0500 Subject: [PATCH] fix: Explicitly specify JupyterViz space view limits --- mesa/experimental/components/matplotlib.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/mesa/experimental/components/matplotlib.py b/mesa/experimental/components/matplotlib.py index e2389b5ce39..7932407247b 100644 --- a/mesa/experimental/components/matplotlib.py +++ b/mesa/experimental/components/matplotlib.py @@ -55,6 +55,8 @@ def portray(g): out["c"] = c return out + space_ax.set_xlim(-1, space.width) + space_ax.set_ylim(-1, space.height) space_ax.scatter(**portray(space)) @@ -91,6 +93,14 @@ def portray(space): out["c"] = c return out + width = space.x_max - space.x_min + x_padding = width / 20 + height = space.y_max - space.y_min + y_padding = height / 20 + space_ax.set_xlim(space.x_min - x_padding, space.x_max + x_padding) + space_ax.set_ylim(space.y_min - y_padding, space.y_max + y_padding) + space_ax.scatter(**portray(space)) + space_ax.scatter(**portray(space))