Skip to content

Can now plot columns from GeoDataFrame #149

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
Aug 31, 2023
Merged
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@ and this project adheres to [Semantic Versioning][].
[keep a changelog]: https://keepachangelog.com/en/1.0.0/
[semantic versioning]: https://semver.org/spec/v2.0.0.html

## [0.0.5] -tbd
## [0.1.0] - tbd

### Added

- Multipolygons are now handled correctly (#93)
- Can now plot columns from GeoDataFrame (#149)

### Fixed

- Legend order is now deterministic (#143)
- Images no longer normalised by default (#150)

## [0.0.4] - 2023-08-11

Expand Down
30 changes: 8 additions & 22 deletions src/spatialdata_plot/pl/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,22 @@

from spatialdata_plot._accessor import register_spatial_data_accessor
from spatialdata_plot.pl.render import (
ImageRenderParams,
LabelsRenderParams,
PointsRenderParams,
ShapesRenderParams,
_render_images,
_render_labels,
_render_points,
_render_shapes,
)
from spatialdata_plot.pl.utils import (
from spatialdata_plot.pl.render_params import (
CmapParams,
ImageRenderParams,
LabelsRenderParams,
LegendParams,
PointsRenderParams,
ShapesRenderParams,
_FontSize,
_FontWeight,
)
from spatialdata_plot.pl.utils import (
_get_cs_contents,
_get_extent,
_maybe_set_colors,
Expand Down Expand Up @@ -147,7 +149,6 @@ def render_shapes(
outline: bool = False,
outline_width: float = 1.5,
outline_color: str | list[float] = "#000000ff",
alt_var: str | None = None,
layer: str | None = None,
palette: ListedColormap | str | None = None,
cmap: Colormap | str | None = None,
Expand Down Expand Up @@ -178,8 +179,6 @@ def render_shapes(
Width of the border.
outline_color
Color of the border.
alt_var
Which column to use in :attr:`anndata.AnnData.var` to select alternative ``var_name``.
layer
Key in :attr:`anndata.AnnData.layers` or `None` for :attr:`anndata.AnnData.X`.
palette
Expand Down Expand Up @@ -219,7 +218,6 @@ def render_shapes(
color=color,
groups=groups,
outline_params=outline_params,
alt_var=alt_var,
layer=layer,
cmap_params=cmap_params,
palette=palette,
Expand Down Expand Up @@ -381,7 +379,6 @@ def render_labels(
groups: str | Sequence[str] | None = None,
contour_px: int = 3,
outline: bool = False,
alt_var: str | None = None,
layer: str | None = None,
palette: ListedColormap | str | None = None,
cmap: Colormap | str | None = None,
Expand Down Expand Up @@ -409,8 +406,6 @@ def render_labels(
entire segment, see :func:`skimage.morphology.erosion`.
outline
Whether to plot boundaries around segmentation masks.
alt_var
Which column to use in :attr:`anndata.AnnData.var` to select alternative ``var_name``.
layer
Key in :attr:`anndata.AnnData.layers` or `None` for :attr:`anndata.AnnData.X`.
palette
Expand Down Expand Up @@ -452,7 +447,6 @@ def render_labels(
groups=groups,
contour_px=contour_px,
outline=outline,
alt_var=alt_var,
layer=layer,
cmap_params=cmap_params,
palette=palette,
Expand Down Expand Up @@ -667,15 +661,6 @@ def show(
# extent=extent[cs],
)
elif cmd == "render_shapes" and cs_contents.query(f"cs == '{cs}'")["has_shapes"][0]:
if sdata.table is not None and isinstance(params.color, str):
colors = sc.get.obs_df(sdata.table, params.color)
if is_categorical_dtype(colors):
_maybe_set_colors(
source=sdata.table,
target=sdata.table,
key=params.color,
palette=params.palette,
)
_render_shapes(
sdata=sdata,
render_params=params,
Expand Down Expand Up @@ -728,6 +713,7 @@ def show(
else:
t = cs
ax.set_title(t)
ax.set_aspect("equal")

if any(
[
Expand Down
Loading