1+ import warnings
12from unittest .mock import patch
23
34import matplotlib
45import matplotlib .pyplot as plt
6+ import pytest
57import scanpy as sc
8+ from matplotlib .figure import Figure
69from spatialdata import SpatialData
10+ from spatialdata .transformations import Identity , set_transformation
711
812import spatialdata_plot # noqa: F401
913from tests .conftest import DPI , PlotTester , PlotTesterMeta
@@ -25,6 +29,19 @@ class TestShow(PlotTester, metaclass=PlotTesterMeta):
2529 def test_plot_pad_extent_adds_padding (self , sdata_blobs : SpatialData ):
2630 sdata_blobs .pl .render_images (element = "blobs_image" ).pl .show (pad_extent = 100 )
2731
32+ def test_plot_frameon_false_single_panel (self , sdata_blobs : SpatialData ):
33+ """Visual test: frameon=False hides axes decorations on a single panel (regression for #204)."""
34+ sdata_blobs .pl .render_images (element = "blobs_image" ).pl .show (frameon = False )
35+
36+ def test_plot_frameon_false_multi_panel (self , sdata_blobs : SpatialData ):
37+ """Visual test: frameon=False hides axes decorations on all panels (regression for #204)."""
38+ set_transformation (sdata_blobs ["blobs_image" ], Identity (), "second_cs" )
39+ sdata_blobs .pl .render_images (element = "blobs_image" ).pl .show (frameon = False , title = "" )
40+
41+ def test_plot_no_decorations (self , sdata_blobs : SpatialData ):
42+ """Visual test: frameon=False + title='' produces just the plot content (regression for #204)."""
43+ sdata_blobs .pl .render_images (element = "blobs_image" ).pl .show (frameon = False , title = "" , colorbar = False )
44+
2845 def test_no_plt_show_when_ax_provided (self , sdata_blobs : SpatialData ):
2946 """plt.show() must not be called when the user supplies ax= (regression for #362)."""
3047 _ , ax = plt .subplots ()
@@ -40,3 +57,56 @@ def test_plt_show_when_ax_provided_and_show_true(self, sdata_blobs: SpatialData)
4057 sdata_blobs .pl .render_images (element = "blobs_image" ).pl .show (ax = ax , show = True )
4158 mock_show .assert_called_once ()
4259 plt .close ("all" )
60+
61+ def test_frameon_false_hides_axes_decorations (self , sdata_blobs : SpatialData ):
62+ """frameon=False should turn off axes decorations (regression for #204)."""
63+ ax = sdata_blobs .pl .render_images (element = "blobs_image" ).pl .show (frameon = False , return_ax = True , show = False )
64+ assert not ax .axison
65+ plt .close ("all" )
66+
67+ def test_frameon_none_keeps_axes_decorations (self , sdata_blobs : SpatialData ):
68+ """Default frameon=None should keep axes decorations visible."""
69+ ax = sdata_blobs .pl .render_images (element = "blobs_image" ).pl .show (frameon = None , return_ax = True , show = False )
70+ assert ax .axison
71+ plt .close ("all" )
72+
73+ def test_title_empty_string_suppresses_title (self , sdata_blobs : SpatialData ):
74+ """title='' should suppress the default coordinate system title (regression for #204)."""
75+ ax = sdata_blobs .pl .render_images (element = "blobs_image" ).pl .show (title = "" , return_ax = True , show = False )
76+ assert ax .get_title () == ""
77+ plt .close ("all" )
78+
79+
80+ def test_fig_parameter_emits_deprecation_warning (sdata_blobs : SpatialData ):
81+ """Passing fig= should emit a DeprecationWarning (regression for #204)."""
82+ fig = Figure ()
83+ with pytest .warns (DeprecationWarning , match = "`fig` is being deprecated" ):
84+ sdata_blobs .pl .render_images (element = "blobs_image" ).pl .show (fig = fig , show = False )
85+ plt .close ("all" )
86+
87+
88+ def test_fig_parameter_default_no_warning (sdata_blobs : SpatialData ):
89+ """Not passing fig= should not emit a deprecation warning."""
90+ with warnings .catch_warnings ():
91+ warnings .simplefilter ("error" , DeprecationWarning )
92+ sdata_blobs .pl .render_images (element = "blobs_image" ).pl .show (show = False )
93+ plt .close ("all" )
94+
95+
96+ def test_fig_parameter_no_warning_with_ax_list (sdata_blobs : SpatialData ):
97+ """Passing fig= with a list of axes should not warn (fig is still required there)."""
98+ set_transformation (sdata_blobs ["blobs_image" ], Identity (), "second_cs" )
99+ fig , axs = plt .subplots (1 , 2 )
100+ with warnings .catch_warnings ():
101+ warnings .simplefilter ("error" , DeprecationWarning )
102+ sdata_blobs .pl .render_images (element = "blobs_image" ).pl .show (fig = fig , ax = list (axs ), show = False )
103+ plt .close ("all" )
104+
105+
106+ def test_frameon_false_multi_panel (sdata_blobs : SpatialData ):
107+ """frameon=False should apply to all panels in a multi-panel plot (regression for #204)."""
108+ set_transformation (sdata_blobs ["blobs_image" ], Identity (), "second_cs" )
109+ axs = sdata_blobs .pl .render_images (element = "blobs_image" ).pl .show (frameon = False , return_ax = True , show = False )
110+ for ax in axs :
111+ assert not ax .axison
112+ plt .close ("all" )
0 commit comments