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
8 changes: 4 additions & 4 deletions mesa/visualization/mpl_space_drawing.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,10 @@ def draw_property_layers(
continue

data = layer.data.astype(float) if layer.data.dtype == bool else layer.data
width, height = data.shape # if space is None else (space.width, space.height)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest adding these two lines:

data = data.T
height, width = data.shape

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I fixed your comments in a slightly different way but the effect is the same

if space and data.shape != (width, height):
if (space.width, space.height) != data.shape:
warnings.warn(
f"Layer {layer_name} dimensions ({data.shape}) do not match space dimensions ({width}, {height}).",
f"Layer {layer_name} dimensions ({data.shape}) do not match space dimensions ({space.width}, {space.height}).",
UserWarning,
stacklevel=2,
)
Expand All @@ -208,6 +207,7 @@ def draw_property_layers(

# Draw the layer
if "color" in portrayal:
data = data.T
rgba_color = to_rgba(portrayal["color"])
normalized_data = (data - vmin) / (vmax - vmin)
rgba_data = np.full((*data.shape, 4), rgba_color)
Expand All @@ -231,7 +231,7 @@ def draw_property_layers(
if isinstance(cmap, list):
cmap = LinearSegmentedColormap.from_list(layer_name, cmap)
im = ax.imshow(
data,
data.T,
cmap=cmap,
alpha=alpha,
vmin=vmin,
Expand Down
Loading