63 lines
1.8 KiB
Python
63 lines
1.8 KiB
Python
import ast
|
|
|
|
import matplotlib.pyplot as plt
|
|
import numpy as np
|
|
import seaborn as sns
|
|
|
|
sns.set_theme()
|
|
params = {
|
|
"font.family": "Serif",
|
|
"font.serif": "Roman",
|
|
"text.usetex": True,
|
|
"xtick.bottom": False,
|
|
"xtick.labelbottom": False,
|
|
"ytick.left": False,
|
|
"ytick.labelleft": False,
|
|
"axes.grid": False,
|
|
# "figure.autolayout": True
|
|
# "figure.constrained_layout.use": False,
|
|
# "figure.constrained_layout.h_pad": 0.04167,
|
|
# "figure.constrained_layout.w_pad": 0.04167
|
|
# "figure.subplot.wspace": 0,
|
|
# "figure.subplot.hspace": 0
|
|
}
|
|
plt.rcParams.update(params)
|
|
|
|
|
|
def plot():
|
|
fig, axes = plt.subplots(figsize=(6,6), nrows=3, ncols=3)
|
|
with open("data/color_map.txt") as f:
|
|
lines = f.readlines()
|
|
size = int(lines[0])
|
|
for i, line in enumerate(lines[1:]):
|
|
arr = line.strip().split("\t")
|
|
arr = np.asarray(list(map(lambda x: complex(*ast.literal_eval(x)), arr)))
|
|
# Reshape and transpose array
|
|
arr = arr.reshape(size, size).T
|
|
|
|
# Plot color maps
|
|
axes[0, i].imshow(
|
|
np.multiply(arr, arr.conj()).real,
|
|
interpolation="nearest",
|
|
cmap=sns.color_palette("mako", as_cmap=True)
|
|
)
|
|
axes[1, i].imshow(
|
|
arr.real,
|
|
interpolation="nearest",
|
|
cmap=sns.color_palette("mako", as_cmap=True)
|
|
)
|
|
axes[2, i].imshow(
|
|
arr.imag,
|
|
interpolation="nearest",
|
|
cmap=sns.color_palette("mako", as_cmap=True)
|
|
)
|
|
|
|
# Create tight subplots and save figure
|
|
fig.subplots_adjust(wspace=0, hspace=0)
|
|
fig.savefig(f"latex/images/color_map_all.pdf", bbox_inches="tight")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
plot()
|
|
|