Skip to content

Commit 7658fe9

Browse files
committed
Added xlim ylim to plotting #951
and fixed a small bug when legend wasnt provided
1 parent 52e8876 commit 7658fe9

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

atom_batch_execution/scripts/batch_execution

+4
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,10 @@ def main():
138138
# Dataset is no longer needed
139139
del dataset
140140

141+
# Add dataset dirname to data
142+
dataset_dirname = os.path.dirname(data["dataset_path"])
143+
data["dataset_dirname"] = dataset_dirname
144+
141145
# Add folds to data
142146
data['folds'] = fold_list
143147

atom_batch_execution/scripts/plot_graphs

+16-2
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,11 @@ def main():
144144
# nightmare to work with
145145
# Get y data
146146
for name in x_data_files_names:
147-
file_path_to_get_data_fom = glob.glob(f'{args["results_folder"]}/{name}/{plot_line["ydata"]["file"]}')[0]
147+
try:
148+
file_path_to_get_data_fom = glob.glob(f'{args["results_folder"]}/{name}/{plot_line["ydata"]["file"]}')[0]
149+
except:
150+
atomError(f"Experiment {x_data_files_names} doesn't have data file {plot_line['ydata']['file']}")
151+
exit()
148152
# Method with pandas, not working
149153
# df = df.T
150154
# df.drop(0)
@@ -206,6 +210,8 @@ def main():
206210
markers = plot_options['markers']
207211
xscale = plot_options['xscale']
208212
yscale = plot_options['yscale']
213+
xlim = plot_options.get('xlim')
214+
ylim = plot_options.get('ylim')
209215

210216

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

238244
x_values = plot_line['x_values']
239245
y_values = plot_line['y_values']
240-
legend = plot_line['legend'] if plot_line['legend'] else None
246+
legend = plot_line.get('legend')
241247

242248
# Plotting
243249
plt.plot(x_values, y_values, color=colors[idx], linestyle=linestyles[idx], linewidth=linewidths[idx],
@@ -250,6 +256,12 @@ def main():
250256
plt.yscale(yscale) # Set y-scale
251257
if legend is not None:
252258
plt.legend(prop={'size': 6})
259+
260+
if xlim:
261+
plt.xlim(xlim)
262+
263+
if ylim:
264+
plt.ylim(ylim)
253265

254266
# Save figure in output folder
255267

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

284+
plt.close()
285+
272286
# Getting back to cwd, to prevent confusion if this script is further modified
273287
os.chdir(cwd)
274288

0 commit comments

Comments
 (0)