Skip to content

Commit 991af9f

Browse files
committed
added an option to draw legend in free energy profile graphs
1 parent fae69c0 commit 991af9f

File tree

2 files changed

+37
-18
lines changed

2 files changed

+37
-18
lines changed

doc/metadynminer/index.html

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,17 @@
33
<head>
44
<meta charset="utf-8">
55
<meta name="viewport" content="width=device-width, initial-scale=1, minimum-scale=1" />
6-
<meta name="generator" content="pdoc 0.8.1" />
6+
<meta name="generator" content="pdoc 0.10.0" />
77
<title>metadynminer API documentation</title>
88
<meta name="description" content="Metadynminer is a package designed to help you analyse output HILLS files from PLUMED metadynamics simulations …" />
9-
<link href='https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.0/normalize.min.css' rel='stylesheet'>
10-
<link href='https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/8.0.0/sanitize.min.css' rel='stylesheet'>
11-
<link href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/github.min.css" rel="stylesheet">
12-
<style>.flex{display:flex !important}body{line-height:1.5em}#content{padding:20px}#sidebar{padding:30px;overflow:hidden}#sidebar > *:last-child{margin-bottom:2cm}.http-server-breadcrumbs{font-size:130%;margin:0 0 15px 0}#footer{font-size:.75em;padding:5px 30px;border-top:1px solid #ddd;text-align:right}#footer p{margin:0 0 0 1em;display:inline-block}#footer p:last-child{margin-right:30px}h1,h2,h3,h4,h5{font-weight:300}h1{font-size:2.5em;line-height:1.1em}h2{font-size:1.75em;margin:1em 0 .50em 0}h3{font-size:1.4em;margin:25px 0 10px 0}h4{margin:0;font-size:105%}a{color:#058;text-decoration:none;transition:color .3s ease-in-out}a:hover{color:#e82}.title code{font-weight:bold}h2[id^="header-"]{margin-top:2em}.ident{color:#900}pre code{background:#f8f8f8;font-size:.8em;line-height:1.4em}code{background:#f2f2f1;padding:1px 4px;overflow-wrap:break-word}h1 code{background:transparent}pre{background:#f8f8f8;border:0;border-top:1px solid #ccc;border-bottom:1px solid #ccc;margin:1em 0;padding:1ex}#http-server-module-list{display:flex;flex-flow:column}#http-server-module-list div{display:flex}#http-server-module-list dt{min-width:10%}#http-server-module-list p{margin-top:0}.toc ul,#index{list-style-type:none;margin:0;padding:0}#index code{background:transparent}#index h3{border-bottom:1px solid #ddd}#index ul{padding:0}#index h4{margin-top:.6em;font-weight:bold}@media (min-width:200ex){#index .two-column{column-count:2}}@media (min-width:300ex){#index .two-column{column-count:3}}dl{margin-bottom:2em}dl dl:last-child{margin-bottom:4em}dd{margin:0 0 1em 3em}#header-classes + dl > dd{margin-bottom:3em}dd dd{margin-left:2em}dd p{margin:10px 0}.name{background:#eee;font-weight:bold;font-size:.85em;padding:5px 10px;display:inline-block;min-width:40%}.name:hover{background:#e0e0e0}.name > span:first-child{white-space:nowrap}.name.class > span:nth-child(2){margin-left:.4em}.inherited{color:#999;border-left:5px solid #eee;padding-left:1em}.inheritance em{font-style:normal;font-weight:bold}.desc h2{font-weight:400;font-size:1.25em}.desc h3{font-size:1em}.desc dt code{background:inherit}.source summary,.git-link-div{color:#666;text-align:right;font-weight:400;font-size:.8em;text-transform:uppercase}.source summary > *{white-space:nowrap;cursor:pointer}.git-link{color:inherit;margin-left:1em}.source pre{max-height:500px;overflow:auto;margin:0}.source pre code{font-size:12px;overflow:visible}.hlist{list-style:none}.hlist li{display:inline}.hlist li:after{content:',\2002'}.hlist li:last-child:after{content:none}.hlist .hlist{display:inline;padding-left:1em}img{max-width:100%}.admonition{padding:.1em .5em;margin-bottom:1em}.admonition-title{font-weight:bold}.admonition.note,.admonition.info,.admonition.important{background:#aef}.admonition.todo,.admonition.versionadded,.admonition.tip,.admonition.hint{background:#dfd}.admonition.warning,.admonition.versionchanged,.admonition.deprecated{background:#fd4}.admonition.error,.admonition.danger,.admonition.caution{background:lightpink}</style>
9+
<link rel="preload stylesheet" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/11.0.1/sanitize.min.css" integrity="sha256-PK9q560IAAa6WVRRh76LtCaI8pjTJ2z11v0miyNNjrs=" crossorigin>
10+
<link rel="preload stylesheet" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/11.0.1/typography.min.css" integrity="sha256-7l/o7C8jubJiy74VsKTidCy1yBkRtiUGbVkYBylBqUg=" crossorigin>
11+
<link rel="stylesheet preload" as="style" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.1/styles/github.min.css" crossorigin>
12+
<style>:root{--highlight-color:#fe9}.flex{display:flex !important}body{line-height:1.5em}#content{padding:20px}#sidebar{padding:30px;overflow:hidden}#sidebar > *:last-child{margin-bottom:2cm}.http-server-breadcrumbs{font-size:130%;margin:0 0 15px 0}#footer{font-size:.75em;padding:5px 30px;border-top:1px solid #ddd;text-align:right}#footer p{margin:0 0 0 1em;display:inline-block}#footer p:last-child{margin-right:30px}h1,h2,h3,h4,h5{font-weight:300}h1{font-size:2.5em;line-height:1.1em}h2{font-size:1.75em;margin:1em 0 .50em 0}h3{font-size:1.4em;margin:25px 0 10px 0}h4{margin:0;font-size:105%}h1:target,h2:target,h3:target,h4:target,h5:target,h6:target{background:var(--highlight-color);padding:.2em 0}a{color:#058;text-decoration:none;transition:color .3s ease-in-out}a:hover{color:#e82}.title code{font-weight:bold}h2[id^="header-"]{margin-top:2em}.ident{color:#900}pre code{background:#f8f8f8;font-size:.8em;line-height:1.4em}code{background:#f2f2f1;padding:1px 4px;overflow-wrap:break-word}h1 code{background:transparent}pre{background:#f8f8f8;border:0;border-top:1px solid #ccc;border-bottom:1px solid #ccc;margin:1em 0;padding:1ex}#http-server-module-list{display:flex;flex-flow:column}#http-server-module-list div{display:flex}#http-server-module-list dt{min-width:10%}#http-server-module-list p{margin-top:0}.toc ul,#index{list-style-type:none;margin:0;padding:0}#index code{background:transparent}#index h3{border-bottom:1px solid #ddd}#index ul{padding:0}#index h4{margin-top:.6em;font-weight:bold}@media (min-width:200ex){#index .two-column{column-count:2}}@media (min-width:300ex){#index .two-column{column-count:3}}dl{margin-bottom:2em}dl dl:last-child{margin-bottom:4em}dd{margin:0 0 1em 3em}#header-classes + dl > dd{margin-bottom:3em}dd dd{margin-left:2em}dd p{margin:10px 0}.name{background:#eee;font-weight:bold;font-size:.85em;padding:5px 10px;display:inline-block;min-width:40%}.name:hover{background:#e0e0e0}dt:target .name{background:var(--highlight-color)}.name > span:first-child{white-space:nowrap}.name.class > span:nth-child(2){margin-left:.4em}.inherited{color:#999;border-left:5px solid #eee;padding-left:1em}.inheritance em{font-style:normal;font-weight:bold}.desc h2{font-weight:400;font-size:1.25em}.desc h3{font-size:1em}.desc dt code{background:inherit}.source summary,.git-link-div{color:#666;text-align:right;font-weight:400;font-size:.8em;text-transform:uppercase}.source summary > *{white-space:nowrap;cursor:pointer}.git-link{color:inherit;margin-left:1em}.source pre{max-height:500px;overflow:auto;margin:0}.source pre code{font-size:12px;overflow:visible}.hlist{list-style:none}.hlist li{display:inline}.hlist li:after{content:',\2002'}.hlist li:last-child:after{content:none}.hlist .hlist{display:inline;padding-left:1em}img{max-width:100%}td{padding:0 .5em}.admonition{padding:.1em .5em;margin-bottom:1em}.admonition-title{font-weight:bold}.admonition.note,.admonition.info,.admonition.important{background:#aef}.admonition.todo,.admonition.versionadded,.admonition.tip,.admonition.hint{background:#dfd}.admonition.warning,.admonition.versionchanged,.admonition.deprecated{background:#fd4}.admonition.error,.admonition.danger,.admonition.caution{background:lightpink}</style>
1313
<style media="screen and (min-width: 700px)">@media screen and (min-width:700px){#sidebar{width:30%;height:100vh;overflow:auto;position:sticky;top:0}#content{width:70%;max-width:100ch;padding:3em 4em;border-left:1px solid #ddd}pre code{font-size:1em}.item .name{font-size:1em}main{display:flex;flex-direction:row-reverse;justify-content:flex-end}.toc ul ul,#index ul{padding-left:1.5em}.toc > ul > li{margin-top:.5em}}</style>
1414
<style media="print">@media print{#sidebar h1{page-break-before:always}.source{display:none}}@media print{*{background:transparent !important;color:#000 !important;box-shadow:none !important;text-shadow:none !important}a[href]:after{content:" (" attr(href) ")";font-size:90%}a[href][title]:after{content:none}abbr[title]:after{content:" (" attr(title) ")"}.ir a:after,a[href^="javascript:"]:after,a[href^="#"]:after{content:""}pre,blockquote{border:1px solid #999;page-break-inside:avoid}thead{display:table-header-group}tr,img{page-break-inside:avoid}img{max-width:100% !important}@page{margin:0.5cm}p,h2,h3{orphans:3;widows:3}h1,h2,h3,h4,h5,h6{page-break-after:avoid}}</style>
15+
<script defer src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.1/highlight.min.js" integrity="sha256-Uv3H6lx7dJmRfRvH8TH6kJD1TSK1aFcwgx+mdg3epi8=" crossorigin></script>
16+
<script>window.addEventListener('DOMContentLoaded', () => hljs.initHighlighting())</script>
1517
</head>
1618
<body>
1719
<main>
@@ -116,7 +118,7 @@ <h1 class="title">Package <code>metadynminer</code></h1>
116118
&#34;&#34;&#34;
117119

118120
name = &#34;metadynminer&#34;
119-
__version__ = &#34;0.4.0&#34;
121+
__version__ = &#34;0.5.0&#34;
120122
__author__ = &#39;Jan Beránek&#39;
121123

122124
__pdoc__ = {}
@@ -2339,7 +2341,7 @@ <h1 class="title">Package <code>metadynminer</code></h1>
23392341
plt.clabel(cont, levels = np.arange(0, (vmax + 0.01), contours_spacing))
23402342

23412343
if self.minima.shape[0] == 1:
2342-
background = cmap((float(self.minima.iloc[1])-vmin)/(vmax-vmin))
2344+
background = cmap((float(self.minima.iloc[0,1])-vmin)/(vmax-vmin))
23432345
luma = background[0]*0.2126+background[1]*0.7152+background[3]*0.0722
23442346
if luma &gt; 0.6 and not color_set:
23452347
color = &#34;black&#34;
@@ -2746,7 +2748,7 @@ <h1 class="title">Package <code>metadynminer</code></h1>
27462748
else:
27472749
print(&#34;Fes object doesn&#39;t have supported number of CVs.&#34;)
27482750

2749-
def plot(self, png_name=None, image_size=[10,7], xlabel=None, ylabel=None, label_size=12, cmap=&#34;jet&#34;):
2751+
def plot(self, png_name=None, image_size=[10,7], xlabel=None, ylabel=None, label_size=12, cmap=&#34;jet&#34;, legend=True):
27502752
&#34;&#34;&#34;
27512753
Visualization function for free energy profiles.
27522754

@@ -2769,6 +2771,8 @@ <h1 class="title">Package <code>metadynminer</code></h1>
27692771
* label_size (default=12) = size of labels
27702772

27712773
* cmap (default=&#34;jet&#34;) = matplotlib colormap used for coloring the line of the minima
2774+
2775+
* legend (default=True) = whether there should be a matplotlib&#39;s legend in the graph
27722776
&#34;&#34;&#34;
27732777

27742778
plt.figure(figsize=(image_size[0],image_size[1]))
@@ -2789,6 +2793,8 @@ <h1 class="title">Package <code>metadynminer</code></h1>
27892793
plt.ylabel(&#39;free energy difference (kJ/mol)&#39;, size=label_size)
27902794
else:
27912795
plt.ylabel(ylabel, size=label_size)
2796+
if legend:
2797+
plt.legend(self.minima.iloc[:,0], loc=&#34;lower right&#34;)
27922798
if png_name != None:
27932799
plt.savefig(png_name)</code></pre>
27942800
</details>
@@ -3083,7 +3089,7 @@ <h2 class="section-title" id="header-classes">Classes</h2>
30833089
else:
30843090
print(&#34;Fes object doesn&#39;t have supported number of CVs.&#34;)
30853091

3086-
def plot(self, png_name=None, image_size=[10,7], xlabel=None, ylabel=None, label_size=12, cmap=&#34;jet&#34;):
3092+
def plot(self, png_name=None, image_size=[10,7], xlabel=None, ylabel=None, label_size=12, cmap=&#34;jet&#34;, legend=True):
30873093
&#34;&#34;&#34;
30883094
Visualization function for free energy profiles.
30893095

@@ -3106,6 +3112,8 @@ <h2 class="section-title" id="header-classes">Classes</h2>
31063112
* label_size (default=12) = size of labels
31073113

31083114
* cmap (default=&#34;jet&#34;) = matplotlib colormap used for coloring the line of the minima
3115+
3116+
* legend (default=True) = whether there should be a matplotlib&#39;s legend in the graph
31093117
&#34;&#34;&#34;
31103118

31113119
plt.figure(figsize=(image_size[0],image_size[1]))
@@ -3126,6 +3134,8 @@ <h2 class="section-title" id="header-classes">Classes</h2>
31263134
plt.ylabel(&#39;free energy difference (kJ/mol)&#39;, size=label_size)
31273135
else:
31283136
plt.ylabel(ylabel, size=label_size)
3137+
if legend:
3138+
plt.legend(self.minima.iloc[:,0], loc=&#34;lower right&#34;)
31293139
if png_name != None:
31303140
plt.savefig(png_name)</code></pre>
31313141
</details>
@@ -3344,7 +3354,7 @@ <h3>Methods</h3>
33443354
</details>
33453355
</dd>
33463356
<dt id="metadynminer.FEProfile.plot"><code class="name flex">
3347-
<span>def <span class="ident">plot</span></span>(<span>self, png_name=None, image_size=[10, 7], xlabel=None, ylabel=None, label_size=12, cmap='jet')</span>
3357+
<span>def <span class="ident">plot</span></span>(<span>self, png_name=None, image_size=[10, 7], xlabel=None, ylabel=None, label_size=12, cmap='jet', legend=True)</span>
33483358
</code></dt>
33493359
<dd>
33503360
<div class="desc"><p>Visualization function for free energy profiles. </p>
@@ -3370,12 +3380,15 @@ <h2 id="parameters">Parameters</h2>
33703380
<li>
33713381
<p>cmap (default="jet") = matplotlib colormap used for coloring the line of the minima</p>
33723382
</li>
3383+
<li>
3384+
<p>legend (default=True) = whether there should be a matplotlib's legend in the graph</p>
3385+
</li>
33733386
</ul></div>
33743387
<details class="source">
33753388
<summary>
33763389
<span>Expand source code</span>
33773390
</summary>
3378-
<pre><code class="python">def plot(self, png_name=None, image_size=[10,7], xlabel=None, ylabel=None, label_size=12, cmap=&#34;jet&#34;):
3391+
<pre><code class="python">def plot(self, png_name=None, image_size=[10,7], xlabel=None, ylabel=None, label_size=12, cmap=&#34;jet&#34;, legend=True):
33793392
&#34;&#34;&#34;
33803393
Visualization function for free energy profiles.
33813394

@@ -3398,6 +3411,8 @@ <h2 id="parameters">Parameters</h2>
33983411
* label_size (default=12) = size of labels
33993412

34003413
* cmap (default=&#34;jet&#34;) = matplotlib colormap used for coloring the line of the minima
3414+
3415+
* legend (default=True) = whether there should be a matplotlib&#39;s legend in the graph
34013416
&#34;&#34;&#34;
34023417

34033418
plt.figure(figsize=(image_size[0],image_size[1]))
@@ -3418,6 +3433,8 @@ <h2 id="parameters">Parameters</h2>
34183433
plt.ylabel(&#39;free energy difference (kJ/mol)&#39;, size=label_size)
34193434
else:
34203435
plt.ylabel(ylabel, size=label_size)
3436+
if legend:
3437+
plt.legend(self.minima.iloc[:,0], loc=&#34;lower right&#34;)
34213438
if png_name != None:
34223439
plt.savefig(png_name)</code></pre>
34233440
</details>
@@ -6578,7 +6595,7 @@ <h3>Methods</h3>
65786595
plt.clabel(cont, levels = np.arange(0, (vmax + 0.01), contours_spacing))
65796596

65806597
if self.minima.shape[0] == 1:
6581-
background = cmap((float(self.minima.iloc[1])-vmin)/(vmax-vmin))
6598+
background = cmap((float(self.minima.iloc[0,1])-vmin)/(vmax-vmin))
65826599
luma = background[0]*0.2126+background[1]*0.7152+background[3]*0.0722
65836600
if luma &gt; 0.6 and not color_set:
65846601
color = &#34;black&#34;
@@ -7426,7 +7443,7 @@ <h3>Methods</h3>
74267443
plt.clabel(cont, levels = np.arange(0, (vmax + 0.01), contours_spacing))
74277444

74287445
if self.minima.shape[0] == 1:
7429-
background = cmap((float(self.minima.iloc[1])-vmin)/(vmax-vmin))
7446+
background = cmap((float(self.minima.iloc[0,1])-vmin)/(vmax-vmin))
74307447
luma = background[0]*0.2126+background[1]*0.7152+background[3]*0.0722
74317448
if luma &gt; 0.6 and not color_set:
74327449
color = &#34;black&#34;
@@ -7544,9 +7561,7 @@ <h4><code><a title="metadynminer.Minima" href="#metadynminer.Minima">Minima</a><
75447561
</nav>
75457562
</main>
75467563
<footer id="footer">
7547-
<p>Generated by <a href="https://pdoc3.github.io/pdoc"><cite>pdoc</cite> 0.8.1</a>.</p>
7564+
<p>Generated by <a href="https://pdoc3.github.io/pdoc" title="pdoc: Python API documentation generator"><cite>pdoc</cite> 0.10.0</a>.</p>
75487565
</footer>
7549-
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
7550-
<script>hljs.initHighlightingOnLoad()</script>
75517566
</body>
75527567
</html>

metadynminer/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"""
5757

5858
name = "metadynminer"
59-
__version__ = "0.4.2"
59+
__version__ = "0.5.0"
6060
__author__ = 'Jan Beránek'
6161

6262
__pdoc__ = {}
@@ -2686,7 +2686,7 @@ def makefeprofile(self, hills):
26862686
else:
26872687
print("Fes object doesn't have supported number of CVs.")
26882688

2689-
def plot(self, png_name=None, image_size=[10,7], xlabel=None, ylabel=None, label_size=12, cmap="jet"):
2689+
def plot(self, png_name=None, image_size=[10,7], xlabel=None, ylabel=None, label_size=12, cmap="jet", legend=True):
26902690
"""
26912691
Visualization function for free energy profiles.
26922692
@@ -2709,6 +2709,8 @@ def plot(self, png_name=None, image_size=[10,7], xlabel=None, ylabel=None, label
27092709
* label_size (default=12) = size of labels
27102710
27112711
* cmap (default="jet") = matplotlib colormap used for coloring the line of the minima
2712+
2713+
* legend (default=True) = whether there should be a matplotlib's legend in the graph
27122714
"""
27132715

27142716
plt.figure(figsize=(image_size[0],image_size[1]))
@@ -2729,5 +2731,7 @@ def plot(self, png_name=None, image_size=[10,7], xlabel=None, ylabel=None, label
27292731
plt.ylabel('free energy difference (kJ/mol)', size=label_size)
27302732
else:
27312733
plt.ylabel(ylabel, size=label_size)
2734+
if legend:
2735+
plt.legend(self.minima.iloc[:,0], loc="lower right")
27322736
if png_name != None:
27332737
plt.savefig(png_name)

0 commit comments

Comments
 (0)