import numpy as np from matplotlib import pyplot as plt import scipy as sp from scipy.stats import pearsonr from matplotlib import markers from sys import argv blue = '#0984e3' red = '#d63031' def p1(x, coopr, postfix, show=True): fig = plt.figure(figsize=(4.5, 2)) ax = fig.gca() ax.plot(x, coopr, 'o-', color=blue, linewidth=2, label="$f_c$") ax.set_ylim(0.5, 1) ax.set_yticks(sp.linspace(0.5, 1, 5)) ax.tick_params(labelsize=18) ax.tick_params(direction='in') ax.set_xlim(0, 16) # ax.set_xticklabels(['']) ax.set_xlabel("Rounds", size=22) ax.set_ylabel(r"$f_c$", family='sans-serif', size=22) ax.yaxis.grid(True, linestyle='--') plt.tight_layout() if show: plt.show() else: plt.savefig("graph/fc_plot_%s.eps" % postfix) def plot(mode, show): coopr = np.loadtxt("outputs/CR_%s.csv" % mode, delimiter=',') x = np.arange(1, 16) p1(x, coopr, mode, show) if __name__ == '__main__': # fc_plot c/s t/f mode = 'CLASSIC' if argv[1] == 'c' else 'SURVIVE' show = argv[2] == 't' plot(mode, show)