diff --git a/docs/changes/newsfragments/8388.improved b/docs/changes/newsfragments/8388.improved new file mode 100644 index 00000000000..83aa40c75dd --- /dev/null +++ b/docs/changes/newsfragments/8388.improved @@ -0,0 +1,5 @@ +The ``colorbars`` argument of :func:`.plot_dataset` and :func:`.plot_by_id` now +accepts a sequence that may contain ``None``. Both functions return a list of +colorbars in which the entries for 1D plots are ``None``, so passing the result +back in, which is how you plot into the same axes again, did not match the +declared argument type. A sequence of colorbars is still accepted. diff --git a/src/qcodes/dataset/plotting.py b/src/qcodes/dataset/plotting.py index 6145968e782..11c5ee79c35 100644 --- a/src/qcodes/dataset/plotting.py +++ b/src/qcodes/dataset/plotting.py @@ -95,7 +95,10 @@ def heatmaphandler(**kwargs: Any) -> Any: def plot_dataset( dataset: DataSetProtocol, axes: Axes | Sequence[Axes] | None = None, - colorbars: Colorbar | Sequence[Colorbar] | Sequence[None] | None = None, + # ``Sequence[Colorbar | None]`` so that the list of colorbars returned by + # this function can be passed straight back in, which is how you plot into + # the same axes again. A ``Sequence[Colorbar]`` is also one of these. + colorbars: Colorbar | Sequence[Colorbar | None] | None = None, rescale_axes: bool = True, auto_color_scale: bool | None = None, cutoff_percentile: tuple[float, float] | float | None = None, @@ -417,7 +420,7 @@ def plot_and_save_image( def plot_by_id( run_id: int, axes: Axes | Sequence[Axes] | None = None, - colorbars: Colorbar | Sequence[Colorbar] | None = None, + colorbars: Colorbar | Sequence[Colorbar | None] | None = None, rescale_axes: bool = True, auto_color_scale: bool | None = None, cutoff_percentile: tuple[float, float] | float | None = None,