Skip to content

Commit

Permalink
qr plot custom titles
Browse files Browse the repository at this point in the history
  • Loading branch information
pablogila committed Feb 6, 2025
1 parent 22fbff4 commit 5c7c642
Show file tree
Hide file tree
Showing 37 changed files with 416 additions and 419 deletions.
2 changes: 1 addition & 1 deletion aton/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
"""

__version__ = 'v0.0.22'
__version__ = 'v0.0.23'

19 changes: 9 additions & 10 deletions aton/qrotor/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@
def potential(system, title:str=None) -> None:
"""Plot the potential values of a `system` (System object, or list of systems)."""
system = systems.as_list(system)
title_str = title if title is not None else 'Rotational potential energy'
if not title and system[0].comment and not system[-1].comment:
title_str = system[0].comment
title_str = title if title else (system[0].comment if (system[0].comment and (len(system) == 1 or not system[-1].comment)) else 'Rotational potential energy')

plt.figure()
plt.title(title_str)
Expand All @@ -41,13 +39,13 @@ def potential(system, title:str=None) -> None:
for i in system:
plt.plot(i.grid, i.potential_values, marker='', linestyle='-', label=i.comment)

if all(s.comment for s in system):
if all(s.comment for s in system) and len(system) != 1:
plt.legend()

plt.show()


def energies(data) -> None:
def energies(data, title:str=None) -> None:
"""Plot the eigenvalues of `data` (System or a list of System objects)."""
if isinstance(data, System):
var = [data]
Expand All @@ -61,7 +59,7 @@ def energies(data) -> None:
edgecolors = ['tomato', 'purple', 'grey']

V_linestyle = '-'
title = var[0].comment if var[0].comment else 'Energy eigenvalues'
title = title if title else (var[0].comment if var[0].comment else 'Energy eigenvalues')
ylabel_text = f'Energy / meV'
xlabel_text = 'Angle / radians'

Expand Down Expand Up @@ -102,12 +100,13 @@ def energies(data) -> None:
plt.show()


def reduced_energies(data:list) -> None:
def reduced_energies(data:list, title:str=None) -> None:
"""Plots the reduced energy of the system E/B vs the reduced potential energy V/B.
Takes a `data` list of System objects as input.
"""
systems.as_list(data)
title = title if title else (data[0].comment if data[0].comment else 'Reduced energies')
number_of_levels = data[0].E_levels
x = []
for system in data:
Expand All @@ -119,11 +118,11 @@ def reduced_energies(data:list) -> None:
plt.plot(x, y, marker='', linestyle='-')
plt.xlabel('V$_{B}$ / B')
plt.ylabel('E / B')
plt.title(data[0].comment)
plt.title(title)
plt.show()


def wavefunction(system:System, square:bool=True, levels=[0, 1, 2], overlap=False):
def wavefunction(system:System, square:bool=True, levels=[0, 1, 2], overlap=False, title:str=None):
"""Plot the wavefunction of a `system` for the specified `levels`.
Wavefunctions are squared by default, showing the probabilities;
Expand All @@ -141,7 +140,7 @@ def wavefunction(system:System, square:bool=True, levels=[0, 1, 2], overlap=Fals
data = deepcopy(system)
eigenvectors = data.eigenvectors

title = data.comment
title = title if title else (data.comment if data.comment else 'System wavefunction')
fig, ax1 = plt.subplots()
plt.title(title)
ax1.set_xlabel('Angle / radians')
Expand Down
2 changes: 1 addition & 1 deletion docs/aton.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ <h2>Submodules</h2>
</ul>


<footer>ATON v0.0.22 documentation</footer>
<footer>ATON v0.0.23 documentation</footer>

<a class="attribution" title="pdoc: Python API documentation generator" href="https://pdoc.dev" target="_blank">
built with <span class="visually-hidden">pdoc</span><img
Expand Down
4 changes: 2 additions & 2 deletions docs/aton/_version.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ <h2>API Documentation</h2>
</ul>


<footer>ATON v0.0.22 documentation</footer>
<footer>ATON v0.0.23 documentation</footer>

<a class="attribution" title="pdoc: Python API documentation generator" href="https://pdoc.dev" target="_blank">
built with <span class="visually-hidden">pdoc</span><img
Expand Down Expand Up @@ -116,7 +116,7 @@ <h1 class="modulename">
</span><span id="L-10"><a href="#L-10"><span class="linenos">10</span></a>
</span><span id="L-11"><a href="#L-11"><span class="linenos">11</span></a><span class="sd">&quot;&quot;&quot;</span>
</span><span id="L-12"><a href="#L-12"><span class="linenos">12</span></a>
</span><span id="L-13"><a href="#L-13"><span class="linenos">13</span></a><span class="n">__version__</span> <span class="o">=</span> <span class="s1">&#39;v0.0.22&#39;</span>
</span><span id="L-13"><a href="#L-13"><span class="linenos">13</span></a><span class="n">__version__</span> <span class="o">=</span> <span class="s1">&#39;v0.0.23&#39;</span>
</span></pre></div>


Expand Down
2 changes: 1 addition & 1 deletion docs/aton/interface.html
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ <h2>Submodules</h2>
</ul>


<footer>ATON v0.0.22 documentation</footer>
<footer>ATON v0.0.23 documentation</footer>

<a class="attribution" title="pdoc: Python API documentation generator" href="https://pdoc.dev" target="_blank">
built with <span class="visually-hidden">pdoc</span><img
Expand Down
2 changes: 1 addition & 1 deletion docs/aton/interface/castep.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ <h2>API Documentation</h2>
</ul>


<footer>ATON v0.0.22 documentation</footer>
<footer>ATON v0.0.23 documentation</footer>

<a class="attribution" title="pdoc: Python API documentation generator" href="https://pdoc.dev" target="_blank">
built with <span class="visually-hidden">pdoc</span><img
Expand Down
2 changes: 1 addition & 1 deletion docs/aton/interface/phonopy.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ <h2>API Documentation</h2>
</ul>


<footer>ATON v0.0.22 documentation</footer>
<footer>ATON v0.0.23 documentation</footer>

<a class="attribution" title="pdoc: Python API documentation generator" href="https://pdoc.dev" target="_blank">
built with <span class="visually-hidden">pdoc</span><img
Expand Down
2 changes: 1 addition & 1 deletion docs/aton/interface/qe.html
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ <h2>API Documentation</h2>
</ul>


<footer>ATON v0.0.22 documentation</footer>
<footer>ATON v0.0.23 documentation</footer>

<a class="attribution" title="pdoc: Python API documentation generator" href="https://pdoc.dev" target="_blank">
built with <span class="visually-hidden">pdoc</span><img
Expand Down
2 changes: 1 addition & 1 deletion docs/aton/interface/slurm.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ <h2>API Documentation</h2>
</ul>


<footer>ATON v0.0.22 documentation</footer>
<footer>ATON v0.0.23 documentation</footer>

<a class="attribution" title="pdoc: Python API documentation generator" href="https://pdoc.dev" target="_blank">
built with <span class="visually-hidden">pdoc</span><img
Expand Down
2 changes: 1 addition & 1 deletion docs/aton/phys.html
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ <h2>Submodules</h2>
</ul>


<footer>ATON v0.0.22 documentation</footer>
<footer>ATON v0.0.23 documentation</footer>

<a class="attribution" title="pdoc: Python API documentation generator" href="https://pdoc.dev" target="_blank">
built with <span class="visually-hidden">pdoc</span><img
Expand Down
2 changes: 1 addition & 1 deletion docs/aton/phys/atoms.html
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ <h2>API Documentation</h2>
</ul>


<footer>ATON v0.0.22 documentation</footer>
<footer>ATON v0.0.23 documentation</footer>

<a class="attribution" title="pdoc: Python API documentation generator" href="https://pdoc.dev" target="_blank">
built with <span class="visually-hidden">pdoc</span><img
Expand Down
2 changes: 1 addition & 1 deletion docs/aton/phys/functions.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ <h2>API Documentation</h2>
</ul>


<footer>ATON v0.0.22 documentation</footer>
<footer>ATON v0.0.23 documentation</footer>

<a class="attribution" title="pdoc: Python API documentation generator" href="https://pdoc.dev" target="_blank">
built with <span class="visually-hidden">pdoc</span><img
Expand Down
2 changes: 1 addition & 1 deletion docs/aton/phys/units.html
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ <h2>API Documentation</h2>
</ul>


<footer>ATON v0.0.22 documentation</footer>
<footer>ATON v0.0.23 documentation</footer>

<a class="attribution" title="pdoc: Python API documentation generator" href="https://pdoc.dev" target="_blank">
built with <span class="visually-hidden">pdoc</span><img
Expand Down
2 changes: 1 addition & 1 deletion docs/aton/qrotor.html
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ <h2>Submodules</h2>
</ul>


<footer>ATON v0.0.22 documentation</footer>
<footer>ATON v0.0.23 documentation</footer>

<a class="attribution" title="pdoc: Python API documentation generator" href="https://pdoc.dev" target="_blank">
built with <span class="visually-hidden">pdoc</span><img
Expand Down
2 changes: 1 addition & 1 deletion docs/aton/qrotor/constants.html
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ <h2>API Documentation</h2>
</ul>


<footer>ATON v0.0.22 documentation</footer>
<footer>ATON v0.0.23 documentation</footer>

<a class="attribution" title="pdoc: Python API documentation generator" href="https://pdoc.dev" target="_blank">
built with <span class="visually-hidden">pdoc</span><img
Expand Down
Loading

0 comments on commit 5c7c642

Please sign in to comment.