|
10 | 10 | from spatialdata import SpatialData
|
11 | 11 | from spatialdata._core.query.relational_query import _get_unique_label_values_as_index
|
12 | 12 | from spatialdata.models import TableModel
|
| 13 | +from spatialdata.transformations import Affine, Scale, Sequence, Translation, set_transformation |
13 | 14 |
|
14 | 15 | from tests.conftest import DPI, PlotTester, PlotTesterMeta
|
15 | 16 |
|
@@ -111,6 +112,34 @@ def test_can_plot_with_one_element_color_table(self, sdata_blobs: SpatialData):
|
111 | 112 | def test_plot_label_categorical_color(self, sdata_blobs: SpatialData, label: str):
|
112 | 113 | self._make_tablemodel_with_categorical_labels(sdata_blobs, label)
|
113 | 114 |
|
| 115 | + def test_plot_can_render_transformed_labels_with_outline(self, sdata_blobs: SpatialData): |
| 116 | + # Blobs have by default an identity transform. Replace it by a rotated, scaled transform: |
| 117 | + angle = np.deg2rad(15) |
| 118 | + axes = ("y", "x") |
| 119 | + rotation = Affine( |
| 120 | + matrix=np.array( |
| 121 | + [ |
| 122 | + [np.cos(angle), -np.sin(angle), 0], |
| 123 | + [np.sin(angle), np.cos(angle), 0], |
| 124 | + [0, 0, 1], |
| 125 | + ] |
| 126 | + ), |
| 127 | + input_axes=axes, |
| 128 | + output_axes=axes, |
| 129 | + ) |
| 130 | + translation = Translation([10, 10], axes=axes) |
| 131 | + scale = Scale([0.65, 0.65], axes=axes) |
| 132 | + transform = Sequence([translation, rotation, scale]) |
| 133 | + set_transformation(sdata_blobs["blobs_labels"], transform) |
| 134 | + |
| 135 | + # Render without fill, but with outline. |
| 136 | + sdata_blobs.pl.render_labels( |
| 137 | + "blobs_labels", |
| 138 | + fill_alpha=0.0, |
| 139 | + outline=True, |
| 140 | + outline_alpha=1.0, |
| 141 | + ).pl.show() |
| 142 | + |
114 | 143 | def _make_tablemodel_with_categorical_labels(self, sdata_blobs, label):
|
115 | 144 | n_obs = max(_get_unique_label_values_as_index(sdata_blobs[label]))
|
116 | 145 | adata = AnnData(
|
|
0 commit comments