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))