Skip to content

Commit 72564cf

Browse files
committed
Add visual tests for scalebar frameon/sizing/fixed-value options
Cover three orthogonal scalebar knobs that users routinely tune: - frameon=False (no surrounding box) - length_fraction + pad + border_pad (compact footprint) - fixed_value + label (pin bar length, override displayed text) Also drops a transient explanatory comment block above the non-visual scalebar tests; the test names and docstrings are self-explanatory.
1 parent 07e37d4 commit 72564cf

1 file changed

Lines changed: 21 additions & 5 deletions

File tree

tests/pl/test_show.py

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,27 @@ def test_plot_scalebar_styled(self, sdata_blobs: SpatialData):
5454
scalebar_params={"location": "lower right", "color": "white", "box_alpha": 0.6},
5555
)
5656

57+
def test_plot_scalebar_no_frame(self, sdata_blobs: SpatialData):
58+
"""Visual test: frameon=False drops the surrounding box."""
59+
sdata_blobs.pl.render_images(element="blobs_image").pl.show(
60+
scalebar_dx=1.0,
61+
scalebar_params={"frameon": False, "color": "white"},
62+
)
63+
64+
def test_plot_scalebar_compact(self, sdata_blobs: SpatialData):
65+
"""Visual test: padding and length_fraction shrink the scalebar footprint."""
66+
sdata_blobs.pl.render_images(element="blobs_image").pl.show(
67+
scalebar_dx=1.0,
68+
scalebar_params={"length_fraction": 0.15, "pad": 0.1, "border_pad": 0.1},
69+
)
70+
71+
def test_plot_scalebar_fixed_value_label(self, sdata_blobs: SpatialData):
72+
"""Visual test: fixed_value pins the bar length and label overrides the displayed text."""
73+
sdata_blobs.pl.render_images(element="blobs_image").pl.show(
74+
scalebar_dx=1.0,
75+
scalebar_params={"fixed_value": 200, "label": "200 um"},
76+
)
77+
5778
def test_plot_user_ax_dpi_preserved(self, sdata_blobs: SpatialData):
5879
"""Visual test: low DPI produces visibly pixelated rasterization (regression for #310).
5980
@@ -158,11 +179,6 @@ def test_dpi_default_used_when_no_ax(sdata_blobs: SpatialData):
158179
plt.close(fig)
159180

160181

161-
# Scalebar regression tests (#614). The scalebar machinery existed but was
162-
# unreachable: show() did not accept scalebar_dx/scalebar_units. These tests
163-
# lock the wiring, the defaults, the kwargs passthrough, and validation.
164-
165-
166182
def _scalebars_on(ax):
167183
from matplotlib_scalebar.scalebar import ScaleBar
168184

0 commit comments

Comments
 (0)