Plotting Figure 2¶

In [1]:
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.image as image
import scipy.ndimage as ndimage
# load modules
import matplotlib as mpl
from matplotlib.offsetbox import (OffsetImage, AnnotationBbox)
import os
from nice_figures import *


figsizes = load_style()
mpl.rcParams.update({'figure.autolayout' : False})

plt.rcParams.update({
    "text.usetex": True,
    "font.family": "lmodern"
})

plt.rcParams['mathtext.fontset'] = 'stix'
#plt.rcParams['mathtext.cal'] = 'stix:cal'


mpl.rcParams['mathtext.fontset'] = 'custom'
mpl.rcParams['mathtext.rm'] = 'lmodern'
mpl.rcParams['mathtext.it'] = 'lmodern:italic'
mpl.rcParams['mathtext.bf'] = 'lmodern:bold'
In [2]:
#Loading data:
Ps17 = np.loadtxt("./Figures_Dataset/Fig2/Fig2_Periods_U1_1.7.txt")
Xs17 = np.loadtxt("./Figures_Dataset/Fig2/Fig2_Critical_X_U1_1.7.txt")
Ps15 = np.loadtxt("./Figures_Dataset/Fig2/Fig2_Periods_U1_1.5.txt")
Xs15 = np.loadtxt("./Figures_Dataset/Fig2/Fig2_Critical_X_U1_1.5.txt")
Ps10 = np.loadtxt("./Figures_Dataset/Fig2/Fig2_Periods_U1_1.0.txt")
Xs10 = np.loadtxt("./Figures_Dataset/Fig2/Fig2_Critical_X_U1_1.0.txt")
Ps05 = np.loadtxt("./Figures_Dataset/Fig2/Fig2_Periods_U1_0.5.txt")
Xs05 = np.loadtxt("./Figures_Dataset/Fig2/Fig2_Critical_X_U1_0.5.txt")

As110 = np.loadtxt("./Figures_Dataset/Fig2/inset/Fig2_inset_Amplitudes_period_1.09.txt")
Xs110 = np.loadtxt("./Figures_Dataset/Fig2/inset/Fig2_inset_Critical_X_period_1.09.txt")
As100 = np.loadtxt("./Figures_Dataset/Fig2/inset/Fig2_inset_Amplitudes_period_1.2.txt")
Xs100 = np.loadtxt("./Figures_Dataset/Fig2/inset/Fig2_inset_Critical_X_period_1.2.txt")
As90 = np.loadtxt("./Figures_Dataset/Fig2/inset/Fig2_inset_Amplitudes_period_1.33.txt")
Xs90 = np.loadtxt("./Figures_Dataset/Fig2/inset/Fig2_inset_Critical_X_period_1.33.txt")
As60 = np.loadtxt("./Figures_Dataset/Fig2/inset/Fig2_inset_Amplitudes_period_2.0.txt")
Xs60 = np.loadtxt("./Figures_Dataset/Fig2/inset/Fig2_inset_Critical_X_period_2.0.txt")
In [7]:
xtick_p = [0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8,
           0.9, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0,
           7.0, 8.0, 9.0, 10.0]
xtick_l = ["$0.2$", "", "", "", "", "", "",
           "", "$1.0$", "", "", "", "", "",
           "", "", "", "$10$"]


figsize = load_style()
w, h = figsize[('APS', '1-column')]
font_size = 14
mpl.rcParams.update({'font.size': font_size})
mpl.rcParams['mathtext.fontset'] = 'custom'
mpl.rcParams['mathtext.rm'] = 'lmodern'
mpl.rcParams['mathtext.it'] = 'lmodern:italic'
mpl.rcParams['mathtext.bf'] = 'lmodern:bold'


fig, ax1 = plt.subplots(figsize=(5, 3.5))

color = 'red'
markerS = 2.0
ax1.set_xlabel(r"Period $a/\sigma$",labelpad=3)
ax1.set_ylabel(r'$\chi_{c}$',labelpad=3)


#filling ----------------------------------
Ps17 = np.array(Ps17)
Xs17 = np.array(Xs17)
Ps15 = np.array(Ps15)
Xs15 = np.array(Xs15)
Ps10 = np.array(Ps10)
Xs10 = np.array(Xs10)
Ps05 = np.array(Ps05)
Xs05 = np.array(Xs05)

baseline = 0.8
upline = 3.3
ax1.fill_between(Ps05, Xs05, upline, where=(Xs05 <= upline), alpha=0.2, color='pink')
ax1.fill_between(Ps10[:218], Xs10[:218], Xs05[:218], alpha=0.2, color='blue')
ax1.fill_between(Ps15[:179], Xs15[:179], Xs10[39:218], alpha=0.2, color="green")
ax1.fill_between(Ps17[1:180], Xs17[1:180], Xs15[:179], alpha=0.2, color="orange")
ax1.fill_between(Ps17, Xs17, baseline, where=(Xs17 > baseline), alpha=0.3, color='red')




text_kwargs_state = dict(ha='center', va='center', fontsize=14)

color17t = 'red'

xxx=0.86
yy0 = 0.8 
arrlw = 1.0
arrfc = 'black'


ax1.annotate('', (xxx-0.054,yy0), (xxx-0.045,2.97),ha="right", va="center",
             arrowprops=dict(fc=arrfc, arrowstyle='<|- ' ,mutation_scale=8, lw=arrlw, color='blue'),zorder=1)#linestyle=":",
ax1.annotate('', (xxx-0.036,yy0), (xxx-0.03,2.81),ha="right", va="center",
             arrowprops=dict(fc=arrfc, arrowstyle='<|- ' ,mutation_scale=8, lw=arrlw, color='green'),zorder=1)
ax1.annotate('', (xxx-0.018,yy0), (xxx-0.015,2.3),ha="right", va="center",
             arrowprops=dict(fc=arrfc, arrowstyle='<|- ' ,mutation_scale=8, lw=arrlw, color='orange'),zorder=1)
ax1.annotate('', (xxx,yy0), (xxx,2.1),ha="right", va="center",
             arrowprops=dict(fc=arrfc, arrowstyle='<|- ' ,mutation_scale=8, lw=arrlw, color='red'),zorder=1)


xxx=0.47
yy0 = 3.26


ax1.annotate('', (xxx,yy0), (xxx,1.98),ha="right", va="center",
             arrowprops=dict(fc=arrfc, arrowstyle='<|- ' ,mutation_scale=8, lw=arrlw, color='red'),zorder=1)

ax1.annotate('', (xxx-0.01,yy0), (xxx-0.01,2.21),ha="right", va="center",
             arrowprops=dict(fc=arrfc, arrowstyle='<|- ' ,mutation_scale=8, lw=arrlw, color='orange'),zorder=1)

ax1.annotate('', (xxx-0.02,yy0), (xxx-0.02,2.8),ha="right", va="center",
             arrowprops=dict(fc=arrfc, arrowstyle='<|- ' ,mutation_scale=8, lw=arrlw, color='green'),zorder=1)
ax1.annotate('', (xxx-0.03,yy0), (xxx-0.03,2.95),ha="right", va="center",
             arrowprops=dict(fc=arrfc, arrowstyle='<|- ' ,mutation_scale=8, lw=arrlw, color='blue'),zorder=1)#linestyle=":",

ax1.text(1.12,0.97, r'liquid', color='black', **text_kwargs_state)
ax1.text(0.36,3.15, r'glass', color='black', **text_kwargs_state)

#------------------------------------------
ax1.axhline(y=2.9596, color='black', linestyle='--', label=r"$0.0$", lw=0.5)
ax1.plot(Ps05, Xs05, linestyle="-", marker="s", markeredgewidth=0.6,markerfacecolor="None", color="blue" ,label=r"$0.5$",ms=markerS,lw=0.15)
ax1.plot(Ps10, Xs10, linestyle="-", marker="o", markeredgewidth=0.6,markerfacecolor="None", color="green" ,label=r"$1.0$",ms=markerS,lw=0.15)
ax1.plot(Ps15, Xs15, linestyle="-", marker="p", markeredgewidth=0.6,markerfacecolor="None", color="orange" ,label=r"$1.5$",ms=markerS,lw=0.15)

ax1.plot(Ps17, Xs17, linestyle="-", marker="D", markeredgewidth=0.6,markerfacecolor="None", color="red" ,label=r"$1.7$",ms=markerS,lw=0.15)


Ps17Dot = [Ps17[54], Ps17[65], Ps17[94], Ps17[102]]
Xs17Dot = [Xs17[54], Xs17[65], Xs17[94], Xs17[102]]
ax1.plot(Ps17Dot, Xs17Dot, linestyle=" ", marker="o", color="black", ms=markerS*1.7)


ax1.set_ylim(0.8, 3.3)
ax1.set_xlim(0.199, 11)
font_size = 10
mpl.rcParams.update({'font.size': font_size})
legend = ax1.legend(frameon=True,loc='upper right', bbox_to_anchor=(0.2, 0.505), title=r"$U_{1}/k_{B}T$", fontsize=10)


font_size = 8
mpl.rcParams.update({'font.size': font_size})
left, bottom, width, height = [0.57, 0.3, 0.35, 0.35]
ax2 = fig.add_axes([left, bottom, width, height])
ax2.set_ylim(2.4,3.3)
ax2.set_xlim(-0.05,2.05)


ax2.plot(As110, Xs110, linestyle="-", color="orange", mec="orange", marker="s",  label="$1.09$", lw=0.5, ms=1.5)
ax2.plot(As100, Xs100, linestyle="-", color="red",mec="red", marker="o",  label="$1.2$", lw=0.5, ms=1.5)
ax2.plot(As90, Xs90, linestyle="-", color="blue",mec="blue", marker="p",  label="$1.33$", lw=0.5, ms=1.5)
ax2.plot(As60, Xs60, linestyle="-", color="green", mec="green", marker="D",  label="$2.0$", lw=0.5, ms=1.5)
ax2.axhline(y=2.9596, color='black', linestyle='--', lw=0.5)
legend2 = ax2.legend(frameon=True,loc='upper right', bbox_to_anchor=(0.33, 0.61), fontsize=6, title=r"$a/\sigma$")
legend2.get_frame().set_linestyle("-")
legend2.get_frame().set_edgecolor("navy")


ax2.set_xlabel(r"${U}_{1}/k_{B}T$", fontsize=8,labelpad=3)
ax2.set_ylabel(r"$\chi_{c}$", fontsize=8,labelpad=3)
ax2.tick_params(axis='x', which='major', pad=3, labelsize=8)
ax2.tick_params(axis='y', which='major', pad=3, labelsize=8)
font_size = 14
mpl.rcParams.update({'font.size': font_size})

fig.tight_layout()
ax1.set_xscale("log")
legend.get_frame().set_linestyle("-")
legend.get_frame().set_edgecolor("navy")
ax1.set_xticks(xtick_p, xtick_l)
ax1.tick_params(axis='x', which='major', pad=5)
ax1.tick_params(axis='y', which='major', pad=4)
plt.subplots_adjust(bottom=0.135)
plt.subplots_adjust(left=0.1)
plt.subplots_adjust(top=0.98)
plt.subplots_adjust(right=0.98)

#plt.savefig("fig2n3.pdf", format="PDF")
#plt.savefig("fig2n3_tight.pdf", format="PDF",bbox_inches='tight')
plt.show()
/tmp/ipykernel_34097/2856232453.py:132: UserWarning: This figure includes Axes that are not compatible with tight_layout, so results might be incorrect.
  fig.tight_layout()
/home/abolfazl/pythons/p3104/lib/python3.10/site-packages/IPython/core/pylabtools.py:152: UserWarning: This figure includes Axes that are not compatible with tight_layout, so results might be incorrect.
  fig.canvas.print_figure(bytes_io, **kw)
No description has been provided for this image
In [ ]: