Skip to content

Commit 66bd38c

Browse files
Use plt.show to avoid extra output (#78)
1 parent 71e9bc5 commit 66bd38c

File tree

6 files changed

+24
-0
lines changed

6 files changed

+24
-0
lines changed

examples/dos-align/dos-align.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -848,6 +848,7 @@ def train_model(model_to_train, fixed_DOS, structure_splines, spline_positions,
848848
plt.xlabel("Epochs")
849849
plt.ylabel("RMSE")
850850
plt.title("Train Loss vs Epoch")
851+
plt.show()
851852
# %%
852853
# Lets plot the val loss histories to compare their learning behaviour
853854
#
@@ -861,6 +862,7 @@ def train_model(model_to_train, fixed_DOS, structure_splines, spline_positions,
861862
plt.xlabel("Epochs")
862863
plt.ylabel("RMSE")
863864
plt.title("Validation Loss vs Epoch")
865+
plt.show()
864866

865867

866868
# %%
@@ -918,6 +920,7 @@ def train_model(model_to_train, fixed_DOS, structure_splines, spline_positions,
918920
plt.title("Energy Reference - Average Hartree Potential")
919921
plt.xlabel("Energy [eV]")
920922
plt.ylabel("DOS")
923+
plt.show()
921924
print("The DOSes, despite looking similar, are offset along the energy axis")
922925

923926
# %%
@@ -927,6 +930,7 @@ def train_model(model_to_train, fixed_DOS, structure_splines, spline_positions,
927930
plt.title("Energy Reference - Fermi Level")
928931
plt.xlabel("Energy [eV]")
929932
plt.ylabel("DOS")
933+
plt.show()
930934

931935
print("It is better aligned but still quite some offset")
932936
# %%
@@ -943,6 +947,7 @@ def train_model(model_to_train, fixed_DOS, structure_splines, spline_positions,
943947
plt.title("Energy Reference - Optimized")
944948
plt.xlabel("Energy [eV]")
945949
plt.ylabel("DOS")
950+
plt.show()
946951
print("The DOS alignment is better under the optimized energy reference")
947952
print("The difference will increase with more training epochs")
948953
# %%

examples/gaas-map/gaas-map.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@
101101
ax.plot(energy / natoms, atom_energy / natoms, "b.")
102102
ax.set_xlabel("Energy / (eV/atom)")
103103
ax.set_ylabel("Atomic e. / (eV/atom)")
104+
plt.show()
104105
print(f"RMSE / (eV/atom): {np.sqrt(np.mean((cohesive_peratom)**2))}")
105106

106107

@@ -172,6 +173,7 @@
172173
ax.set_ylabel("PCA[2]")
173174
cbar = fig.colorbar(scatter, ax=ax)
174175
cbar.set_label("energy / eV/at.")
176+
plt.show()
175177

176178
# computes PCovR map
177179
pcovr = PCovR(n_components=4)
@@ -183,6 +185,7 @@
183185
ax.set_ylabel("PCovR[2]")
184186
cbar = fig.colorbar(scatter, ax=ax)
185187
cbar.set_label("energy / (eV/at.)")
188+
plt.show()
186189

187190

188191
######################################################################

examples/lpr/lpr.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@
206206
ax.set_ylabel("PC2")
207207
fig.colorbar(im, ax=ax, label="LPR")
208208
ax.tick_params(left=False, bottom=False, labelleft=False, labelbottom=False)
209+
plt.show()
209210

210211
# %%
211212
# In the PCA map, where each point corresponds to an
@@ -253,6 +254,7 @@
253254
ax.set_ylabel("PC2")
254255
fig.colorbar(im, ax=ax, label=r"LPR$_{\mathrm{new}}$ / LPR$_{\mathrm{old}}$")
255256
ax.tick_params(left=False, bottom=False, labelleft=False, labelbottom=False)
257+
plt.show()
256258

257259
# %%
258260
# It is apparent that while the LPR stays more or less consistent for the

examples/path-integrals/path-integrals.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@
150150
ax.set_xlabel(r"$t$ / ps")
151151
ax.set_ylabel(r"energy / eV")
152152
ax.legend()
153+
plt.show()
153154

154155
# %%
155156
# While the potential energy is simply the mean over the beads of the
@@ -179,6 +180,7 @@
179180
ax.set_xlabel(r"$t$ / ps")
180181
ax.set_ylabel(r"energy / eV")
181182
ax.legend()
183+
plt.show()
182184

183185
# %%
184186
# You can also visualize the (very short) trajectory in a way that highlights the
@@ -252,6 +254,7 @@
252254
ax.set_xlabel(r"$t$ / ps")
253255
ax.set_ylabel(r"energy / eV")
254256
ax.legend()
257+
plt.show()
255258

256259
# %%
257260
# However, you should be somewhat careful: PIGLET converges *some* but not all the
@@ -270,6 +273,7 @@
270273
ax.set_xlabel(r"$t$ / ps")
271274
ax.set_ylabel(r"energy / eV")
272275
ax.legend()
276+
plt.show()
273277

274278
# %%
275279
# Kinetic energy tensors

examples/pi-metad/pi-metad.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,7 @@
317317
ax.set_xlabel(r"$t$ / ps")
318318
ax.set_ylabel(r"energy / eV")
319319
ax.legend(loc="upper left", ncols=1)
320+
plt.show()
320321

321322
# %%
322323
#
@@ -360,6 +361,7 @@ def moving_average(arr, window_size):
360361
ax.set_xlabel(r"$t$ / ps")
361362
ax.set_ylabel(r"temperature / K")
362363
ax.legend(loc="upper left", ncols=2)
364+
plt.show()
363365

364366
# %%
365367
# It is clear that the very high rate of biasing used in this demonstrative
@@ -458,6 +460,7 @@ def moving_average(arr, window_size):
458460
ax[0].set_title(r"$t=0.8$ ps")
459461
ax[1].set_title(r"$t=2.5$ ps")
460462
ax[2].set_title(r"$t=5.0$ ps")
463+
plt.show()
461464

462465
# %%
463466
# Biasing a path integral calculation
@@ -667,6 +670,7 @@ def moving_average(arr, window_size):
667670
ax[0].set_title(r"$t=0.8$ ps")
668671
ax[1].set_title(r"$t=2.5$ ps")
669672
ax[2].set_title(r"$t=5.0$ ps")
673+
plt.show()
670674

671675
# %%
672676
# Assessing quantum nuclear effects
@@ -694,6 +698,7 @@ def moving_average(arr, window_size):
694698
plt.Line2D([0], [0], color="r", label="PIMD"),
695699
]
696700
)
701+
plt.show()
697702

698703
# %%
699704
#
@@ -730,6 +735,7 @@ def moving_average(arr, window_size):
730735
plt.Line2D([0], [0], color="r", label="PIMD"),
731736
]
732737
)
738+
plt.show()
733739

734740
# %%
735741
#
@@ -765,6 +771,7 @@ def moving_average(arr, window_size):
765771
ax.legend(ncols=2, loc="upper right", fontsize=9)
766772
ax.set_ylabel(r"$F$ / eV")
767773
ax.set_xlabel(r"$\Delta C_\mathrm{H}$")
774+
plt.show()
768775

769776
# %%
770777
# This model system is representative of the behavior of protons

examples/roy-gch/roy-gch.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@
9090
ax.plot(density[ssel], energy[ssel], "k--")
9191
ax.set_xlabel("density / g/cm$^3$")
9292
ax.set_ylabel("energy / kJ/mol")
93+
plt.show()
9394

9495
print(
9596
f"Mean hull energy for 'known' stable structures {dch_dist[iknown].mean()} kJ/mol"
@@ -194,6 +195,7 @@
194195
ax.set_ylabel("PCA[2]")
195196
cbar = fig.colorbar(scatter, ax=ax)
196197
cbar.set_label("energy / kJ/mol")
198+
plt.show()
197199

198200

199201
# %%
@@ -221,6 +223,7 @@
221223
ax.set_ylabel("PCA[2]")
222224
ax.set_zlabel("energy / kJ/mol\n \n", labelpad=11)
223225
ax.view_init(25, 110)
226+
plt.show()
224227

225228

226229
# %%

0 commit comments

Comments
 (0)