Skip to content

Commit

Permalink
bugfix for draw_property_layer (#2639)
Browse files Browse the repository at this point in the history
  • Loading branch information
quaquel authored Jan 23, 2025
1 parent d71f688 commit 13518b2
Showing 1 changed file with 4 additions and 4 deletions.
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)

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

0 comments on commit 13518b2

Please sign in to comment.