Skip to content

Commit

Permalink
make convergence plot xlim dynamic
Browse files Browse the repository at this point in the history
  • Loading branch information
yusuferentunc committed Oct 1, 2024
1 parent 294539c commit b3f6521
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions domhmm/analysis/domhmm.py
Original file line number Diff line number Diff line change
Expand Up @@ -629,18 +629,22 @@ def plot_hmm_result(self):
Plots Hidden Markov Models training history
"""
x_len = 0
for resname, ghmm in self.results['HMM'].items():
if self.asymmetric_membrane:
for leaflet in range(2):
x_len = max(x_len,len(ghmm[leaflet].monitor_.history) - 1)
plt.semilogy(np.arange(len(ghmm[leaflet].monitor_.history) - 1),
np.diff(np.array(ghmm[leaflet].monitor_.history)),
ls="-", label=f"{resname}_{leaflet}", lw=2)
else:
x_len = max(x_len, len(ghmm.monitor_.history) - 1)
plt.semilogy(np.arange(len(ghmm.monitor_.history) - 1), np.diff(np.array(ghmm.monitor_.history)),
ls="-", label=resname, lw=2)
x_len = (x_len // 100 + 1) * 100
plt.legend(fontsize=15)
plt.semilogy(np.arange(100), np.repeat(1E-4, 100), color="k", ls="--", lw=2)
plt.xlim(0, 100)
plt.semilogy(np.arange(x_len), np.repeat(1E-4, x_len), color="k", ls="--", lw=2)
plt.xlim(0, x_len)
plt.ylim(1E-5, 15E5)
plt.ylabel(r"$\Delta(log(\hat{L}))$", fontsize=18)
plt.xlabel("Iterations", fontsize=18)
Expand Down

0 comments on commit b3f6521

Please sign in to comment.