Skip to content

Commit

Permalink
Import plot module in not refactored plotting scripts
Browse files Browse the repository at this point in the history
All plotting scripts that have not been refactored, yet, need to import
the plotting module `mdtools.plot` now, because it is not loaded
together with mdtools anymore.

The plotting scripts that have not been refactored, yet, are:

  * All `scripts/dynamics/plot_renewal_envents_*.py` scripts.

  * `scripts/structure/plot_topological_map.py`.
  • Loading branch information
andthum committed Sep 3, 2021
1 parent 412d5e5 commit a4089ce
Show file tree
Hide file tree
Showing 17 changed files with 800 additions and 565 deletions.
38 changes: 23 additions & 15 deletions scripts/dynamics/plot_renewal_events_displ_hist.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env python3


# This file is part of MDTools.
# Copyright (C) 2020 Andreas Thum
# Copyright (C) 2021 The MDTools Development Team and all contributors
# listed in the file AUTHORS.rst
#
# MDTools is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
Expand All @@ -18,6 +18,9 @@
# along with MDTools. If not, see <http://www.gnu.org/licenses/>.


__author__ = "Andreas Thum"


import sys
import os
from datetime import datetime
Expand All @@ -28,6 +31,8 @@
import matplotlib.pyplot as plt
from matplotlib.backends.backend_pdf import PdfPages
import mdtools as mdt
import mdtools.plot as mdtplt # TODO: Replace deprecated functions
plt.style.use("default") # TODO: Use MDTools plotting style


if __name__ == '__main__':
Expand Down Expand Up @@ -227,18 +232,20 @@
frameon=False,
clear=True,
tight_layout=True)
mdt.plot.hist(ax=axis,
x=data,
xmin=args.XMIN,
xmax=args.XMAX,
ymin=args.YMIN,
ymax=args.YMAX,
xlabel=r'$' + xlabel[i] + r'$ / ' + args.LUNIT,
ylabel=r'$p(' + xlabel[i] + r')$',
bins=bins[i],
range=(args.START, args.STOP),
density=True)
mdt.plot.plot(
mdtplt.hist(
ax=axis,
x=data,
xmin=args.XMIN,
xmax=args.XMAX,
ymin=args.YMIN,
ymax=args.YMAX,
xlabel=r'$' + xlabel[i] + r'$ / ' + args.LUNIT,
ylabel=r'$p(' + xlabel[i] + r')$',
bins=bins[i],
range=(args.START, args.STOP),
density=True,
)
mdtplt.plot(
ax=axis,
x=x[i],
y=mdt.stats.gaussian(x=x[i],
Expand All @@ -251,7 +258,8 @@
xlabel=r'$' + xlabel[i] + r'$ / ' + args.LUNIT,
ylabel=r'$p(' + xlabel[i] + r')$',
label="Fit",
color='black')
color='black',
)
plt.tight_layout()
pdf.savefig()
plt.close()
Expand Down
71 changes: 42 additions & 29 deletions scripts/dynamics/plot_renewal_events_displ_vs_post0.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/env python3


# This file is part of MDTools.
# Copyright (C) 2020 Andreas Thum
# Copyright (C) 2021 The MDTools Development Team and all contributors
# listed in the file AUTHORS.rst
#
# MDTools is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
Expand All @@ -18,6 +18,9 @@
# along with MDTools. If not, see <http://www.gnu.org/licenses/>.


__author__ = "Andreas Thum"


import sys
import os
from datetime import datetime
Expand All @@ -27,6 +30,8 @@
import matplotlib.pyplot as plt
from matplotlib.backends.backend_pdf import PdfPages
import mdtools as mdt
import mdtools.plot as mdtplt # TODO: Replace deprecated functions
plt.style.use("default") # TODO: Use MDTools plotting style


if __name__ == '__main__':
Expand Down Expand Up @@ -319,7 +324,7 @@
axis = axes[1]

axis.axhline(y=0, color='black')
img = mdt.plot.scatter(
img = mdtplt.scatter(
ax=axis,
x=pos_t0,
y=displ.T[i],
Expand All @@ -331,7 +336,8 @@
xlabel=r'${}(t_0)$ / {}'.format(args.DIRECTION, args.LUNIT),
ylabel=r'$\Delta ' + ylabel[i] + r'(\tau_{renew})$ / ' + args.LUNIT,
marker='x',
cmap='plasma')
cmap='plasma',
)
cbar = plt.colorbar(img, ax=axis)
cbar.set_label(label=r'$\tau_{renew}$ / ' + args.TUNIT,
fontsize=fontsize_labels)
Expand All @@ -346,18 +352,20 @@
length=0.5 * tick_length,
labelsize=0.8 * fontsize_ticks)

mdt.plot.vlines(ax=axis,
x=bins,
start=axis.get_ylim()[0],
stop=axis.get_ylim()[1],
xmin=args.XMIN,
xmax=args.XMAX,
ymin=args.YMIN,
ymax=args.YMAX,
color='black',
linestyle='dotted')

mdt.plot.plot(
mdtplt.vlines(
ax=axis,
x=bins,
start=axis.get_ylim()[0],
stop=axis.get_ylim()[1],
xmin=args.XMIN,
xmax=args.XMAX,
ymin=args.YMIN,
ymax=args.YMAX,
color='black',
linestyle='dotted',
)

mdtplt.plot(
ax=axis,
x=bins[1:] - np.diff(bins) / 2,
y=displ_means.T[i][1:],
Expand All @@ -369,9 +377,10 @@
ylabel=r'$\Delta ' + ylabel[i] + r'(\tau_{renew})$ / ' + args.LUNIT,
label=r'$\langle \Delta ' + ylabel[i] + r' \rangle$',
color='red',
marker='o')
marker='o',
)

mdt.plot.plot(
mdtplt.plot(
ax=axis,
x=bins[1:] - np.diff(bins) / 2,
y=msd_means.T[i][1:],
Expand All @@ -383,9 +392,10 @@
ylabel=r'$\Delta ' + ylabel[i] + r'(\tau_{renew})$ / ' + args.LUNIT,
label=r'$\langle \Delta ' + ylabel[i] + r'^2 \rangle$',
color='blue',
marker='^')
marker='^',
)

mdt.plot.plot(
mdtplt.plot(
ax=axis,
x=bins[1:] - np.diff(bins) / 2,
y=displ_vars.T[i][1:],
Expand All @@ -397,22 +407,25 @@
ylabel=r'$\Delta ' + ylabel[i] + r'(\tau_{renew})$ / ' + args.LUNIT,
label=r'$\langle \Delta ' + ylabel[i] + r'^2 \rangle - \langle \Delta ' + ylabel[i] + r' \rangle ^2$',
color='green',
marker='s')
marker='s',
)

axis.legend(loc='lower left',
numpoints=1,
frameon=True,
fontsize=fontsize_legend)

if args.INFILE2 is not None:
mdt.plot.plot(ax=axes[0],
x=data[:, 0],
y=data[:, 1],
xmin=args.XMIN,
xmax=args.XMAX,
ymin=np.min(data[:, 1]),
ymax=np.max(data[:, 1]),
color='black')
mdtplt.plot(
ax=axes[0],
x=data[:, 0],
y=data[:, 1],
xmin=args.XMIN,
xmax=args.XMAX,
ymin=np.min(data[:, 1]),
ymax=np.max(data[:, 1]),
color='black',
)
axes[0].xaxis.set_visible(False)
axes[0].yaxis.set_visible(False)
axes[0].spines['bottom'].set_visible(False)
Expand Down

0 comments on commit a4089ce

Please sign in to comment.