Skip to content

Commit

Permalink
Allow overriding plotting title
Browse files Browse the repository at this point in the history
  • Loading branch information
callumforrester committed Feb 13, 2024
1 parent 11e1e20 commit 5720ea1
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/scanspec/plot.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from itertools import cycle
from typing import Any, Dict, Iterator, List
from typing import Any, Dict, Iterator, List, Optional

import numpy as np
from matplotlib import colors, patches
Expand Down Expand Up @@ -85,7 +85,7 @@ def _plot_spline(axes, ranges, arrays: List[np.ndarray], index_colours: Dict[int
yield unscaled_splines


def plot_spec(spec: Spec[Any]):
def plot_spec(spec: Spec[Any], title: Optional[str] = None):
"""Plot a spec, drawing the path taken through the scan.
Uses a different colour for each frame, grey for the turnarounds, and
Expand Down Expand Up @@ -124,7 +124,8 @@ def plot_spec(spec: Spec[Any]):
plt_axes.set_xlabel(axes[-1])

# Title with dimension sizes
plt.title(", ".join(f"Dim[{' '.join(d.axes())} len={len(d)}]" for d in dims))
title = title or ", ".join(f"Dim[{' '.join(d.axes())} len={len(d)}]" for d in dims)
plt.title(title)

# Plot any Regions
if ndims <= 2:
Expand Down

0 comments on commit 5720ea1

Please sign in to comment.