Skip to content

Commit

Permalink
add timeplot setting to choose plot scaling based on values
Browse files Browse the repository at this point in the history
  • Loading branch information
shinkle-lanl committed Jan 30, 2024
1 parent b4984e1 commit 45b5f26
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions hippynn/_settings_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ def kernel_handler(kernel_string):
"DEBUG_AUTOINDEXING": (False, strtobool),
"USE_CUSTOM_KERNELS": ("auto", kernel_handler),
"WARN_LOW_DISTANCES": (True, strtobool),
"TIMEPLOT_AUTOSCALING": (True, strtobool),
}

settings = SimpleNamespace(**{k: default for k, (default, handler) in default_settings.items()})
Expand Down
5 changes: 3 additions & 2 deletions hippynn/plotting/timeplots.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,13 @@ def plot_over_time(metric_name, metric_data, pltkwd_info, save_dir):

datamin = min(min(arr) for arr in metric_data.values())
datamax = max(max(arr) for arr in metric_data.values())
if datamin > 0 and datamax / datamin > 2:
# if settings.TIMEPLOT_AUTOSCALING is set to True, only produce log-scale plots under certain conditions
if (not settings.TIMEPLOT_AUTOSCALING) or (datamin > 0 and datamax / datamin > 2):
plt.yscale("log")
fname = os.path.join(save_dir, metric_name + "_logplot" + settings.DEFAULT_PLOT_FILETYPE)
plt.savefig(fname)

if max(len(arr) for arr in metric_data.values()) > 10:
if (not settings.TIMEPLOT_AUTOSCALING) or (max(len(arr) for arr in metric_data.values()) > 10):
plt.xscale("log")
fname = os.path.join(save_dir, metric_name + "_loglogplot" + settings.DEFAULT_PLOT_FILETYPE)
plt.savefig(fname)
Expand Down

0 comments on commit 45b5f26

Please sign in to comment.