From 8761ae1048037c329f8083b823211ba616abff00 Mon Sep 17 00:00:00 2001 From: Janita Willumsen Date: Fri, 22 Dec 2023 13:21:42 +0100 Subject: [PATCH] Add alternative script for colormap, removing grid and adding colorbar to plots. --- python_scripts/colormap_alt.py | 38 ++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 python_scripts/colormap_alt.py diff --git a/python_scripts/colormap_alt.py b/python_scripts/colormap_alt.py new file mode 100644 index 0000000..1496a37 --- /dev/null +++ b/python_scripts/colormap_alt.py @@ -0,0 +1,38 @@ +import numpy as np +import matplotlib.pyplot as plt +import ast +import seaborn as sns + +sns.set_theme() +params = { + "font.family": "Serif", + "font.serif": "Roman", + "text.usetex": True, + "axes.titlesize": "large", + "axes.labelsize": "large", + "xtick.labelsize": "large", + "ytick.labelsize": "large", + "legend.fontsize": "medium", +} +plt.rcParams.update(params) + +def plot(): + with open("data/color_map.txt") as f: + lines = f.readlines() + size = int(lines[0]) + for i, line in enumerate(lines[1:]): + fig, ax = plt.subplots() + arr = line.strip().split("\t") + arr = np.asarray(list(map(lambda x: ((a := complex(*ast.literal_eval(x)))*a.conjugate()).real, arr))) + + arr = arr.reshape(size,size) + + color_map = ax.imshow(arr.T, interpolation="nearest", cmap=sns.color_palette("mako", as_cmap=True)) + fig.colorbar(color_map, ax=ax) + plt.grid(False) + plt.savefig(f"latex/images/color_map_{i}.pdf") + plt.close(fig) + + +if __name__ == "__main__": + plot() \ No newline at end of file