Skip to content

Commit

Permalink
Added xlim ylim to plotting #951
Browse files Browse the repository at this point in the history
and fixed a small bug when legend wasnt provided
  • Loading branch information
brunofavs committed May 14, 2024
1 parent 52e8876 commit 7658fe9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
4 changes: 4 additions & 0 deletions atom_batch_execution/scripts/batch_execution
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ def main():
# Dataset is no longer needed
del dataset

# Add dataset dirname to data
dataset_dirname = os.path.dirname(data["dataset_path"])
data["dataset_dirname"] = dataset_dirname

# Add folds to data
data['folds'] = fold_list

Expand Down
18 changes: 16 additions & 2 deletions atom_batch_execution/scripts/plot_graphs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,11 @@ def main():
# nightmare to work with
# Get y data
for name in x_data_files_names:
file_path_to_get_data_fom = glob.glob(f'{args["results_folder"]}/{name}/{plot_line["ydata"]["file"]}')[0]
try:
file_path_to_get_data_fom = glob.glob(f'{args["results_folder"]}/{name}/{plot_line["ydata"]["file"]}')[0]
except:
atomError(f"Experiment {x_data_files_names} doesn't have data file {plot_line['ydata']['file']}")
exit()
# Method with pandas, not working
# df = df.T
# df.drop(0)
Expand Down Expand Up @@ -206,6 +210,8 @@ def main():
markers = plot_options['markers']
xscale = plot_options['xscale']
yscale = plot_options['yscale']
xlim = plot_options.get('xlim')
ylim = plot_options.get('ylim')


# Normalizing options to allow them to be defined as lists or individual str/int
Expand Down Expand Up @@ -237,7 +243,7 @@ def main():

x_values = plot_line['x_values']
y_values = plot_line['y_values']
legend = plot_line['legend'] if plot_line['legend'] else None
legend = plot_line.get('legend')

# Plotting
plt.plot(x_values, y_values, color=colors[idx], linestyle=linestyles[idx], linewidth=linewidths[idx],
Expand All @@ -250,6 +256,12 @@ def main():
plt.yscale(yscale) # Set y-scale
if legend is not None:
plt.legend(prop={'size': 6})

if xlim:
plt.xlim(xlim)

if ylim:
plt.ylim(ylim)

# Save figure in output folder

Expand All @@ -269,6 +281,8 @@ def main():
if args["show_plots"]:
plt.show()

plt.close()

# Getting back to cwd, to prevent confusion if this script is further modified
os.chdir(cwd)

Expand Down

0 comments on commit 7658fe9

Please sign in to comment.