Skip to content
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

datashader speedup and bugfixes #309

Open
wants to merge 24 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
50808b3
speed up datashader by using canvas size equal to image size
Jul 17, 2024
759ecd8
_cax definition bugfix
Jul 17, 2024
ea718bf
attempt mypy error fixes
Jul 17, 2024
eef7b8b
delete comments
Jul 17, 2024
702a226
continuous agg with mean instead of sum and use linear cmap instead o…
Jul 19, 2024
420772a
Merge branch 'main' into feature/296-datashader-canvas-size
LucaMarconato Jul 22, 2024
48c1c52
switch back to sum() and move duplicate datashader code into private …
Jul 23, 2024
fc89462
make ds reduction a kwarg and fix ds colorbar limits for continuous c…
Jul 30, 2024
a0dac08
adapt ds px using dpi/100
Jul 31, 2024
c8b0b34
spread how kw refactoring
Aug 6, 2024
e1662e8
add tests and minor adaptations
Sep 10, 2024
d3a4c14
Merge branch 'main' into feature/296-datashader-canvas-size
Sonja-Stockhaus Sep 10, 2024
f0074c9
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Sep 10, 2024
6dfaf51
fix merge conflict resolution
Sep 10, 2024
3d890a6
update test images
Sep 10, 2024
a2b66e1
update changelog
Sep 10, 2024
8b0b24d
minor refactor
timtreis Sep 14, 2024
982c627
added tests for remaining methods
timtreis Sep 14, 2024
0d124d7
added images from runner
timtreis Sep 14, 2024
ceb4fd2
remove m2 reduction, fix datashader coloring shapes by given color
Sep 18, 2024
59a19da
add ds shapes outlines, fix shapes fill_alpha behavior, fix std/var/a…
Oct 1, 2024
22cdabc
add test images
Oct 1, 2024
1d07544
update test images
Oct 1, 2024
febd424
changelog update and documentation
Oct 2, 2024
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
9 changes: 6 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,22 @@ 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.2.7] - 2024-09-04
## [0.2.7] - tbd

### Added

-
- The user can now specify `datashader_reduction` to control the rendering behaviour (#309)
- Rendering outlines of shapes with datashader works now (#309)

### Changed

-

### Fixed

-
- datashader now uses canvas size = image size which speeds up the rendering (#309)
- datashader now uses the linear version of continuous colormaps (#309)
- point sizes of datashader now agree with matplotlib also when dpi != 100 (#309)

## [0.2.6] - 2024-09-04

Expand Down
25 changes: 20 additions & 5 deletions src/spatialdata_plot/pl/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,15 @@ def render_shapes(
Name of the table containing the color(s) columns. If one name is given than the table is used for each
spatial element to be plotted if the table annotates it. If you want to use different tables for particular
elements, as specified under element.

**kwargs : Any
Additional arguments to be passed to cmap and norm.
Additional arguments for customization. This can include:

datashader_reduction : Literal[
"sum", "mean", "any", "count", "std", "var", "max", "min"
], default: "sum"
Reduction method for datashader when coloring by continuous values. Defaults to 'sum'.


Notes
-----
Expand Down Expand Up @@ -257,13 +264,13 @@ def render_shapes(
scale=scale,
table_name=table_name,
method=method,
ds_reduction=kwargs.get("datashader_reduction", None),
)

sdata = self._copy()
sdata = _verify_plotting_tree(sdata)
n_steps = len(sdata.plotting_tree.keys())
outline_params = _set_outline(outline_alpha > 0, outline_width, outline_color)

for element, param_values in params_dict.items():
cmap_params = _prepare_cmap_norm(
cmap=cmap,
Expand All @@ -285,7 +292,8 @@ def render_shapes(
transfunc=kwargs.get("transfunc", None),
table_name=param_values["table_name"],
zorder=n_steps,
method=method,
method=param_values["method"],
ds_reduction=param_values["ds_reduction"],
)
n_steps += 1

Expand Down Expand Up @@ -355,8 +363,14 @@ def render_points(
Name of the table containing the color(s) columns. If one name is given than the table is used for each
spatial element to be plotted if the table annotates it. If you want to use different tables for particular
elements, as specified under element.
kwargs
Additional arguments to be passed to cmap and norm.

**kwargs : Any
Additional arguments for customization. This can include:

datashader_reduction : Literal[
"sum", "mean", "any", "count", "std", "var", "max", "min"
], default: "sum"
Reduction method for datashader when coloring by continuous values. Defaults to 'sum'.

Returns
-------
Expand Down Expand Up @@ -407,6 +421,7 @@ def render_points(
table_name=param_values["table_name"],
zorder=n_steps,
method=method,
ds_reduction=kwargs.get("datashader_reduction", None),
)
n_steps += 1

Expand Down
Loading
Loading