scripts: plot.py: Fixed subplots with differing widths

This was completely broken due to the renderer ignoring s.xspan. As a
result, subplots could end up rendered multiple times if they spanned
neighboring subplots.

Quick example:

  ./scripts/plot.py test.csv -xx \
      --subplot="-ya" \
      --subplot-right="-yb" \
      --subplot-below="-yc"

Fortunately the fix is easy, just make sure to increment x_ += s.xspan
as we render subplots across the x-axis.

Curiously the behavior was already correct for the y-axis, I guess
because the y-axis is quite a bit more complicated with how it crosses
multiple lines.
This commit is contained in:
Christopher Haster
2026-02-15 01:02:10 -06:00
parent 6998a10088
commit 36c3a1467b
+3 -1
View File
@@ -1811,7 +1811,8 @@ def main_(ring, csv_paths, *,
for line in ylabel_) for line in ylabel_)
if ylabel_ else '') if ylabel_ else '')
for x_ in range(grid.width): x_ = 0
while x_ < grid.width:
# figure out the grid x/y position # figure out the grid x/y position
subrow = row subrow = row
y_ = len(heights)-1 y_ = len(heights)-1
@@ -1821,6 +1822,7 @@ def main_(ring, csv_paths, *,
s = grid[x_, y_] s = grid[x_, y_]
subrow = row - sum(heights[s.y+s.yspan:]) subrow = row - sum(heights[s.y+s.yspan:])
x_ += s.xspan
# header # header
if subrow < s.ymargin[-1]: if subrow < s.ymargin[-1]: