1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79
| import numpy as np import matplotlib.pyplot as plt from matplotlib import rcParams import os import matplotlib.ticker as mticker import matplotlib.colors as colors plt.rc('font', family='Times New Roman') config = { "font.size": 30, "mathtext.fontset":'stix', "font.serif": ['SimSun'], } rcParams.update(config)
def Plot_phase_diagram(numk): dataname = "chi-val-kn-" + str(format(numk,"0>3d")) + ".dat" dataname = "Bx_kbt-phase.dat" picname = os.path.splitext(dataname)[0] + ".png" da = np.loadtxt(dataname) x0 = np.array(da[0, :]) y0 = np.array(da[1, :]) z0 = np.array(da[2, :]) xn = int(np.sqrt(len(x0))) x0 = x0.reshape(xn, xn) y0 = y0.reshape(xn, xn) z0 = z0.reshape(xn,xn) x_min, x_max = np.min(x0), np.max(x0) y_min, y_max = np.min(y0), np.max(y0)
plt.figure(figsize=(10, 10)) sc = plt.imshow(z0, interpolation = 'spline16', cmap = "jet", origin = 'lower') cb = plt.colorbar(sc,fraction = 0.045,extend='both') cb.ax.tick_params(size = 0.8) cb.ax.set_title(r"$\Delta_0$", fontsize = 30) font2 = {'family': 'Times New Roman','weight': 'normal','size': 40} plt.axis('scaled') plt.xlabel(r"$k_BT$",font2) plt.ylabel(r"$B_c$",font2) xticks = np.linspace(0, z0.shape[1] - 1, num = 5) yticks = np.linspace(0, z0.shape[0] - 1, num = 5) xtick_labels = np.linspace(x_min, x_max, num = 5) ytick_labels = np.linspace(y_min, y_max, num = 5) plt.xticks(xticks, labels=[f"{x:.1f}" for x in xtick_labels]) plt.yticks(yticks, labels=[f"{y:.1f}" for y in ytick_labels]) plt.tight_layout() plt.tick_params(axis='x',width = 0.,length = 10) plt.tick_params(axis='y',width = 0,length = 10) ax = plt.gca() ax.locator_params(axis='x', nbins = 5) ax.locator_params(axis='y', nbins = 5) ax.spines["bottom"].set_linewidth(1.5) ax.spines["left"].set_linewidth(1.5) ax.spines["right"].set_linewidth(1.5) ax.spines["top"].set_linewidth(1.5) plt.savefig(picname, dpi = 300,bbox_inches = 'tight') plt.close()
if __name__=="__main__": kn = 128 Plot_phase_diagram(kn)
|