Skip to content

Commit 5ee10f4

Browse files
authored
Merge pull request #45 from Axiomatic-AI/fix-blank-figure-bug
Fix blank figure bug
2 parents 733bb3b + 15da1fd commit 5ee10f4

File tree

1 file changed

+21
-9
lines changed

1 file changed

+21
-9
lines changed

src/axiomatic/pic_helpers.py

+21-9
Original file line numberDiff line numberDiff line change
@@ -211,19 +211,31 @@ def plot_parameter_history(parameters: List[Parameter], parameter_history: List[
211211
Returns:
212212
None: This function displays the plots and does not return any value.
213213
"""
214+
plt.clf()
215+
216+
fig, axs = plt.subplots(len(parameters), 1, figsize=(10, 5 * len(parameters)), sharex=True)
217+
fig.suptitle("Parameter History vs. Iterations")
218+
fig.supxlabel("Iterations")
219+
fig.supylabel("Parameter Values")
214220

215-
for param in parameters:
216-
plt.figure(figsize=(10, 5))
217-
plt.title(f"Parameter {param.path} vs. Iterations")
218-
plt.xlabel("Iterations")
219-
plt.ylabel(param.path)
221+
for i, param in enumerate(parameters):
220222
split_param = param.path.split(",")
221223
if "," in param.path:
222-
split_param = param.path.split(",")
223-
plt.plot([parameter_history[i][split_param[0]][split_param[1]] for i in range(len(parameter_history))])
224+
axs[i].plot(
225+
[parameter_history[j][split_param[0]][split_param[1]] for j in range(len(parameter_history))],
226+
label=param.path
227+
)
224228
else:
225-
plt.plot([parameter_history[i][param.path] for i in range(len(parameter_history))])
226-
return plt.gcf()
229+
axs[i].plot(
230+
[parameter_history[j][param.path] for j in range(len(parameter_history))],
231+
label=param.path
232+
)
233+
axs[i].legend()
234+
axs[i].grid(True)
235+
236+
plt.tight_layout(rect=[0, 0, 1, 0.96])
237+
plt.close(fig)
238+
return fig
227239

228240

229241
def print_statements(

0 commit comments

Comments
 (0)