Skip to content

Commit 86b520c

Browse files
chore: deprecate save parameter of plots (#3675)
Co-authored-by: Phil Schaf <[email protected]>
1 parent 2b3e605 commit 86b520c

File tree

14 files changed

+75
-33
lines changed

14 files changed

+75
-33
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Scanpy outfiles
22
/data/
33
/write/
4+
/figures/
45

56
# Docs
67
/docs/_build/

docs/release-notes/3675.docs.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Update tutorial {doc}`/tutorials/experimental/dask` for {mod}`anndata` 0.12 (see {pr}`scverse/scanpy-tutorials#186`) {smaller}`I Gold`

docs/release-notes/3675.misc.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Deprecate `save` parameter of plotting functions. {smaller}`zethson`

src/scanpy/_settings/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ def datasetdir(cls, datasetdir: Path | str) -> None:
229229

230230
@property
231231
def figdir(cls) -> Path:
232-
"""Directory for saving figures (default `'./figures/'`)."""
232+
r"""Directory for `autosave`\ ing figures (default `'./figures/'`)."""
233233
return cls._figdir
234234

235235
@figdir.setter

src/scanpy/plotting/_anndata.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,9 @@ def scatter( # noqa: PLR0913
145145
marker: str | Sequence[str] = ".",
146146
title: str | Collection[str] | None = None,
147147
show: bool | None = None,
148-
save: str | bool | None = None,
149148
ax: Axes | None = None,
149+
# deprecated
150+
save: str | bool | None = None,
150151
) -> Axes | list[Axes] | None:
151152
"""Scatter plot along observations or variables axes.
152153
@@ -750,9 +751,9 @@ def violin( # noqa: PLR0912, PLR0913, PLR0915
750751
ylabel: str | Sequence[str] | None = None,
751752
rotation: float | None = None,
752753
show: bool | None = None,
753-
save: bool | str | None = None,
754754
ax: Axes | None = None,
755-
# deprecatd
755+
# deprecated
756+
save: bool | str | None = None,
756757
scale: DensityNorm | Empty = _empty,
757758
**kwds,
758759
) -> Axes | FacetGrid | None:
@@ -1007,7 +1008,7 @@ def clustermap(
10071008
*,
10081009
use_raw: bool | None = None,
10091010
show: bool | None = None,
1010-
save: bool | str | None = None,
1011+
save: bool | str | None = None, # deprecated
10111012
**kwds,
10121013
) -> ClusterGrid | None:
10131014
"""Hierarchically-clustered heatmap.

src/scanpy/plotting/_docs.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,8 @@
186186
save
187187
If `True` or a `str`, save the figure.
188188
A string is appended to the default filename.
189-
Infer the filetype if ending on {`'.pdf'`, `'.png'`, `'.svg'`}.\
189+
Infer the filetype if ending on {`'.pdf'`, `'.png'`, `'.svg'`}.
190+
(deprecated in favour of `sc.pl.plot(show=False).figure.savefig()`).\
190191
"""
191192

192193
doc_show_save_ax = f"""\

src/scanpy/plotting/_preprocessing.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@ def highly_variable_genes( # noqa: PLR0912
2121
*,
2222
log: bool = False,
2323
show: bool | None = None,
24-
save: bool | str | None = None,
2524
highly_variable_genes: bool = True,
25+
# deprecated
26+
save: bool | str | None = None,
2627
) -> None:
2728
"""Plot dispersions or normalized variance versus means for genes.
2829
@@ -111,6 +112,7 @@ def filter_genes_dispersion(
111112
*,
112113
log: bool = False,
113114
show: bool | None = None,
115+
# deprecated
114116
save: bool | str | None = None,
115117
) -> None:
116118
"""Plot dispersions versus means for genes.

src/scanpy/plotting/_stacked_violin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -682,7 +682,6 @@ def stacked_violin( # noqa: PLR0913
682682
categories_order: Sequence[str] | None = None,
683683
swap_axes: bool = False,
684684
show: bool | None = None,
685-
save: bool | str | None = None,
686685
return_fig: bool | None = False,
687686
ax: _AxesSubplot | None = None,
688687
vmin: float | None = None,
@@ -700,6 +699,7 @@ def stacked_violin( # noqa: PLR0913
700699
# deprecated
701700
order: Sequence[str] | None | Empty = _empty,
702701
scale: DensityNorm | Empty = _empty,
702+
save: bool | str | None = None,
703703
**kwds,
704704
) -> StackedViolin | dict | None:
705705
"""Stacked violin plots.

src/scanpy/plotting/_tools/__init__.py

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ def pca_variance_ratio(
188188
*,
189189
log: bool = False,
190190
show: bool | None = None,
191+
# deprecated
191192
save: bool | str | None = None,
192193
):
193194
"""Plot the variance ratio.
@@ -230,9 +231,10 @@ def dpt_timeseries(
230231
*,
231232
color_map: str | Colormap | None = None,
232233
show: bool | None = None,
233-
save: bool | None = None,
234234
as_heatmap: bool = True,
235235
marker: str | Sequence[str] = ".",
236+
# deprecated
237+
save: bool | None = None,
236238
):
237239
"""Heatmap of pseudotime series.
238240
@@ -277,9 +279,10 @@ def dpt_groups_pseudotime(
277279
color_map: str | Colormap | None = None,
278280
palette: Sequence[str] | Cycler | None = None,
279281
show: bool | None = None,
280-
save: bool | str | None = None,
281282
marker: str | Sequence[str] = ".",
282283
return_fig: bool = False,
284+
# deprecated
285+
save: bool | str | None = None,
283286
) -> Figure | None:
284287
"""Plot groups and pseudotime.
285288
@@ -349,8 +352,8 @@ def rank_genes_groups( # noqa: PLR0912, PLR0913, PLR0915
349352
ncols: int = 4,
350353
sharey: bool = True,
351354
show: bool | None = None,
352-
save: bool | None = None,
353355
ax: Axes | None = None,
356+
save: bool | None = None, # deprecated
354357
**kwds,
355358
) -> list[Axes] | None:
356359
"""Plot ranking of genes.
@@ -503,7 +506,12 @@ def rank_genes_groups( # noqa: PLR0912, PLR0913, PLR0915
503506

504507

505508
def _fig_show_save_or_axes(
506-
plot_obj: BasePlot, *, return_fig: bool, show: bool | None, save: bool | None
509+
plot_obj: BasePlot,
510+
*,
511+
return_fig: bool,
512+
show: bool | None,
513+
# deprecated
514+
save: bool | None,
507515
):
508516
"""Decides what to return."""
509517
if return_fig:
@@ -528,9 +536,9 @@ def _rank_genes_groups_plot( # noqa: PLR0912, PLR0913, PLR0915
528536
min_logfoldchange: float | None = None,
529537
key: str | None = None,
530538
show: bool | None = None,
531-
save: bool | None = None,
532539
return_fig: bool = False,
533540
gene_symbols: str | None = None,
541+
save: bool | None = None, # deprecated
534542
**kwds,
535543
):
536544
"""Call the different `rank_genes_groups_*` plots."""
@@ -703,7 +711,7 @@ def rank_genes_groups_heatmap(
703711
min_logfoldchange: float | None = None,
704712
key: str | None = None,
705713
show: bool | None = None,
706-
save: bool | None = None,
714+
save: bool | None = None, # deprecated
707715
**kwds,
708716
):
709717
"""Plot ranking of genes using heatmap plot (see :func:`~scanpy.pl.heatmap`).
@@ -786,7 +794,7 @@ def rank_genes_groups_tracksplot(
786794
min_logfoldchange: float | None = None,
787795
key: str | None = None,
788796
show: bool | None = None,
789-
save: bool | None = None,
797+
save: bool | None = None, # deprecated
790798
**kwds,
791799
):
792800
"""Plot ranking of genes using heatmap plot (see :func:`~scanpy.pl.heatmap`).
@@ -863,8 +871,8 @@ def rank_genes_groups_dotplot( # noqa: PLR0913
863871
min_logfoldchange: float | None = None,
864872
key: str | None = None,
865873
show: bool | None = None,
866-
save: bool | None = None,
867874
return_fig: bool = False,
875+
save: bool | None = None, # deprecated
868876
**kwds,
869877
):
870878
"""Plot ranking of genes using dotplot plot (see :func:`~scanpy.pl.dotplot`).
@@ -1002,8 +1010,8 @@ def rank_genes_groups_stacked_violin( # noqa: PLR0913
10021010
min_logfoldchange: float | None = None,
10031011
key: str | None = None,
10041012
show: bool | None = None,
1005-
save: bool | None = None,
10061013
return_fig: bool = False,
1014+
save: bool | None = None, # deprecated
10071015
**kwds,
10081016
):
10091017
"""Plot ranking of genes using stacked_violin plot.
@@ -1090,8 +1098,8 @@ def rank_genes_groups_matrixplot( # noqa: PLR0913
10901098
min_logfoldchange: float | None = None,
10911099
key: str | None = None,
10921100
show: bool | None = None,
1093-
save: bool | None = None,
10941101
return_fig: bool = False,
1102+
save: bool | None = None, # deprecated
10951103
**kwds,
10961104
):
10971105
"""Plot ranking of genes using matrixplot plot (see :func:`~scanpy.pl.matrixplot`).
@@ -1230,8 +1238,8 @@ def rank_genes_groups_violin( # noqa: PLR0913
12301238
size: int = 1,
12311239
ax: Axes | None = None,
12321240
show: bool | None = None,
1233-
save: bool | None = None,
12341241
# deprecated
1242+
save: bool | None = None,
12351243
scale: DensityNorm | Empty = _empty,
12361244
):
12371245
"""Plot ranking of genes for all tested comparisons.
@@ -1348,8 +1356,9 @@ def sim(
13481356
as_heatmap: bool = False,
13491357
shuffle: bool = False,
13501358
show: bool | None = None,
1351-
save: bool | str | None = None,
13521359
marker: str | Sequence[str] = ".",
1360+
# deprecated
1361+
save: bool | str | None = None,
13531362
) -> None:
13541363
"""Plot results of simulation.
13551364
@@ -1456,9 +1465,9 @@ def embedding_density( # noqa: PLR0912, PLR0913, PLR0915
14561465
wspace: None = None,
14571466
title: str | None = None,
14581467
show: bool | None = None,
1459-
save: bool | str | None = None,
14601468
ax: Axes | None = None,
14611469
return_fig: bool | None = None,
1470+
save: bool | str | None = None, # deprecated
14621471
**kwargs,
14631472
) -> Figure | Axes | None:
14641473
"""Plot the density of cells in an embedding (per condition).

0 commit comments

Comments
 (0)