-
Klaus Böhnlein authoredKlaus Böhnlein authored
PerforatedBilayer_square_parameterDependence.py 5.79 KiB
import numpy as np
import matplotlib.pyplot as plt
import math
import os
import subprocess
import fileinput
import re
import sys
import matplotlib as mpl
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.cm as cm
import matplotlib.ticker as ticker
from matplotlib.ticker import MultipleLocator,FormatStrFormatter,MaxNLocator
import seaborn as sns
import matplotlib.colors as mcolors
import codecs
import json
# ----------------------------------------------------
# --- Define Plot style:
# plt.style.use("seaborn-white")
# plt.style.use("seaborn-pastel")
# plt.style.use("seaborn-colorblind")
plt.style.use("seaborn")
mpl.rcParams['text.usetex'] = True
mpl.rcParams["font.family"] = "serif"
mpl.rcParams["font.size"] = "8"
mpl.rcParams['xtick.bottom'] = True
mpl.rcParams['xtick.major.size'] = 3
mpl.rcParams['xtick.minor.size'] = 1.5
mpl.rcParams['xtick.major.width'] = 0.75
mpl.rcParams['xtick.labelsize'] = 8
mpl.rcParams['xtick.major.pad'] = 1
mpl.rcParams['ytick.left'] = True
mpl.rcParams['ytick.major.size'] = 3
mpl.rcParams['ytick.minor.size'] = 1.5
mpl.rcParams['ytick.major.width'] = 0.75
mpl.rcParams['ytick.labelsize'] = 8
mpl.rcParams['ytick.major.pad'] = 1
mpl.rcParams['axes.titlesize'] = 8
mpl.rcParams['axes.titlepad'] = 1
mpl.rcParams['axes.labelsize'] = 8
#Adjust Legend:
mpl.rcParams['legend.frameon'] = True # Use frame for legend
# mpl.rcParams['legend.framealpha'] = 0.5
mpl.rcParams['legend.fontsize'] = 8 # fontsize of legend
#Adjust grid:
mpl.rcParams.update({"axes.grid" : True}) # Add grid
mpl.rcParams['axes.labelpad'] = 3
mpl.rcParams['grid.linewidth'] = 0.25
mpl.rcParams['grid.alpha'] = 0.9 # 0.75
mpl.rcParams['grid.linestyle'] = '-'
mpl.rcParams['grid.color'] = 'gray'#'black'
mpl.rcParams['text.latex.preamble'] = r'\usepackage{amsfonts}' # Makes Use of \mathbb possible.
# ----------------------------------------------------------------------------------------
textwidth = 6.26894 #textwidth in inch
width = textwidth * 0.5
height = width / 1.618 # The golden ratio.
dataset_numbers = [0, 1, 2, 3, 4 ,5]
for dataset_number in dataset_numbers:
# fig, ax = plt.subplots(figsize=(width,height))
fig, ax = plt.subplots()
fig.subplots_adjust(left=.15, bottom=.15, right=.95, top=.92)
# ax.xaxis.set_major_locator(MultipleLocator(1.0))
# ax.xaxis.set_minor_locator(MultipleLocator(0.5))
ax.xaxis.set_major_locator(MultipleLocator(0.05))
ax.xaxis.set_minor_locator(MultipleLocator(0.025))
Path_KappaUpper = './experiment/perforated-bilayer_square/results_upper_' + str(dataset_number) + '/kappa_simulation.txt'
Path_KappaLower = './experiment/perforated-bilayer_square/results_lower_' + str(dataset_number) + '/kappa_simulation.txt'
kappa_sim_upper = open(Path_KappaUpper).read().split(",")
kappa_sim_lower = open(Path_KappaLower).read().split(",")
kappa_sim_upper = [float(i) for i in kappa_sim_upper]
kappa_sim_lower = [float(i) for i in kappa_sim_lower]
input = [0 , 0.05, 0.10, 0.15, 0.20, 0.25, 0.30] # Design parameter (volume ratio)
# --------------- Plot Lines + Scatter -----------------------
line_1 = ax.plot(input, kappa_sim_upper, # data
# color='forestgreen', # linecolor
marker='D', # each marker will be rendered as a circle
markersize=3.5, # marker size
# markerfacecolor='darkorange', # marker facecolor
markeredgecolor='black', # marker edgecolor
markeredgewidth=0.5, # marker edge width
# linestyle='dashdot', # line style will be dash line
linewidth=1.0, # line width
zorder=3,
label = r"$\kappa_{sim}$ (passive perf.)")
line_2 = ax.plot(input, kappa_sim_lower, # data
# color='orangered', # linecolor
marker='o', # each marker will be rendered as a circle
markersize=3.5, # marker size
# markerfacecolor='cornflowerblue', # marker facecolor
markeredgecolor='black', # marker edgecolor
markeredgewidth=0.5, # marker edge width
# linestyle='--', # line style will be dash line
linewidth=1.0, # line width
zorder=3,
alpha=0.8, # Change opacity
label = r"$\kappa_{sim}$ (active perf.)")
# --------------- Set Axes -----------------------
# Plot - Title
match dataset_number:
case 0:
ax.set_title(r"Thickness ratio $r = 0.12$")
case 1:
ax.set_title(r"Thickness ratio $r = 0.17$")
case 2:
ax.set_title(r"Thickness ratio $r = 0.22$")
case 3:
ax.set_title(r"Thickness ratio $r = 0.34$")
case 4:
ax.set_title(r"Thickness ratio $r = 0.43$")
case 5:
ax.set_title(r"Thickness ratio $r = 0.49$")
# ax.set_xlabel(r"Volume ratio ", labelpad=4)
# ax.set_ylabel(r"Curvature $\kappa$", labelpad=4)
ax.set_xlabel(r"Volume ratio ")
ax.set_ylabel(r"Curvature $\kappa$")
# --- Set Legend
# legend = ax.legend(fontsize=8)
legend = ax.legend()
frame = legend.get_frame()
frame.set_edgecolor('black')
frame.set_linewidth(0.5)
# --- Adjust left/right spacing:
# plt.subplots_adjust(right=0.81)
# plt.subplots_adjust(left=0.11)
# ---------- Output Figure as pdf:
fig.set_size_inches(width, height)
fig.savefig('PerforatedBilayer_square_dependence_' + str(dataset_number) + '.pdf')
# plt.show()