diff --git a/scripts/dynamics/plot_renewal_events_displ_hist.py b/scripts/dynamics/plot_renewal_events_displ_hist.py index e15bf975..bfea78ce 100644 --- a/scripts/dynamics/plot_renewal_events_displ_hist.py +++ b/scripts/dynamics/plot_renewal_events_displ_hist.py @@ -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 @@ -18,6 +18,9 @@ # along with MDTools. If not, see . +__author__ = "Andreas Thum" + + import sys import os from datetime import datetime @@ -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__': @@ -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], @@ -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() diff --git a/scripts/dynamics/plot_renewal_events_displ_vs_post0.py b/scripts/dynamics/plot_renewal_events_displ_vs_post0.py index 51cdec5a..c1a3ee78 100644 --- a/scripts/dynamics/plot_renewal_events_displ_vs_post0.py +++ b/scripts/dynamics/plot_renewal_events_displ_vs_post0.py @@ -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 @@ -18,6 +18,9 @@ # along with MDTools. If not, see . +__author__ = "Andreas Thum" + + import sys import os from datetime import datetime @@ -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__': @@ -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], @@ -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) @@ -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:], @@ -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:], @@ -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:], @@ -397,7 +407,8 @@ 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, @@ -405,14 +416,16 @@ 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) diff --git a/scripts/dynamics/plot_renewal_events_displ_vs_trenew_binned.py b/scripts/dynamics/plot_renewal_events_displ_vs_trenew_binned.py index cd51c56e..59b30281 100644 --- a/scripts/dynamics/plot_renewal_events_displ_vs_trenew_binned.py +++ b/scripts/dynamics/plot_renewal_events_displ_vs_trenew_binned.py @@ -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 @@ -18,6 +18,9 @@ # along with MDTools. If not, see . +__author__ = "Andreas Thum" + + import sys import os from datetime import datetime @@ -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__': @@ -380,23 +385,27 @@ frameon=False, clear=True, tight_layout=True) - mdt.plot.plot(ax=axis, - x=t, - y=nevents[1:], - xmin=args.XMIN, - xmax=args.XMAX, - xlabel=r'$\tau_{renew}$ / ' + args.TUNIT, - ylabel=r'$N_{renew}$', - color='black', - marker='o') - mdt.plot.vlines(ax=axis, - x=tbins, - start=axis.get_ylim()[0], - stop=axis.get_ylim()[1], - xmin=args.XMIN, - xmax=args.XMAX, - color='black', - linestyle='dotted') + mdtplt.plot( + ax=axis, + x=t, + y=nevents[1:], + xmin=args.XMIN, + xmax=args.XMAX, + xlabel=r'$\tau_{renew}$ / ' + args.TUNIT, + ylabel=r'$N_{renew}$', + color='black', + marker='o', + ) + mdtplt.vlines( + ax=axis, + x=tbins, + start=axis.get_ylim()[0], + stop=axis.get_ylim()[1], + xmin=args.XMIN, + xmax=args.XMAX, + color='black', + linestyle='dotted', + ) plt.tight_layout() pdf.savefig() plt.close() @@ -410,7 +419,7 @@ tight_layout=True) axis.axhline(y=0, color='black') if args.DCOLOR is None: - mdt.plot.scatter( + mdtplt.scatter( ax=axis, x=trenew, y=displ.T[i], @@ -420,9 +429,10 @@ ymax=args.YMAX, xlabel=r'$\tau_{renew}$ / ' + args.TUNIT, ylabel=r'$\Delta ' + ylabel[i] + r'(\tau_{renew})$ / ' + args.LUNIT, - marker='x') + marker='x', + ) else: - img = mdt.plot.scatter( + img = mdtplt.scatter( ax=axis, x=trenew, y=displ.T[i], @@ -434,7 +444,8 @@ xlabel=r'$\tau_{renew}$ / ' + args.TUNIT, 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'${}(t_0)$ / {}'.format(args.DCOLOR, args.LUNIT), fontsize=fontsize_labels) @@ -448,17 +459,19 @@ direction='out', length=0.5 * tick_length, labelsize=0.8 * fontsize_ticks) - mdt.plot.vlines(ax=axis, - x=tbins, - 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=tbins, + 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=t, y=displ_mean.T[i][1:], @@ -470,8 +483,9 @@ ylabel=r'$\Delta ' + ylabel[i] + r'(\tau_{renew})$ / ' + args.LUNIT, label=r'$\langle \Delta ' + ylabel[i] + r' \rangle$', color='red', - marker='o') - mdt.plot.plot( + marker='o', + ) + mdtplt.plot( ax=axis, x=t, y=np.sqrt(msd_mean.T[i][1:]), @@ -483,8 +497,9 @@ ylabel=r'$\Delta ' + ylabel[i] + r'(\tau_{renew})$ / ' + args.LUNIT, label=r'$\sqrt{\langle \Delta ' + ylabel[i] + r'^2 \rangle}$', color='blue', - marker='^') - mdt.plot.plot( + marker='^', + ) + mdtplt.plot( ax=axis, x=t, y=displ_std.T[i][1:], @@ -496,7 +511,8 @@ ylabel=r'$\Delta ' + ylabel[i] + r'(\tau_{renew})$ / ' + args.LUNIT, label=r'$\sqrt{\langle \Delta ' + ylabel[i] + r'^2 \rangle - \langle \Delta ' + ylabel[i] + r' \rangle ^2}$', color='green', - marker='s') + marker='s', + ) axis.legend(loc='upper center', bbox_to_anchor=(0.5, 1.32), ncol=2, @@ -626,7 +642,7 @@ tight_layout=True) axis.axhline(y=0, color='black') if args.DCOLOR is None: - img = mdt.plot.scatter( + img = mdtplt.scatter( ax=axis, x=trenew, y=displ.T[i], @@ -636,9 +652,10 @@ ymax=args.YMAX, xlabel=r'$\tau_{renew}$ / ' + args.TUNIT, ylabel=r'$\Delta ' + ylabel[i] + r'(\tau_{renew})$ / ' + args.LUNIT, - marker='x') + marker='x', + ) else: - img = mdt.plot.scatter( + img = mdtplt.scatter( ax=axis, x=trenew, y=displ.T[i], @@ -650,7 +667,8 @@ xlabel=r'$\tau_{renew}$ / ' + args.TUNIT, 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'${}(t_0)$ / {}'.format(args.DCOLOR, args.LUNIT), fontsize=fontsize_labels) @@ -664,17 +682,19 @@ direction='out', length=0.5 * tick_length, labelsize=0.8 * fontsize_ticks) - mdt.plot.vlines(ax=axis, - x=tbins, - 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=tbins, + 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=t, y=popt_displ.T[0][i][1:], @@ -686,8 +706,9 @@ ylabel=r'$\Delta ' + ylabel[i] + r'(\tau_{renew})$ / ' + args.LUNIT, label=r'$\mu$', color='red', - marker='o') - mdt.plot.plot( + marker='o', + ) + mdtplt.plot( ax=axis, x=t, y=popt_displ.T[1][i][1:], @@ -699,8 +720,9 @@ ylabel=r'$\Delta ' + ylabel[i] + r'(\tau_{renew})$ / ' + args.LUNIT, label=r'$\sigma$', color='blue', - marker='^') - mdt.plot.plot( + marker='^', + ) + mdtplt.plot( ax=axis, x=t, y=non_gaus.T[i][1:], @@ -712,7 +734,8 @@ ylabel=r'$\Delta ' + ylabel[i] + r'(\tau_{renew})$ / ' + args.LUNIT, label=r'$A$', color='green', - marker='s') + marker='s', + ) plt.tight_layout() pdf.savefig() plt.close() diff --git a/scripts/dynamics/plot_renewal_events_displa_vs_displb.py b/scripts/dynamics/plot_renewal_events_displa_vs_displb.py index cf1dfdb0..544ddf48 100644 --- a/scripts/dynamics/plot_renewal_events_displa_vs_displb.py +++ b/scripts/dynamics/plot_renewal_events_displa_vs_displb.py @@ -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 @@ -18,6 +18,9 @@ # along with MDTools. If not, see . +__author__ = "Andreas Thum" + + import sys import os from datetime import datetime @@ -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__': @@ -277,7 +282,7 @@ axis.axhline(y=0, color='black') axis.axvline(x=0, color='black') - img = mdt.plot.scatter( + img = mdtplt.scatter( ax=axis, x=displ1, y=displ2, @@ -289,7 +294,8 @@ xlabel=r'$\Delta ' + args.DIRECTION1 + r'(\tau_{renew})$ / ' + args.LUNIT, ylabel=r'$\Delta ' + args.DIRECTION2 + 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) @@ -305,7 +311,7 @@ labelsize=0.8 * fontsize_ticks) diagonal = np.linspace(*axis.get_xlim()) - mdt.plot.plot( + mdtplt.plot( ax=axis, x=diagonal, y=diagonal, @@ -317,7 +323,8 @@ ylabel=r'$\Delta ' + args.DIRECTION2 + r'(\tau_{renew})$ / ' + args.LUNIT, label="Diagonal", color='black', - linestyle='--') + linestyle='--', + ) axis.axvline(x=np.mean(displ1), color='red', diff --git a/scripts/dynamics/plot_renewal_events_msd_vs_post0.py b/scripts/dynamics/plot_renewal_events_msd_vs_post0.py index 37c7fa13..1d4f86cb 100644 --- a/scripts/dynamics/plot_renewal_events_msd_vs_post0.py +++ b/scripts/dynamics/plot_renewal_events_msd_vs_post0.py @@ -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 @@ -18,6 +18,9 @@ # along with MDTools. If not, see . +__author__ = "Andreas Thum" + + import sys import os from datetime import datetime @@ -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__': @@ -333,7 +338,7 @@ mask = (msd_tot > 0) else: mask = slice(0, len(msd_tot)) - img = mdt.plot.scatter( + img = mdtplt.scatter( ax=axis, x=pos_t0[mask], y=msd_tot[mask], @@ -346,7 +351,8 @@ xlabel=r'${}(t_0)$ / {}'.format(args.DIRECTION, args.LUNIT), ylabel=r'$\Delta r^2(\tau_{renew})$ / ' + args.LUNIT + r'$^2$', marker='x', - cmap='plasma') + cmap='plasma', + ) cbar = plt.colorbar(img, ax=axis) cbar.set_label(label=r'$\tau_{renew}$ / ' + args.TUNIT, fontsize=fontsize_labels) @@ -361,22 +367,24 @@ 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=ymin[l], - ymax=args.YMAX, - color='black', - linestyle='dotted') + mdtplt.vlines( + ax=axis, + x=bins, + start=axis.get_ylim()[0], + stop=axis.get_ylim()[1], + xmin=args.XMIN, + xmax=args.XMAX, + ymin=ymin[l], + ymax=args.YMAX, + color='black', + linestyle='dotted', + ) if logy[l]: mask = (msd_tot_mean[1:] > 0) else: mask = slice(0, len(msd_tot_mean)) - mdt.plot.errorbar( + mdtplt.errorbar( ax=axis, x=(bins[1:] - np.diff(bins) / 2)[mask], y=msd_tot_mean[1:][mask], @@ -389,17 +397,20 @@ xlabel=r'${}(t_0)$ / {}'.format(args.DIRECTION, args.LUNIT), ylabel=r'$\Delta r^2(\tau_{renew})$ / ' + args.LUNIT + r'$^2$', color='red', - marker='o') + marker='o', + ) 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) @@ -435,7 +446,7 @@ mask = (msd.T[i] > 0) else: mask = slice(0, len(msd.T[i])) - img = mdt.plot.scatter( + img = mdtplt.scatter( ax=axis, x=pos_t0[mask], y=msd.T[i][mask], @@ -448,7 +459,8 @@ xlabel=r'${}(t_0)$ / {}'.format(args.DIRECTION, args.LUNIT), ylabel=ylabel[i] + args.LUNIT + r'$^2$', marker='x', - cmap='plasma') + cmap='plasma', + ) cbar = plt.colorbar(img, ax=axis) cbar.set_label(label=r'$\tau_{renew}$ / ' + args.TUNIT, fontsize=fontsize_labels) @@ -463,22 +475,24 @@ 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=ymin[l], - ymax=args.YMAX, - color='black', - linestyle='dotted') + mdtplt.vlines( + ax=axis, + x=bins, + start=axis.get_ylim()[0], + stop=axis.get_ylim()[1], + xmin=args.XMIN, + xmax=args.XMAX, + ymin=ymin[l], + ymax=args.YMAX, + color='black', + linestyle='dotted', + ) if logy[l]: mask = (msd_mean.T[i][1:] > 0) else: mask = slice(0, len(msd_mean.T[i])) - mdt.plot.errorbar( + mdtplt.errorbar( ax=axis, x=(bins[1:] - np.diff(bins) / 2)[mask], y=msd_mean.T[i][1:][mask], @@ -491,17 +505,20 @@ xlabel=r'${}(t_0)$ / {}'.format(args.DIRECTION, args.LUNIT), ylabel=ylabel[i] + args.LUNIT + r'$^2$', color='red', - marker='o') + marker='o', + ) 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) diff --git a/scripts/dynamics/plot_renewal_events_msd_vs_trenew.py b/scripts/dynamics/plot_renewal_events_msd_vs_trenew.py index bcbb82a1..d4fb256e 100644 --- a/scripts/dynamics/plot_renewal_events_msd_vs_trenew.py +++ b/scripts/dynamics/plot_renewal_events_msd_vs_trenew.py @@ -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 @@ -18,6 +18,9 @@ # along with MDTools. If not, see . +__author__ = "Andreas Thum" + + import sys import os from datetime import datetime @@ -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__': @@ -239,7 +244,7 @@ displ0[-1] = np.count_nonzero(msd_tot == 0) mask = (msd_tot > 0) if args.DCOLOR is None: - mdt.plot.scatter( + mdtplt.scatter( ax=axis, x=trenew[mask], y=msd_tot[mask], @@ -251,9 +256,10 @@ logy=True, xlabel=r'$\tau_{renew}$ / ' + args.TUNIT, ylabel=r'$\Delta r^2(\tau_{renew})$ / ' + args.LUNIT + r'$^2$', - marker='x') + marker='x', + ) else: - img = mdt.plot.scatter( + img = mdtplt.scatter( ax=axis, x=trenew[mask], y=msd_tot[mask], @@ -267,7 +273,8 @@ xlabel=r'$\tau_{renew}$ / ' + args.TUNIT, ylabel=r'$\Delta r^2(\tau_{renew})$ / ' + args.LUNIT + r'$^2$', marker='x', - cmap='plasma') + cmap='plasma', + ) cbar = plt.colorbar(img, ax=axis) cbar.set_label(label=r'${}(t_0)$ / {}'.format(args.DCOLOR, args.LUNIT), fontsize=fontsize_labels) @@ -282,7 +289,7 @@ length=0.5 * tick_length, labelsize=0.8 * fontsize_ticks) mask = (running_average_tot > 0) - mdt.plot.plot( + mdtplt.plot( ax=axis, x=trenew[mask][sort_ix[mask]], y=running_average_tot[mask], @@ -295,10 +302,11 @@ xlabel=r'$\tau_{renew}$ / ' + args.TUNIT, ylabel=r'$\Delta r^2(\tau_{renew})$ / ' + args.LUNIT + r'$^2$', label="Running average", - color='red') + color='red', + ) fit = mdt.dyn.msd(t=trenew, D=popt[-1], d=3) mask = (fit > 0) - mdt.plot.plot( + mdtplt.plot( ax=axis, x=trenew[mask], y=fit[mask], @@ -311,7 +319,8 @@ xlabel=r'$\tau_{renew}$ / ' + args.TUNIT, ylabel=r'$\Delta r^2(\tau_{renew})$ / ' + args.LUNIT + r'$^2$', label="Fit", - color='black') + color='black', + ) plt.tight_layout() pdf.savefig() plt.close() @@ -325,7 +334,7 @@ displ0[i] = np.count_nonzero(data == 0) mask = (data > 0) if args.DCOLOR is None: - mdt.plot.scatter( + mdtplt.scatter( ax=axis, x=trenew[mask], y=data[mask], @@ -337,9 +346,10 @@ logy=True, xlabel=r'$\tau_{renew}$ / ' + args.TUNIT, ylabel=r'$\Delta ' + ylabel[i] + r'^2(\tau_{renew})$ / ' + args.LUNIT + r'$^2$', - marker='x') + marker='x', + ) else: - img = mdt.plot.scatter( + img = mdtplt.scatter( ax=axis, x=trenew[mask], y=data[mask], @@ -353,7 +363,8 @@ xlabel=r'$\tau_{renew}$ / ' + args.TUNIT, ylabel=r'$\Delta ' + ylabel[i] + r'^2(\tau_{renew})$ / ' + args.LUNIT + r'$^2$', marker='x', - cmap='plasma') + cmap='plasma', + ) cbar = plt.colorbar(img, ax=axis) cbar.set_label(label=r'${}(t_0)$ / {}'.format(args.DCOLOR, args.LUNIT), fontsize=fontsize_labels) @@ -368,7 +379,7 @@ length=0.5 * tick_length, labelsize=0.8 * fontsize_ticks) mask = (running_average.T[i] > 0) - mdt.plot.plot( + mdtplt.plot( ax=axis, x=trenew[mask][sort_ix[mask]], y=running_average.T[i][mask], @@ -381,10 +392,11 @@ xlabel=r'$\tau_{renew}$ / ' + args.TUNIT, ylabel=r'$\Delta ' + ylabel[i] + r'^2(\tau_{renew})$ / ' + args.LUNIT + r'$^2$', label="Running average", - color='red') + color='red', + ) fit = mdt.dyn.msd(t=trenew, D=popt[i], d=1) mask = (fit > 0) - mdt.plot.plot( + mdtplt.plot( ax=axis, x=trenew[mask], y=fit[mask], @@ -397,7 +409,8 @@ xlabel=r'$\tau_{renew}$ / ' + args.TUNIT, ylabel=r'$\Delta ' + ylabel[i] + r'^2(\tau_{renew})$ / ' + args.LUNIT + r'$^2$', label="Fit", - color='black') + color='black', + ) plt.tight_layout() pdf.savefig() plt.close() diff --git a/scripts/dynamics/plot_renewal_events_msd_vs_trenew_binned.py b/scripts/dynamics/plot_renewal_events_msd_vs_trenew_binned.py index 186b0016..8f97ab59 100644 --- a/scripts/dynamics/plot_renewal_events_msd_vs_trenew_binned.py +++ b/scripts/dynamics/plot_renewal_events_msd_vs_trenew_binned.py @@ -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 @@ -18,6 +18,9 @@ # along with MDTools. If not, see . +__author__ = "Andreas Thum" + + import sys import os from datetime import datetime @@ -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__': @@ -338,23 +343,27 @@ frameon=False, clear=True, tight_layout=True) - mdt.plot.plot(ax=axis, - x=tbins[1:] - np.diff(tbins) / 2, - y=nevents[1:], - xmin=0, - xmax=args.XMAX, - xlabel=r'$\tau_{renew}$ / ' + args.TUNIT, - ylabel=r'$N_{renew}$', - color='black', - marker='o') - mdt.plot.vlines(ax=axis, - x=tbins, - start=axis.get_ylim()[0], - stop=axis.get_ylim()[1], - xmin=args.XMIN, - xmax=args.XMAX, - color='black', - linestyle='dotted') + mdtplt.plot( + ax=axis, + x=tbins[1:] - np.diff(tbins) / 2, + y=nevents[1:], + xmin=0, + xmax=args.XMAX, + xlabel=r'$\tau_{renew}$ / ' + args.TUNIT, + ylabel=r'$N_{renew}$', + color='black', + marker='o', + ) + mdtplt.vlines( + ax=axis, + x=tbins, + start=axis.get_ylim()[0], + stop=axis.get_ylim()[1], + xmin=args.XMIN, + xmax=args.XMAX, + color='black', + linestyle='dotted', + ) plt.tight_layout() pdf.savefig() plt.close() @@ -367,7 +376,7 @@ displ0[-1] = np.count_nonzero(msd_tot == 0) mask = (msd_tot > 0) if args.DCOLOR is None: - mdt.plot.scatter( + mdtplt.scatter( ax=axis, x=trenew[mask], y=msd_tot[mask], @@ -379,9 +388,10 @@ logy=True, xlabel=r'$\tau_{renew}$ / ' + args.TUNIT, ylabel=r'$\Delta r^2(\tau_{renew})$ / ' + args.LUNIT + r'$^2$', - marker='x') + marker='x', + ) else: - img = mdt.plot.scatter( + img = mdtplt.scatter( ax=axis, x=trenew[mask], y=msd_tot[mask], @@ -395,7 +405,8 @@ xlabel=r'$\tau_{renew}$ / ' + args.TUNIT, ylabel=r'$\Delta r^2(\tau_{renew})$ / ' + args.LUNIT + r'$^2$', marker='x', - cmap='plasma') + cmap='plasma', + ) cbar = plt.colorbar(img, ax=axis) cbar.set_label(label=r'${}(t_0)$ / {}'.format(args.DCOLOR, args.LUNIT), fontsize=fontsize_labels) @@ -409,18 +420,20 @@ direction='out', length=0.5 * tick_length, labelsize=0.8 * fontsize_ticks) - mdt.plot.vlines(ax=axis, - x=tbins, - 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.vlines( + ax=axis, + x=tbins, + 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', + ) mask = ~(msd_tot_mean[1:] < 0) - mdt.plot.errorbar( + mdtplt.errorbar( ax=axis, x=t[mask], y=msd_tot_mean[1:][mask], @@ -435,10 +448,11 @@ ylabel=r'$\Delta r^2(\tau_{renew})$ / ' + args.LUNIT + r'$^2$', label=r'$\langle \Delta r^2 \rangle$', color='red', - marker='o') + marker='o', + ) fit = mdt.dyn.msd(t=trenew, D=popt_msd[-1], d=3) mask = (fit > 0) - mdt.plot.plot( + mdtplt.plot( ax=axis, x=trenew[mask], y=fit[mask], @@ -451,7 +465,8 @@ xlabel=r'$\tau_{renew}$ / ' + args.TUNIT, ylabel=r'$\Delta r^2(\tau_{renew})$ / ' + args.LUNIT + r'$^2$', label="Fit", - color='black') + color='black', + ) plt.tight_layout() pdf.savefig() plt.close() @@ -465,7 +480,7 @@ displ0[i] = np.count_nonzero(data == 0) mask = (data > 0) if args.DCOLOR is None: - mdt.plot.scatter( + mdtplt.scatter( ax=axis, x=trenew[mask], y=data[mask], @@ -477,9 +492,10 @@ logy=True, xlabel=r'$\tau_{renew}$ / ' + args.TUNIT, ylabel=r'$\Delta ' + ylabel[i] + r'^2(\tau_{renew})$ / ' + args.LUNIT + r'$^2$', - marker='x') + marker='x', + ) else: - img = mdt.plot.scatter( + img = mdtplt.scatter( ax=axis, x=trenew[mask], y=data[mask], @@ -493,7 +509,8 @@ xlabel=r'$\tau_{renew}$ / ' + args.TUNIT, ylabel=r'$\Delta ' + ylabel[i] + r'^2(\tau_{renew})$ / ' + args.LUNIT + r'$^2$', marker='x', - cmap='plasma') + cmap='plasma', + ) cbar = plt.colorbar(img, ax=axis) cbar.set_label(label=r'${}(t_0)$ / {}'.format(args.DCOLOR, args.LUNIT), fontsize=fontsize_labels) @@ -507,18 +524,20 @@ direction='out', length=0.5 * tick_length, labelsize=0.8 * fontsize_ticks) - mdt.plot.vlines(ax=axis, - x=tbins, - 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.vlines( + ax=axis, + x=tbins, + 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', + ) mask = ~(msd_mean.T[i][1:] < 0) - mdt.plot.errorbar( + mdtplt.errorbar( ax=axis, x=t[mask], y=msd_mean.T[i][1:][mask], @@ -533,10 +552,11 @@ ylabel=r'$\Delta ' + ylabel[i] + r'^2(\tau_{renew})$ / ' + args.LUNIT + r'$^2$', label=r'$\langle \Delta ' + ylabel[i] + r'^2 \rangle$', color='red', - marker='o') + marker='o', + ) fit = mdt.dyn.msd(t=trenew, D=popt_msd[i], d=1) mask = (fit > 0) - mdt.plot.plot( + mdtplt.plot( ax=axis, x=trenew[mask], y=fit[mask], @@ -549,7 +569,8 @@ xlabel=r'$\tau_{renew}$ / ' + args.TUNIT, ylabel=r'$\Delta ' + ylabel[i] + r'^2(\tau_{renew})$ / ' + args.LUNIT + r'$^2$', label="Fit", - color='black') + color='black', + ) plt.tight_layout() pdf.savefig() plt.close() @@ -724,7 +745,7 @@ tight_layout=True) axis.axhline(y=0, color='black') - mdt.plot.plot( + mdtplt.plot( ax=axis, x=t, y=msd_tot_non_gaus[1:], @@ -735,23 +756,26 @@ xlabel=r'$\tau_{renew}$ / ' + args.TUNIT, ylabel=r'$A(\tau_{renew})$', label=r'$\Delta r^2$', - marker='o') - - mdt.plot.vlines(ax=axis, - x=tbins, - 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') + marker='o', + ) + + mdtplt.vlines( + ax=axis, + x=tbins, + 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', + ) label = (r'$\Delta x^2$', r'$\Delta y^2$', r'$\Delta z^2$') marker = ('^', 's', 'D') for i, data in enumerate(msd_non_gaus.T): - mdt.plot.plot( + mdtplt.plot( ax=axis, x=t, y=data[1:], @@ -762,7 +786,8 @@ xlabel=r'$\tau_{renew}$ / ' + args.TUNIT, ylabel=r'$A(\tau_{renew})$', label=label[i], - marker=marker[i]) + marker=marker[i], + ) plt.tight_layout() pdf.savefig() diff --git a/scripts/dynamics/plot_renewal_events_msda_vs_msdb.py b/scripts/dynamics/plot_renewal_events_msda_vs_msdb.py index 642fbfac..f1cdfe16 100644 --- a/scripts/dynamics/plot_renewal_events_msda_vs_msdb.py +++ b/scripts/dynamics/plot_renewal_events_msda_vs_msdb.py @@ -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 @@ -18,6 +18,9 @@ # along with MDTools. If not, see . +__author__ = "Andreas Thum" + + import sys import os from datetime import datetime @@ -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__': @@ -281,7 +286,7 @@ tight_layout=True) mask = (msd1 > 0) & (msd2 > 0) - img = mdt.plot.scatter( + img = mdtplt.scatter( ax=axis, x=msd1[mask], y=msd2[mask], @@ -295,7 +300,8 @@ xlabel=r'$\Delta ' + args.DIRECTION1 + r'^2(\tau_{renew})$ / ' + args.LUNIT + r'$^2$', ylabel=r'$\Delta ' + args.DIRECTION2 + r'^2(\tau_{renew})$ / ' + args.LUNIT + r'$^2$', marker='x', - cmap='plasma') + cmap='plasma', + ) cbar = plt.colorbar(img, ax=axis) cbar.set_label(label=r'$\tau_{renew}$ / ' + args.TUNIT, fontsize=fontsize_labels) @@ -311,7 +317,7 @@ labelsize=0.8 * fontsize_ticks) diagonal = np.linspace(*axis.get_xlim()) - mdt.plot.plot( + mdtplt.plot( ax=axis, x=diagonal, y=diagonal, @@ -324,7 +330,8 @@ xlabel=r'$\Delta ' + args.DIRECTION1 + r'^2(\tau_{renew})$ / ' + args.LUNIT + r'$^2$', ylabel=r'$\Delta ' + args.DIRECTION2 + r'^2(\tau_{renew})$ / ' + args.LUNIT + r'$^2$', color='black', - linestyle='--') + linestyle='--', + ) axis.axvline(x=np.mean(msd1), color='blue', diff --git a/scripts/dynamics/plot_renewal_events_nevents_vs_post0.py b/scripts/dynamics/plot_renewal_events_nevents_vs_post0.py index 8bc4e0af..6936647c 100644 --- a/scripts/dynamics/plot_renewal_events_nevents_vs_post0.py +++ b/scripts/dynamics/plot_renewal_events_nevents_vs_post0.py @@ -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 @@ -18,6 +18,9 @@ # along with MDTools. If not, see . +__author__ = "Andreas Thum" + + import sys import os from datetime import datetime @@ -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__': @@ -324,7 +329,7 @@ gridspec_kw={'height_ratios': [1 / 5, 1]}) axis = axes[1] - mdt.plot.errorbar( + mdtplt.errorbar( ax=axis, x=bins[1:] - np.diff(bins) / 2, y=nevents[1:], @@ -337,28 +342,33 @@ xlabel=r'${}(t_0)$ / {}'.format(args.DIRECTION, args.LUNIT), ylabel=r'$N_{renew}$', color='black', - marker='o') - - mdt.plot.vlines(ax=axis, - x=bins, - start=axis.get_ylim()[0], - stop=axis.get_ylim()[1], - xmin=args.XMIN, - xmax=args.XMAX, - ymin=ymin[i], - ymax=args.YMAX, - color='black', - linestyle='dotted') + marker='o', + ) + + mdtplt.vlines( + ax=axis, + x=bins, + start=axis.get_ylim()[0], + stop=axis.get_ylim()[1], + xmin=args.XMIN, + xmax=args.XMAX, + ymin=ymin[i], + ymax=args.YMAX, + color='black', + linestyle='dotted', + ) if args.INFILE2 is not None: - mdt.plot.plot(ax=axes[0], - x=xdata, - y=ydata, - xmin=args.XMIN, - xmax=args.XMAX, - ymin=np.min(ydata), - ymax=np.max(ydata), - color='black') + mdtplt.plot( + ax=axes[0], + x=xdata, + y=ydata, + xmin=args.XMIN, + xmax=args.XMAX, + ymin=np.min(ydata), + ymax=np.max(ydata), + color='black', + ) axes[0].xaxis.set_visible(False) axes[0].yaxis.set_visible(False) axes[0].spines['bottom'].set_visible(False) @@ -381,7 +391,7 @@ constrained_layout=True, gridspec_kw={'height_ratios': [1 / 5, 1]}) - mdt.plot.plot( + mdtplt.plot( ax=axes[1], x=bins[1:] - np.diff(bins) / 2, y=n_compounds_per_bin[1:], @@ -393,27 +403,32 @@ xlabel=r'${}(t_0)$ / {}'.format(args.DIRECTION, args.LUNIT), ylabel=r'$\langle N_{' + args.NAME + r'} \rangle$', color='black', - marker='o') - - mdt.plot.vlines(ax=axes[1], - x=bins, - start=axes[1].get_ylim()[0], - stop=axes[1].get_ylim()[1], - xmin=args.XMIN, - xmax=args.XMAX, - ymin=ymin[i], - ymax=args.YMAX, - color='black', - linestyle='dotted') - - mdt.plot.plot(ax=axes[0], - x=xdata, - y=ydata, - xmin=args.XMIN, - xmax=args.XMAX, - ymin=np.min(ydata), - ymax=np.max(ydata), - color='black') + marker='o', + ) + + mdtplt.vlines( + ax=axes[1], + x=bins, + start=axes[1].get_ylim()[0], + stop=axes[1].get_ylim()[1], + xmin=args.XMIN, + xmax=args.XMAX, + ymin=ymin[i], + ymax=args.YMAX, + color='black', + linestyle='dotted', + ) + + mdtplt.plot( + ax=axes[0], + x=xdata, + y=ydata, + xmin=args.XMIN, + xmax=args.XMAX, + ymin=np.min(ydata), + ymax=np.max(ydata), + color='black', + ) axes[0].xaxis.set_visible(False) axes[0].yaxis.set_visible(False) axes[0].spines['bottom'].set_visible(False) @@ -433,7 +448,7 @@ constrained_layout=True, gridspec_kw={'height_ratios': [1 / 5, 1]}) - mdt.plot.errorbar( + mdtplt.errorbar( ax=axes[1], x=bins[1:] - np.diff(bins) / 2, y=nevents[1:] / n_compounds_per_bin[1:], @@ -446,27 +461,32 @@ xlabel=r'${}(t_0)$ / {}'.format(args.DIRECTION, args.LUNIT), ylabel=r'$N_{renew}$ / $\langle N_{' + args.NAME + r'} \rangle$', color='black', - marker='o') - - mdt.plot.vlines(ax=axes[1], - x=bins, - start=axes[1].get_ylim()[0], - stop=axes[1].get_ylim()[1], - xmin=args.XMIN, - xmax=args.XMAX, - ymin=ymin[i], - ymax=args.YMAX, - color='black', - linestyle='dotted') - - mdt.plot.plot(ax=axes[0], - x=xdata, - y=ydata, - xmin=args.XMIN, - xmax=args.XMAX, - ymin=np.min(ydata), - ymax=np.max(ydata), - color='black') + marker='o', + ) + + mdtplt.vlines( + ax=axes[1], + x=bins, + start=axes[1].get_ylim()[0], + stop=axes[1].get_ylim()[1], + xmin=args.XMIN, + xmax=args.XMAX, + ymin=ymin[i], + ymax=args.YMAX, + color='black', + linestyle='dotted', + ) + + mdtplt.plot( + ax=axes[0], + x=xdata, + y=ydata, + xmin=args.XMIN, + xmax=args.XMAX, + ymin=np.min(ydata), + ymax=np.max(ydata), + color='black', + ) axes[0].xaxis.set_visible(False) axes[0].yaxis.set_visible(False) axes[0].spines['bottom'].set_visible(False) diff --git a/scripts/dynamics/plot_renewal_events_post0_vs_postrenew.py b/scripts/dynamics/plot_renewal_events_post0_vs_postrenew.py index a3030427..3d491d85 100644 --- a/scripts/dynamics/plot_renewal_events_post0_vs_postrenew.py +++ b/scripts/dynamics/plot_renewal_events_post0_vs_postrenew.py @@ -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 @@ -18,6 +18,9 @@ # along with MDTools. If not, see . +__author__ = "Andreas Thum" + + import sys import os from datetime import datetime @@ -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__': @@ -317,7 +322,7 @@ gridspec_kw={'height_ratios': [1 / 5, 1]}) axis = axes[1] - img = mdt.plot.scatter( + img = mdtplt.scatter( ax=axis, x=pos_t0_new_event, y=pos_tend_preceding_event, @@ -329,7 +334,8 @@ xlabel=r'$' + args.DIRECTION + r'(t_0 + \tau_{renew})$ / ' + args.LUNIT, ylabel=r'$' + args.DIRECTION + r'(t_0^\prime)$ / ' + 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) @@ -345,29 +351,33 @@ labelsize=0.8 * fontsize_ticks) if i > 0: - 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') + 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', + ) if i > 1: - mdt.plot.hlines(ax=axis, - y=bins, - start=axis.get_xlim()[0], - stop=axis.get_xlim()[1], - xmin=args.XMIN, - xmax=args.XMAX, - ymin=args.YMIN, - ymax=args.YMAX, - color='black', - linestyle='dotted') + mdtplt.hlines( + ax=axis, + y=bins, + start=axis.get_xlim()[0], + stop=axis.get_xlim()[1], + xmin=args.XMIN, + xmax=args.XMAX, + ymin=args.YMIN, + ymax=args.YMAX, + color='black', + linestyle='dotted', + ) diagonal = np.linspace(*axis.get_xlim()) - mdt.plot.plot( + mdtplt.plot( ax=axis, x=diagonal, y=diagonal, @@ -377,17 +387,20 @@ ymax=args.YMAX, xlabel=r'$' + args.DIRECTION + r'(t_0 + \tau_{renew})$ / ' + args.LUNIT, ylabel=r'$' + args.DIRECTION + r'(t_0^\prime)$ / ' + args.LUNIT, - color='black') + color='black', + ) 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) diff --git a/scripts/dynamics/plot_renewal_events_postrenew_vs_post0.py b/scripts/dynamics/plot_renewal_events_postrenew_vs_post0.py index af86343a..30cdfa9f 100644 --- a/scripts/dynamics/plot_renewal_events_postrenew_vs_post0.py +++ b/scripts/dynamics/plot_renewal_events_postrenew_vs_post0.py @@ -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 @@ -18,6 +18,9 @@ # along with MDTools. If not, see . +__author__ = "Andreas Thum" + + import sys import os from datetime import datetime @@ -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__': @@ -311,7 +316,7 @@ gridspec_kw={'height_ratios': [1 / 5, 1]}) axis = axes[1] - img = mdt.plot.scatter( + img = mdtplt.scatter( ax=axis, x=pos_t0, y=pos_trenew, @@ -323,7 +328,8 @@ xlabel=r'${}(t_0)$ / {}'.format(args.DIRECTION, args.LUNIT), ylabel=r'$' + args.DIRECTION + r'(t_0 + \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) @@ -338,29 +344,33 @@ 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') + 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', + ) if i == 1: - mdt.plot.hlines(ax=axis, - y=bins, - start=axis.get_xlim()[0], - stop=axis.get_xlim()[1], - xmin=args.XMIN, - xmax=args.XMAX, - ymin=args.YMIN, - ymax=args.YMAX, - color='black', - linestyle='dotted') + mdtplt.hlines( + ax=axis, + y=bins, + start=axis.get_xlim()[0], + stop=axis.get_xlim()[1], + xmin=args.XMIN, + xmax=args.XMAX, + ymin=args.YMIN, + ymax=args.YMAX, + color='black', + linestyle='dotted', + ) diagonal = np.linspace(*axis.get_xlim()) - mdt.plot.plot( + mdtplt.plot( ax=axis, x=diagonal, y=diagonal, @@ -370,9 +380,10 @@ ymax=args.YMAX, xlabel=r'${}(t_0)$ / {}'.format(args.DIRECTION, args.LUNIT), ylabel=r'$' + args.DIRECTION + r'(t_0 + \tau_{renew})$ / ' + args.LUNIT, - color='black') + color='black', + ) - mdt.plot.errorbar( + mdtplt.errorbar( ax=axis, x=bins[1:] - np.diff(bins) / 2, y=pos_trenew_mean[1:], @@ -384,17 +395,20 @@ xlabel=r'${}(t_0)$ / {}'.format(args.DIRECTION, args.LUNIT), ylabel=r'$' + args.DIRECTION + r'(t_0 + \tau_{renew})$ / ' + args.LUNIT, color='red', - marker='o') + marker='o', + ) 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) diff --git a/scripts/dynamics/plot_renewal_events_ref_dist.py b/scripts/dynamics/plot_renewal_events_ref_dist.py index 74bba6fc..b7feb9a9 100644 --- a/scripts/dynamics/plot_renewal_events_ref_dist.py +++ b/scripts/dynamics/plot_renewal_events_ref_dist.py @@ -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 @@ -18,6 +18,9 @@ # along with MDTools. If not, see . +__author__ = "Andreas Thum" + + import sys import os from datetime import datetime @@ -26,6 +29,8 @@ import numpy as np import matplotlib.pyplot as plt 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__': @@ -268,7 +273,7 @@ gridspec_kw={'height_ratios': [1 / 5, 1]}) axis = axes[1] - mdt.plot.plot( + mdtplt.plot( ax=axis, x=bins[1:] - np.diff(bins) / 2, y=distribution[1:], @@ -279,28 +284,33 @@ xlabel=r'${}(t_0)$ / {}'.format(args.DIRECTION, args.LUNIT), ylabel=r'$p$', color='black', - marker='o') + marker='o', + ) - 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') + 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', + ) if args.INFILE2 is not None: - mdt.plot.plot(ax=axes[0], - x=xdata, - y=ydata, - xmin=args.XMIN, - xmax=args.XMAX, - ymin=np.min(ydata), - ymax=np.max(ydata), - color='black') + mdtplt.plot( + ax=axes[0], + x=xdata, + y=ydata, + xmin=args.XMIN, + xmax=args.XMAX, + ymin=np.min(ydata), + ymax=np.max(ydata), + color='black', + ) axes[0].xaxis.set_visible(False) axes[0].yaxis.set_visible(False) axes[0].spines['bottom'].set_visible(False) diff --git a/scripts/dynamics/plot_renewal_events_t0_vs_trenew.py b/scripts/dynamics/plot_renewal_events_t0_vs_trenew.py index 4089a818..6e2554de 100644 --- a/scripts/dynamics/plot_renewal_events_t0_vs_trenew.py +++ b/scripts/dynamics/plot_renewal_events_t0_vs_trenew.py @@ -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 @@ -18,6 +18,9 @@ # along with MDTools. If not, see . +__author__ = "Andreas Thum" + + import sys import os from datetime import datetime @@ -26,6 +29,8 @@ import numpy as np import matplotlib.pyplot as plt 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__': @@ -170,7 +175,7 @@ clear=True, tight_layout=True) - img = mdt.plot.scatter( + img = mdtplt.scatter( ax=axis, x=t0_new_event, y=tend_preceding_event, @@ -180,10 +185,11 @@ ymax=args.YMAX, xlabel=r'$t_0 + \tau_{renew}$ / ' + args.TUNIT, ylabel=r'$t_0^\prime$ / ' + args.TUNIT, - marker='x') + marker='x', + ) diagonal = np.linspace(*axis.get_xlim()) - mdt.plot.plot( + mdtplt.plot( ax=axis, x=diagonal, y=diagonal, @@ -193,7 +199,8 @@ ymax=args.YMAX, xlabel=r'$t_0 + \tau_{renew}$ / ' + args.TUNIT, ylabel=r'$t_0^\prime$ / ' + args.TUNIT, - color='black') + color='black', + ) mdt.fh.backup(args.OUTFILE) plt.tight_layout() diff --git a/scripts/dynamics/plot_renewal_events_transition_matrix.py b/scripts/dynamics/plot_renewal_events_transition_matrix.py index 9083ddd9..2ccc182c 100644 --- a/scripts/dynamics/plot_renewal_events_transition_matrix.py +++ b/scripts/dynamics/plot_renewal_events_transition_matrix.py @@ -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 @@ -18,6 +18,9 @@ # along with MDTools. If not, see . +__author__ = "Andreas Thum" + + import sys import os from datetime import datetime @@ -29,6 +32,8 @@ from matplotlib.backends.backend_pdf import PdfPages from matplotlib.ticker import MaxNLocator 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__': @@ -409,7 +414,7 @@ axis.yaxis.set_major_locator(MaxNLocator(integer=True)) xy = np.append(active_set, active_set[-1] + 1) - 0.5 - mdt.plot.pcolormesh( + mdtplt.pcolormesh( ax=axis, x=xy, y=xy, @@ -421,7 +426,8 @@ xlabel=r'Bin $j$', ylabel=r'Bin $i$', cbarlabel=cbarlabel[i], - cmap=cmap[i]) + cmap=cmap[i], + ) axis.invert_yaxis() axis.xaxis.set_label_position('top') @@ -440,16 +446,18 @@ tight_layout=True) axis.xaxis.set_major_locator(MaxNLocator(integer=True)) axis.yaxis.set_major_locator(MaxNLocator(integer=True)) - mdt.plot.plot(ax=axis, - x=active_set, - y=eigvecs, - xmin=0.5, - xmax=len(bins) - 0.5, - ymin=0, - xlabel=r'Bin $i$', - ylabel="Stationary distribution", - color='black', - marker='o') + mdtplt.plot( + ax=axis, + x=active_set, + y=eigvecs, + xmin=0.5, + xmax=len(bins) - 0.5, + ymin=0, + xlabel=r'Bin $i$', + ylabel="Stationary distribution", + color='black', + marker='o', + ) plt.tight_layout() pdf.savefig() plt.close() @@ -470,7 +478,7 @@ inactive, np.nan, axis=1) - mdt.plot.pcolormesh( + mdtplt.pcolormesh( ax=axis, x=bins, y=bins, @@ -482,7 +490,8 @@ xlabel=r'$' + args.DIRECTION + r'(t_0 + \tau_{renew})$ / ' + args.LUNIT, ylabel=r'${}(t_0)$ / {}'.format(args.DIRECTION, args.LUNIT), cbarlabel=cbarlabel[i], - cmap=cmap[i]) + cmap=cmap[i], + ) yticks = np.array(axis.get_yticks()) mask = ((yticks >= axis.get_xlim()[0]) & @@ -517,7 +526,7 @@ axis = axes[1] eigvecs = np.insert(eigvecs, inactive, np.nan, axis=0) - mdt.plot.plot( + mdtplt.plot( ax=axis, x=bins[1:] - np.diff(bins) / 2, y=eigvecs, @@ -527,26 +536,31 @@ xlabel=r'${}(t_0)$ / {}'.format(args.DIRECTION, args.LUNIT), ylabel="Stationary distribution", color='black', - marker='o') - mdt.plot.vlines(ax=axis, - x=bins, - start=axis.get_ylim()[0], - stop=axis.get_ylim()[1], - xmin=args.MIN, - xmax=args.MAX, - ymin=0, - color='black', - linestyle='dotted') + marker='o', + ) + mdtplt.vlines( + ax=axis, + x=bins, + start=axis.get_ylim()[0], + stop=axis.get_ylim()[1], + xmin=args.MIN, + xmax=args.MAX, + ymin=0, + color='black', + linestyle='dotted', + ) if args.INFILE2 is not None: - mdt.plot.plot(ax=axes[0], - x=xdata, - y=ydata, - xmin=args.MIN, - xmax=args.MAX, - ymin=np.min(ydata), - ymax=np.max(ydata), - color='black') + mdtplt.plot( + ax=axes[0], + x=xdata, + y=ydata, + xmin=args.MIN, + xmax=args.MAX, + ymin=np.min(ydata), + ymax=np.max(ydata), + color='black', + ) axes[0].xaxis.set_visible(False) axes[0].yaxis.set_visible(False) axes[0].spines['bottom'].set_visible(False) @@ -580,7 +594,7 @@ gridspec_kw={'height_ratios': [1 / 5, 1]}) axis = axes[1] - mdt.plot.errorbar( + mdtplt.errorbar( ax=axis, x=bins[1:] - np.diff(bins) / 2, y=nevents, @@ -592,17 +606,20 @@ xlabel=r'${}(t_0)$ / {}'.format(args.DIRECTION, args.LUNIT), ylabel=r'$N_{renew}$', label="Simulation", - marker='o') - mdt.plot.vlines(ax=axis, - x=bins, - start=axis.get_ylim()[0], - stop=axis.get_ylim()[1], - xmin=args.MIN, - xmax=args.MAX, - ymin=ymin[i], - color='black', - linestyle='dotted') - mdt.plot.plot( + marker='o', + ) + mdtplt.vlines( + ax=axis, + x=bins, + start=axis.get_ylim()[0], + stop=axis.get_ylim()[1], + xmin=args.MIN, + xmax=args.MAX, + ymin=ymin[i], + color='black', + linestyle='dotted', + ) + mdtplt.plot( ax=axis, x=bins[1:] - np.diff(bins) / 2, y=eigvecs * np.sum(nevents), @@ -613,17 +630,20 @@ xlabel=r'${}(t_0)$ / {}'.format(args.DIRECTION, args.LUNIT), ylabel=r'$N_{renew}$', label="Model", - marker='s') + marker='s', + ) if args.INFILE2 is not None: - mdt.plot.plot(ax=axes[0], - x=xdata, - y=ydata, - xmin=args.MIN, - xmax=args.MAX, - ymin=np.min(ydata), - ymax=np.max(ydata), - color='black') + mdtplt.plot( + ax=axes[0], + x=xdata, + y=ydata, + xmin=args.MIN, + xmax=args.MAX, + ymin=np.min(ydata), + ymax=np.max(ydata), + color='black', + ) axes[0].xaxis.set_visible(False) axes[0].yaxis.set_visible(False) axes[0].spines['bottom'].set_visible(False) @@ -647,7 +667,7 @@ clear=True, constrained_layout=True, gridspec_kw={'height_ratios': [1 / 5, 1]}) - mdt.plot.errorbar( + mdtplt.errorbar( ax=axes[1], x=bins[1:] - np.diff(bins) / 2, y=nevents / n_compounds_per_bin[1:], @@ -659,17 +679,20 @@ xlabel=r'${}(t_0)$ / {}'.format(args.DIRECTION, args.LUNIT), ylabel=r'$N_{renew}$ / $\langle N_{' + args.NAME + r'} \rangle$', label="Simulation", - marker='o') - mdt.plot.vlines(ax=axes[1], - x=bins, - start=axes[1].get_ylim()[0], - stop=axes[1].get_ylim()[1], - xmin=args.MIN, - xmax=args.MAX, - ymin=ymin[i], - color='black', - linestyle='dotted') - mdt.plot.plot( + marker='o', + ) + mdtplt.vlines( + ax=axes[1], + x=bins, + start=axes[1].get_ylim()[0], + stop=axes[1].get_ylim()[1], + xmin=args.MIN, + xmax=args.MAX, + ymin=ymin[i], + color='black', + linestyle='dotted', + ) + mdtplt.plot( ax=axes[1], x=bins[1:] - np.diff(bins) / 2, y=eigvecs * np.sum(nevents) / n_compounds_per_bin[1:][:, None], @@ -680,15 +703,18 @@ xlabel=r'${}(t_0)$ / {}'.format(args.DIRECTION, args.LUNIT), ylabel=r'$N_{renew}$ / $\langle N_{' + args.NAME + r'} \rangle$', label="Model", - marker='s') - mdt.plot.plot(ax=axes[0], - x=xdata, - y=ydata, - xmin=args.MIN, - xmax=args.MAX, - ymin=np.min(ydata), - ymax=np.max(ydata), - color='black') + marker='s', + ) + mdtplt.plot( + ax=axes[0], + x=xdata, + y=ydata, + xmin=args.MIN, + xmax=args.MAX, + ymin=np.min(ydata), + ymax=np.max(ydata), + color='black', + ) axes[0].xaxis.set_visible(False) axes[0].yaxis.set_visible(False) axes[0].spines['bottom'].set_visible(False) diff --git a/scripts/dynamics/plot_renewal_events_trenew_hist.py b/scripts/dynamics/plot_renewal_events_trenew_hist.py index a8280389..2dac289f 100644 --- a/scripts/dynamics/plot_renewal_events_trenew_hist.py +++ b/scripts/dynamics/plot_renewal_events_trenew_hist.py @@ -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 @@ -18,6 +18,9 @@ # along with MDTools. If not, see . +__author__ = "Andreas Thum" + + import sys import os from datetime import datetime @@ -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__': @@ -198,17 +203,19 @@ frameon=False, clear=True, tight_layout=True) - mdt.plot.hist(ax=axis, - x=trenew, - xmin=args.XMIN, - xmax=args.XMAX, - ymin=args.YMIN, - ymax=args.YMAX, - xlabel=r'$\tau_{renew}$ / ' + args.TUNIT, - ylabel="Counts", - bins=bins, - range=(args.START, args.STOP), - density=False) + mdtplt.hist( + ax=axis, + x=trenew, + xmin=args.XMIN, + xmax=args.XMAX, + ymin=args.YMIN, + ymax=args.YMAX, + xlabel=r'$\tau_{renew}$ / ' + args.TUNIT, + ylabel="Counts", + bins=bins, + range=(args.START, args.STOP), + density=False, + ) plt.tight_layout() pdf.savefig() plt.close() @@ -218,28 +225,32 @@ frameon=False, clear=True, tight_layout=True) - mdt.plot.hist(ax=axis, - x=trenew, - xmin=args.XMIN, - xmax=args.XMAX, - ymin=args.YMIN, - ymax=args.YMAX, - xlabel=r'$\tau_{renew}$ / ' + args.TUNIT, - ylabel=r'$p(\tau_{renew})$', - bins=bins, - range=(args.START, args.STOP), - density=True) - mdt.plot.plot(ax=axis, - x=x, - y=mdt.stats.exp_dist(x=x, rate=popt), - xmin=args.XMIN, - xmax=args.XMAX, - ymin=args.YMIN, - ymax=args.YMAX, - xlabel=r'$\tau_{renew}$ / ' + args.TUNIT, - ylabel=r'$p(\tau_{renew})$', - label="Fit", - color='black') + mdtplt.hist( + ax=axis, + x=trenew, + xmin=args.XMIN, + xmax=args.XMAX, + ymin=args.YMIN, + ymax=args.YMAX, + xlabel=r'$\tau_{renew}$ / ' + args.TUNIT, + ylabel=r'$p(\tau_{renew})$', + bins=bins, + range=(args.START, args.STOP), + density=True, + ) + mdtplt.plot( + ax=axis, + x=x, + y=mdt.stats.exp_dist(x=x, rate=popt), + xmin=args.XMIN, + xmax=args.XMAX, + ymin=args.YMIN, + ymax=args.YMAX, + xlabel=r'$\tau_{renew}$ / ' + args.TUNIT, + ylabel=r'$p(\tau_{renew})$', + label="Fit", + color='black', + ) plt.tight_layout() pdf.savefig() plt.close() diff --git a/scripts/dynamics/plot_renewal_events_trenew_vs_post0.py b/scripts/dynamics/plot_renewal_events_trenew_vs_post0.py index 654e9f14..12b39507 100644 --- a/scripts/dynamics/plot_renewal_events_trenew_vs_post0.py +++ b/scripts/dynamics/plot_renewal_events_trenew_vs_post0.py @@ -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 @@ -18,6 +18,9 @@ # along with MDTools. If not, see . +__author__ = "Andreas Thum" + + import sys import os from datetime import datetime @@ -27,6 +30,8 @@ import matplotlib.pyplot as plt import matplotlib.colors as colors 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__': @@ -306,7 +311,7 @@ gridspec_kw={'height_ratios': [1 / 5, 1]}) axis = axes[1] - img = mdt.plot.scatter( + img = mdtplt.scatter( ax=axis, x=pos_t0, y=trenew, @@ -319,9 +324,12 @@ ylabel=r'$\tau_{renew}$ / ' + args.TUNIT, marker='x', cmap='coolwarm', - norm=colors.TwoSlopeNorm(vmin=np.min(displ), - vcenter=0, - vmax=np.max(displ))) + norm=colors.TwoSlopeNorm( + vmin=np.min(displ), + vcenter=0, + vmax=np.max(displ), + ), + ) cbar = fig.colorbar(img, ax=axis) cbar.set_label(label=r'$\Delta ' + args.DIRECTION + r'$ / ' + args.LUNIT, fontsize=fontsize_labels) @@ -336,18 +344,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.errorbar( + 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.errorbar( ax=axis, x=bins[1:] - np.diff(bins) / 2, y=trenew_mean[1:], @@ -359,17 +369,20 @@ xlabel=r'${}(t_0)$ / {}'.format(args.DIRECTION, args.LUNIT), ylabel=r'$\tau_{renew}$ / ' + args.TUNIT, color='black', - marker='o') + marker='o', + ) 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) diff --git a/scripts/structure/plot_topological_map.py b/scripts/structure/plot_topological_map.py index 212a302e..447b237a 100644 --- a/scripts/structure/plot_topological_map.py +++ b/scripts/structure/plot_topological_map.py @@ -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 @@ -18,6 +18,9 @@ # along with MDTools. If not, see . +__author__ = "Andreas Thum" + + # This python script is inspired by the work of Florian Müller-Plathe # and Wilfred F. van Gunsteren which was adapted by Oleg Borodin and # Grant D. Smith @@ -39,6 +42,8 @@ from matplotlib.backends.backend_pdf import PdfPages from matplotlib.ticker import MaxNLocator import mdtools as mdt +import mdtools.plot as mdtplt # TODO: Replace deprecated functions +plt.style.use("default") # TODO: Use MDTools plotting style # Matplotlib: Nested Gridspecs @@ -556,7 +561,7 @@ linestyles='--') for a_ix in ab_ix.T: - mdt.plot.scatter( + mdtplt.scatter( ax=axis, x=times[::effective_plotevery], y=a_ix[::effective_plotevery], @@ -573,7 +578,8 @@ cmap=cmap, vmin=vmin, vmax=vmax, - norm=norm) + norm=norm, + ) if rb < len(res_blocks) - 2: axis.tick_params(labelbottom=False) axis.set_xlabel('') @@ -607,14 +613,16 @@ if vmin_ix == vmax_ix: vmin_ix = 0 vmax_ix = len(data[:, 1]) - mdt.plot.plot(ax=axis, - x=data[:, 0], - y=data[:, 1], - xmin=vmin, - xmax=vmax, - ymin=np.min(data[vmin_ix:vmax_ix, 1]), - ymax=np.max(data[vmin_ix:vmax_ix, 1]), - color='black') + mdtplt.plot( + ax=axis, + x=data[:, 0], + y=data[:, 1], + xmin=vmin, + xmax=vmax, + ymin=np.min(data[vmin_ix:vmax_ix, 1]), + ymax=np.max(data[vmin_ix:vmax_ix, 1]), + color='black', + ) axis.xaxis.set_visible(False) axis.yaxis.set_visible(False) axis.spines['bottom'].set_visible(False)