1
1
from __future__ import annotations
2
2
3
3
from collections import OrderedDict
4
- from typing import Any , Optional , Union
5
4
from collections .abc import Sequence
5
+ from typing import Any , Optional , Union
6
6
7
7
import geopandas as gpd
8
8
import numpy as np
41
41
_prepare_params_plot ,
42
42
_set_outline ,
43
43
)
44
- from spatialdata_plot .pp .utils import (
45
- _verify_plotting_tree ,
46
- )
44
+ from spatialdata_plot .pp .utils import _verify_plotting_tree
47
45
48
46
49
47
@register_spatial_data_accessor ("pl" )
@@ -200,7 +198,7 @@ def render_shapes(
200
198
def render_points (
201
199
self ,
202
200
palette : Optional [Union [str , list [str ], None ]] = None ,
203
- color_key : Optional [str ] = None ,
201
+ color : Optional [str ] = None ,
204
202
** scatter_kwargs : Optional [str ],
205
203
) -> sd .SpatialData :
206
204
"""Render the points contained in the given sd.SpatialData object
@@ -214,7 +212,7 @@ def render_points(
214
212
default colors will be used.
215
213
instance_key : str
216
214
The name of the column in the table that identifies individual shapes
217
- color_key : str or None, optional (default: None)
215
+ color : str or None, optional (default: None)
218
216
The name of the column in the table to use for coloring shapes.
219
217
220
218
Returns
@@ -233,15 +231,15 @@ def render_points(
233
231
else :
234
232
raise TypeError ("The palette argument must be a list of strings or a single string." )
235
233
236
- if color_key is not None and not isinstance (color_key , str ):
234
+ if color is not None and not isinstance (color , str ):
237
235
raise TypeError ("When giving a 'color_key', it must be of type 'str'." )
238
236
239
237
sdata = self ._copy ()
240
238
sdata = _verify_plotting_tree (sdata )
241
239
n_steps = len (sdata .plotting_tree .keys ())
242
240
sdata .plotting_tree [f"{ n_steps + 1 } _render_points" ] = {
243
241
"palette" : palette ,
244
- "color_key " : color_key ,
242
+ "color " : color ,
245
243
}
246
244
247
245
return sdata
@@ -367,6 +365,7 @@ def render_labels(
367
365
368
366
def show (
369
367
self ,
368
+ coordinate_system : str | Sequence [str ] | None = None ,
370
369
legend_fontsize : int | float | _FontSize | None = None ,
371
370
legend_fontweight : int | _FontWeight = "bold" ,
372
371
legend_loc : str | None = "right margin" ,
@@ -406,6 +405,9 @@ def show(
406
405
plotting_tree = self ._sdata .plotting_tree
407
406
sdata = self ._copy ()
408
407
408
+ if isinstance (coordinate_system , str ):
409
+ coordinate_system = [coordinate_system ]
410
+
409
411
# Evaluate execution tree for plotting
410
412
valid_commands = [
411
413
"get_elements" ,
@@ -436,7 +438,9 @@ def show(
436
438
437
439
# set up canvas
438
440
fig_params , scalebar_params = _prepare_params_plot (
439
- num_panels = 1 , # len(render_cmds),
441
+ num_panels = len (sdata .coordinate_systems )
442
+ if coordinate_system is None
443
+ else len (coordinate_system ), # len(render_cmds),
440
444
figsize = figsize ,
441
445
dpi = dpi ,
442
446
fig = fig ,
@@ -528,7 +532,7 @@ def show(
528
532
for key in sdata .shapes .keys ():
529
533
points = []
530
534
polygons = []
531
-
535
+ # TODO: improve getting extent of polygons
532
536
for _ , row in sdata .shapes [key ].iterrows ():
533
537
if row ["geometry" ].geom_type == "Point" :
534
538
points .append (row )
0 commit comments