fix font size

This commit is contained in:
wjsjwr 2020-09-12 22:39:03 +08:00
parent dd8b129a33
commit c6516db0a1
5 changed files with 58 additions and 26 deletions

View File

@ -36,13 +36,19 @@ colors = cm.get_cmap('OrRd')
colors.set_bad('white') colors.set_bad('white')
ax.set_xticklabels(np.arange(1, 46, 11)) ax.set_xticklabels(np.arange(1, 46, 11))
dct = ax.imshow(ndata, cmap=colors, origin='lower')#, norm=colors.LogNorm()) dct = ax.imshow(ndata, cmap=colors, origin='lower')#, norm=colors.LogNorm())
sc = ax.scatter(np.arange(7, 45), np.floor(45 / np.arange(8, 46)), s=20, facecolors='none', edgecolors='black', linewidths=0.75, linestyle='dotted', label='Maximal number of opponents') # sc = ax.scatter(np.arange(7, 45), np.floor(45 / np.arange(8, 46)), s=20, facecolors='none', edgecolors='black', linewidths=0.75, linestyle='dotted', label='Maximal number of opponents')
plt.legend() # ax.scatter(np.arange(0, 7), [5]*7, s=20, facecolors='none', edgecolors='black', linewidths=0.75, linestyle='dotted')
# for i in range(0,7):
# print(f"{i}: {floor(45/(i+1))}\n")
# plt.legend()
# ax2 = ax.twinx() # ax2 = ax.twinx()
# ax2.set_ylabel("Maximal Number of opponents") # ax2.set_ylabel("Maximal Number of opponents")
ax.set_xlabel("Decision time") ax.set_xlabel("Average Decision time", fontsize=11)
ax.set_ylabel("Number of partners") ax.set_ylabel("Number of partners", fontsize=11)
fig.colorbar(dct, ax=ax, orientation='horizontal', aspect=40) ax.tick_params(labelsize=10)
ax.reset_position()
fig.set_size_inches(6,5)
fig.colorbar(dct, ax=ax, orientation='horizontal', aspect=30, shrink=1)
# plt.show() # plt.show()
# print(plt.rcParams) # print(plt.rcParams)

View File

