Skip to content

Commit 828f738

Browse files
authored
Merge pull request #290 from mpage/fix-flag-plot-limits
Only update X axis limits using axes with data
2 parents 93abcb3 + b04ad3d commit 828f738

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

bench_runner/plot.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,23 @@ def get_comparison_value(ref, r, base):
350350
json.dump(data, fd, indent=2)
351351

352352

353+
def _standardize_xlims(axs: Sequence[matplotlib.Axes]) -> None:
354+
if not len(axs):
355+
return
356+
357+
minx, maxx = axs[0].get_xlim()
358+
for ax in axs[1:]:
359+
if not ax.has_data():
360+
continue
361+
xlim = ax.get_xlim()
362+
minx = min(minx, xlim[0])
363+
maxx = max(maxx, xlim[1])
364+
365+
for ax in axs:
366+
if ax.has_data():
367+
ax.set_xlim((minx, maxx))
368+
369+
353370
def flag_effect_plot(
354371
results: Iterable[result.Result],
355372
output_filename: Path,
@@ -438,10 +455,7 @@ def get_comparison_value(ref, r):
438455

439456
fig.suptitle(title)
440457

441-
minx = min(ax.get_xlim()[0] for ax in axs[1:])
442-
maxx = max(ax.get_xlim()[1] for ax in axs[1:])
443-
for ax in axs:
444-
ax.set_xlim((minx, maxx))
458+
_standardize_xlims(axs)
445459

446460
savefig(output_filename, dpi=150)
447461

0 commit comments

Comments
 (0)