Skip to content

Commit 2ffb791

Browse files
committed
fixed plotting datashader categorical column
1 parent 54081dd commit 2ffb791

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/spatialdata_plot/pl/render.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,12 @@ def _render_points(
525525
# use datashader for the visualization of points
526526
cvs = ds.Canvas(plot_width=plot_width, plot_height=plot_height, x_range=x_ext, y_range=y_ext)
527527

528-
color_by_categorical = col_for_color is not None and points[col_for_color].values.dtype == object
528+
color_by_categorical = col_for_color is not None and transformed_element[col_for_color].values.dtype in (
529+
object,
530+
"categorical",
531+
)
532+
if color_by_categorical and transformed_element[col_for_color].values.dtype == object:
533+
transformed_element[col_for_color] = transformed_element[col_for_color].astype("category")
529534
aggregate_with_reduction = None
530535
if col_for_color is not None and (render_params.groups is None or len(render_params.groups) > 1):
531536
if color_by_categorical:
Loading

0 commit comments

Comments
 (0)