Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions mesa/experimental/components/matplotlib.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ def SpaceMatplotlib(model, agent_portrayal, dependencies: Optional[list[any]] =
_draw_continuous_space(space, space_ax, agent_portrayal)
else:
_draw_grid(space, space_ax, agent_portrayal)
space_ax.set_axis_off()
solara.FigureMatplotlib(space_fig, format="png", dependencies=dependencies)


Expand Down Expand Up @@ -93,14 +92,23 @@ def portray(space):
out["c"] = c
return out

# Determine border style based on space.torus
border_style = 'solid' if not space.torus else (0, (5, 10))

# Set the border of the plot
for spine in space_ax.spines.values():
spine.set_linewidth(1.5)
spine.set_color('black')
spine.set_linestyle(border_style)

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

# Portray and scatter the agents in the space
space_ax.scatter(**portray(space))


Expand Down