MAIDR Documentation - v4.4.0
    Preparing search index...

    Function stepDataVertices

    • Pick the data vertices out of a rendered step path.

      A step chart is drawn with the corner vertices the steps introduce, so the rendered path carries more vertices than the series has points — matplotlib emits 2N - 1 for hv/vh and 2N for mid. The surplus is interleaved rather than trailing, so it is removed by stride:

      • 2N - 1 vertices (hv/vh): the even-indexed vertices are exactly the data points; the odd-indexed ones are the corners.
      • 2N vertices (mid): each data point owns a horizontal pair. The first and last runs are half-width — steps-mid starts at x[0] and ends at x[N-1] rather than at a midpoint — so those two samples sit at the outer end of their run and are read off directly. An interior run spans midpoint to midpoint, and its centre is the sample only when the spacing either side is equal: in general the centre is (x[i-1] + 2x[i] + x[i+1]) / 4, off by a quarter of the local second difference. The highlight therefore always lands inside the sample's own run — never on a neighbour's — but on an irregularly sampled mid chart it is not exactly on the sample. Recovering x[i] exactly would mean iterating x[i+1] = 2m[i] - x[i] from one end, which is numerically unstable over a long series; a bounded sub-run offset is the better trade.

      Shared with AreaTrace, which meets the same interleaved geometry once a band is stepped, so the two cannot disagree about which vertex is a sample.

      Parameters

      • coordinates: LinePoint[]

        Vertices parsed from the path

      • expected: number

        How many samples the series has

      Returns LinePoint[] | null

      The data vertices, or null when the count matches neither shape — a library that simplifies collinear vertices produces neither, and interpolating along the surviving segments is the right recovery there.