@ -10,22 +10,22 @@ red = '#d63031'
def error(f,x,y): def error(f,x,y):
return sp.sum((f(x)-y)**2) return sp.sum((f(x)-y)**2)
def p1(x, coopr, e, postfix, show=True): def p1(x, coopr, e, postfix, show=True):
fig = plt.figure(figsize=(4.5, 3)) fig = plt.figure(figsize=(3, 2))
ax = fig.gca() ax = fig.gca()
ax.plot(x, coopr, color=blue, linewidth=2, label="$f_c$") ax.plot(x, coopr, color=blue, linewidth=2, label=r"f$_{\rm c}$")
ax.set_ylim(0, 1) ax.set_ylim(0, 1)
ax.set_yticks(sp.linspace(0, 1, 5)) ax.set_yticks(sp.linspace(0, 1, 5))
ax2 = ax.twinx() ax2 = ax.twinx()
ax2.plot(x[:-1], e[:-1], color=red, linewidth=2, label=r"$\theta$") ax2.plot(x[:-1], e[:-1], color=red, linewidth=2, label=r"${\rm \theta}$")
ax2.set_ylim(-1500, 200) ax2.set_ylim(-1500, 200)
ax2.set_yticks(sp.linspace(-1500, 200, 5)) ax2.set_yticks(sp.linspace(-1500, 200, 5))
ax2.tick_params(labelsize=14) ax2.tick_params(labelsize=10)
ax.tick_params(labelsize=14) ax.tick_params(labelsize=10)
ax.set_xlim(1, 15) ax.set_xlim(1, 15)
ax.set_xlabel("Rounds", size=22) ax.set_xlabel("Rounds", size=11)
ax.set_ylabel(r"$f_c$", family='sans-serif', color=blue, size=22) ax.set_ylabel(r"f$_{\rm c}$", color=blue, size=11)
ax.tick_params(axis='y', labelcolor=blue) ax.tick_params(axis='y', labelcolor=blue)
ax2.set_ylabel(r"$\theta$", family='sans-serif', color=red, size=22) ax2.set_ylabel(r"${\rm \theta}$", color=red, size=11)
ax2.tick_params(axis='y', labelcolor=red) ax2.tick_params(axis='y', labelcolor=red)
ax.tick_params(direction='in') ax.tick_params(direction='in')
ax2.tick_params(direction='in') ax2.tick_params(direction='in')
@ -38,7 +38,7 @@ def p1(x, coopr, e, postfix, show=True):
def p2(e, coopr, postfix, show=True, showline=True): def p2(e, coopr, postfix, show=True, showline=True):
# p2散点图 # p2散点图
fig = plt.figure(figsize=(4, 3)) fig = plt.figure(figsize=(3, 2))
ax = fig.gca() ax = fig.gca()
if showline: if showline:
fp1,residuals,rank,sv,rcond = sp.polyfit(e, coopr, 1, full=True) fp1,residuals,rank,sv,rcond = sp.polyfit(e, coopr, 1, full=True)
@ -51,11 +51,11 @@ def p2(e, coopr, postfix, show=True, showline=True):
plt.plot(fx,f1(fx),linewidth=2,color=red, ls='--', zorder=0) plt.plot(fx,f1(fx),linewidth=2,color=red, ls='--', zorder=0)
plt.scatter(e, coopr, color='white', edgecolors=blue, linewidths=2, zorder=101) plt.scatter(e, coopr, color='white', edgecolors=blue, linewidths=2, zorder=101)
ax.set_xlabel(r'$\theta$', family='sans-serif', size=20) ax.set_xlabel(r"${\rm \theta}$", size=12)
ax.set_ylabel(r'$f_{c}$', family='sans-serif', size=20) ax.set_ylabel(r"f$_{\rm c}$", size=12)
# ax.set_xlim(0, 1440) # ax.set_xlim(0, 1440)
# ax.set_xticks(sp.linspace(int(min(e)*0.9), int(max(e)*1.1), 4)) # ax.set_xticks(sp.linspace(int(min(e)*0.9), int(max(e)*1.1), 4))
ax.tick_params(labelsize=14) ax.tick_params(labelsize=10)
ax.set_ylim(0.6, 1) ax.set_ylim(0.6, 1)
ax.set_yticks(sp.linspace(0.6, 1, 5)) ax.set_yticks(sp.linspace(0.6, 1, 5))
ax.tick_params(direction='in') ax.tick_params(direction='in')

View File

