Skip to content

Commit 22038e3

Browse files
committed
added numeric rgb support
1 parent ab296b1 commit 22038e3

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

src/spatialdata_plot/pl/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ def _set_outline(
502502
# the default black and white colors can be changes using the contour_config parameter
503503
if isinstance(outline_color, str):
504504
bg_color, gap_color = outline_color, outline_color
505-
elif len(outline_color) == 4 and all(isinstance(c, float) for c in outline_color):
505+
elif (len(outline_color) == 3 or len(outline_color) == 4) and all(isinstance(c, float) for c in outline_color):
506506
hex_color = matplotlib.colors.to_hex(outline_color)
507507
bg_color, gap_color = hex_color, hex_color
508508
else:
Loading

tests/pl/test_render_shapes.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,14 @@ def test_plot_can_render_circles_with_colored_outline(self, sdata_blobs: Spatial
3030

3131
def test_plot_can_render_polygons(self, sdata_blobs: SpatialData):
3232
sdata_blobs.pl.render_shapes(elements="blobs_polygons").pl.show()
33+
34+
def test_plot_can_render_polygons_with_outline(self, sdata_blobs: SpatialData):
35+
sdata_blobs.pl.render_shapes(elements="blobs_polygons", outline=True).pl.show()
36+
37+
def test_plot_can_render_polygons_with_colored_outline(self, sdata_blobs: SpatialData):
38+
sdata_blobs.pl.render_shapes(elements="blobs_polygons", outline=True, outline_color="red").pl.show()
39+
40+
def test_plot_can_render_polygons_with_numericcolored_outline(self, sdata_blobs: SpatialData):
41+
sdata_blobs.pl.render_shapes(
42+
elements="blobs_polygons", outline=True, outline_color=(0.0, 1.0, 0.0, 1.0)
43+
).pl.show()

0 commit comments

Comments
 (0)