Skip to content

Commit

Permalink
Plotting QoL improvement.
Browse files Browse the repository at this point in the history
Guard against possible empty plots, which otherwise causes verbose warnings.

PiperOrigin-RevId: 714489386
  • Loading branch information
jcitrin authored and Torax team committed Jan 12, 2025
1 parent e446144 commit 8c68e87
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions torax/plotting/plotruns_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -482,12 +482,15 @@ def get_limit(plotdata, attrs, percentile, include_first_timepoint):
)

lower_bound = ymin / 1.05 if ymin > 0 else ymin * 1.05
if cfg.ylim_min_zero:
ax.set_ylim([min(lower_bound, 0), ymax * 1.05])
else:
ax.set_ylim([lower_bound, ymax * 1.05])

ax.legend(fontsize=cfg.legend_fontsize)
# Guard against empty data
if ymax != 0 or ymin != 0: # Check for meaningful data range
if cfg.ylim_min_zero:
ax.set_ylim([min(lower_bound, 0), ymax * 1.05])
else:
ax.set_ylim([lower_bound, ymax * 1.05])

ax.legend(fontsize=cfg.legend_fontsize)


def get_rho(
Expand Down

0 comments on commit 8c68e87

Please sign in to comment.