@ -8,22 +8,31 @@ import json
import random import random
blue = '#0984e3' blue = '#0984e3'
red = '#d63031' red = '#d63031'
green = '#227D51'
sim = [0.79844266, 0.8377947, 0.87015217, 0.91429971, 0.94337877, 0.89212607, 0.99805755, 0.98048562, 0.98530593, 0.99598291, 0.87856398, 0.99217795, 0.62392839, 0.99253731, 0.99703892]
ana = [0.8, 0.8290884722222223, 0.8581769444444445, 0.8872654166666667, 0.9163538888888889, 0.9454423611111111, 0.9745308333333333, 1.0, 1.0, 1.0, 1.0, 1.0, 0.5, 1.0, 1.0]
def p1(x, coopr, crawx, crawy, postfix, show=True): def p1(x, coopr, crawx, crawy, postfix, show=True):
fig = plt.figure(figsize=(4.5, 2.5)) fig = plt.figure(figsize=(4.5, 1.8))
ax = fig.gca() ax = fig.gca()
ax.plot(x, coopr, marker='o', linestyle='dotted', color=blue, linewidth=2, label="$f_c$") if postfix == 'SURVIVE':
ax.scatter(crawx, crawy, s=15, c='dimgray', marker='x', linewidth=0.5) ax.plot(x, sim, marker='s', linestyle='dotted', markerfacecolor='none', color=red, linewidth=2, label="Simulation")
ax.set_ylim(0, 1) ax.plot(x, ana, marker='^', linestyle='dotted', markerfacecolor='none', color=green, linewidth=2, label="Analytical")
ax.plot(x, coopr, marker='o', linestyle='dotted', markerfacecolor='none', color=blue, linewidth=2, label="Human")
ax.scatter(crawx, crawy, s=15, c='dimgray', marker='x', linewidth=0.5, alpha=0.4)
ax.set_ylim(-0.05, 1.05)
ax.set_yticks(sp.linspace(0, 1, 5)) ax.set_yticks(sp.linspace(0, 1, 5))
ax.tick_params(labelsize=10) ax.tick_params(labelsize=10)
ax.tick_params(direction='in') ax.tick_params(direction='in')
ax.set_xlim(0, 16) ax.set_xlim(0, 16)
ax.set_xticks([1, 5, 10, 15]) ax.set_xticks([1, 5, 10, 15])
# ax.set_xticklabels(['']) # ax.set_xticklabels([''])
ax.set_xlabel("Rounds", size=14) ax.set_xlabel("Rounds", size=11)
ax.set_ylabel(r"$f_c$", family='sans-serif', size=14) ax.set_ylabel(r"f$_{\rm c}$", size=11, fontstyle='normal')
ax.yaxis.grid(True, linestyle='--') ax.yaxis.grid(True, linestyle='--')
# if postfix == 'SURVIVE':
# ax.legend(loc='best', fontsize=10, ncol=3)
plt.tight_layout() plt.tight_layout()
if show: if show:

View File

@ -75,17 +75,20 @@ if __name__ == '__main__':
hdl2 = pch.Patch(facecolor=vp2['bodies'][0].get_facecolor()[0]) hdl2 = pch.Patch(facecolor=vp2['bodies'][0].get_facecolor()[0])
vp1['cmeans'].set_edgecolor(black) vp1['cmeans'].set_edgecolor(black)
vp1['cmeans'].set_linestyle(':') vp1['cmeans'].set_linestyle(':')
vp1['cmedians'].set_linestyle('dashed')
vp2['cmeans'].set_edgecolor(black) vp2['cmeans'].set_edgecolor(black)
vp2['cmeans'].set_linestyle(':') vp2['cmeans'].set_linestyle(':')
ax.set_ylabel('Distribution of Food Loss') vp2['cmedians'].set_linestyle('dashed')
ax.set_ylabel('Distribution of the Payoff Loss', fontsize=11)
ax.yaxis.grid(True, linestyle='--') ax.yaxis.grid(True, linestyle='--')
# ax.set_title('Scores by group and gender') # ax.set_title('Scores by group and gender')
ax.set_xticks(index) ax.set_xticks(index)
ax.set_xticklabels(['C', 'D']) ax.set_xticklabels(['C', 'D'])
ax.set_ylim(-6, 6) ax.set_ylim(-6, 6)
ax.set_xlabel("Previous Move") ax.tick_params(labelsize=10)
ax.set_xlabel("Previous Move", fontsize=11)
ax.tick_params(direction='in') ax.tick_params(direction='in')
ax.legend([hdl1, hdl2], labels, ncol=2) ax.legend([hdl1, hdl2], labels, ncol=2, fontsize=10)
fig.tight_layout() fig.tight_layout()
# plt.show() # plt.show()

14
sanitize.py Normal file
View File

@ -0,0 +1,14 @@
import json
import os.path
with open('profile.csv') as fp:
for l in fp:
fn = l.split(',')[0]
with open(fn, encoding='utf-8') as js:
data = []
for item in json.load(js):
if item['cat'] != 'chat':
data.append(item)
with open(os.path.join('wos-data-sanitized', os.path.basename(fn)), 'w') as out:
json.dump(data, out)
print("Finish: ", fn)