spatialdata-plot icon indicating copy to clipboard operation
spatialdata-plot copied to clipboard

Unintuitive almost white color when plotting with datashader

Open LucaMarconato opened this issue 7 months ago • 0 comments

The following code

import spatialdata_plot
from spatialdata.datasets import blobs
from spatialdata.transformations import Scale, set_transformation
import matplotlib.pyplot as plt

sdata = blobs()

set_transformation(
    sdata["blobs_points"],
    transformation=Scale([1, 5], axes=("x", "y")),
)

_, axes = plt.subplots(1, 2)
sdata.pl.render_points("blobs_points", method="matplotlib").pl.show(ax=axes[0])

sdata.pl.render_points("blobs_points", method="datashader").pl.show(ax=axes[1])
plt.tight_layout()
plt.show()

Shows this plot

Image

The right side is not white, but actually correctly plotted. In fact, if we add color='black' to each of the two pl.render_points(), we get (I also zoomed the plot):

Image

Where you can appreciate that the points are rendered, but they are just the lightly colored.

This can be confusing to users, so we should think of a way to avoid this behavior, for instance by changing some defaults for the grid size of the rasterized object.

LucaMarconato avatar Apr 16 '25 19:04 LucaMarconato