|
1 | 1 | import numpy as np |
2 | 2 | import math |
3 | 3 | import os |
4 | | -from matplotlib import rc |
5 | 4 | import matplotlib.pyplot as plt |
| 5 | +from pylab import rcParams |
6 | 6 |
|
| 7 | +axis_font = {'fontname':'Arial', 'size':'8', 'family':'serif'} |
| 8 | +fs = 8 |
| 9 | +ms = 8 |
| 10 | +lw = 2 |
7 | 11 |
|
8 | 12 | if __name__ == "__main__": |
9 | 13 |
|
10 | | - rc('font', family='sans-serif',size=30) |
11 | | - rc('legend', fontsize='small') |
12 | | - rc('xtick', labelsize='small') |
13 | | - rc('ytick', labelsize='small') |
14 | | - |
15 | 14 | # ref = 'PFASST_GRAYSCOTT_stats_hf_NOFAULT_new.npz' |
16 | 15 | ref = 'PFASST_GRAYSCOTT_stats_hf_SPREAD_P32.npz' |
17 | 16 |
|
|
25 | 24 |
|
26 | 25 | xtick_dist = 16 |
27 | 26 |
|
28 | | - lw = 2 |
29 | | - |
30 | 27 | minstep = 288 |
31 | 28 | maxstep = 384 |
32 | 29 | # minstep = 0 |
|
52 | 49 | data = np.load(ref) |
53 | 50 | ref_iter_count = data['iter_count'][minstep:maxstep] |
54 | 51 |
|
55 | | - fig, ax = plt.subplots(figsize=(20,7)) |
56 | | - |
57 | | - |
| 52 | + rcParams['figure.figsize'] = 6.0, 2.5 |
| 53 | + fig, ax = plt.subplots() |
58 | 54 |
|
59 | 55 | plt.plot(range(minstep,maxstep),[0]*nsteps,'k-',linewidth=2) |
60 | 56 |
|
|
69 | 65 | ymin = min(ymin,min(ref_iter_count-iter_count)) |
70 | 66 | ymax = max(ymax,max(ref_iter_count-iter_count)) |
71 | 67 |
|
72 | | - plt.plot(range(minstep,maxstep),ref_iter_count-iter_count,color=color,label=label,marker=marker,linestyle='',linewidth=lw,markersize=12) |
| 68 | + plt.plot(range(minstep,maxstep),ref_iter_count-iter_count,color=color,label=label,marker=marker,linestyle='',linewidth=lw,markersize=ms) |
73 | 69 |
|
74 | 70 |
|
75 | | - plt.xlabel('step') |
76 | | - plt.ylabel('saved iterations') |
| 71 | + plt.xlabel('step', **axis_font) |
| 72 | + plt.ylabel('saved iterations', **axis_font) |
77 | 73 | plt.xlim(-1+minstep,maxstep+1) |
78 | 74 | plt.ylim(-1+ymin,ymax+1) |
79 | 75 | ax.set_xticks(np.arange(minstep,maxstep,xtick_dist)+0.5, minor=False) |
80 | 76 | ax.set_xticklabels(np.arange(minstep,maxstep,xtick_dist), minor=False) |
81 | | - plt.legend(loc=2,numpoints=1) |
82 | | - |
| 77 | + plt.legend(loc=2,numpoints=1,fontsize=fs) |
| 78 | + plt.tick_params(axis='both', which='major', labelsize=fs) |
| 79 | + ax.xaxis.labelpad = -0.5 |
| 80 | + ax.yaxis.labelpad = -1 |
83 | 81 | plt.tight_layout() |
84 | 82 |
|
85 | 83 | # fname = 'GRAYSCOTT_saved_iteration_vs_NOFAULT_hf.png' |
86 | | - fname = 'GRAYSCOTT_saved_iteration_vs_SPREAD_hf.png' |
87 | | - plt.savefig(fname, rasterized=True, transparent=True, bbox_inches='tight') |
| 84 | + fname = 'GRAYSCOTT_saved_iteration_vs_SPREAD_hf.pdf' |
| 85 | + plt.savefig(fname, bbox_inches='tight') |
| 86 | + os.system('pdfcrop '+fname+' '+fname) |
88 | 87 |
|
89 | 88 | for file,strategy,label,color,marker in list: |
90 | 89 |
|
|
96 | 95 |
|
97 | 96 | residual = np.where(residual > 0, np.log10(residual), -99) |
98 | 97 |
|
99 | | - fig, ax = plt.subplots(figsize=(20,7)) |
| 98 | + rcParams['figure.figsize'] = 6.0, 2.5 |
| 99 | + fig, ax = plt.subplots() |
100 | 100 |
|
101 | 101 | cmap = plt.get_cmap('Reds',vmax-vmin+1) |
102 | | - plt.pcolor(residual,cmap=cmap,vmin=vmin,vmax=vmax) |
| 102 | + pcol = plt.pcolor(residual,cmap=cmap,vmin=vmin,vmax=vmax) |
| 103 | + pcol.set_edgecolor('face') |
103 | 104 |
|
104 | 105 | if not "NOFAULT" in strategy: |
105 | 106 | for item in stats: |
|
110 | 111 |
|
111 | 112 | ticks = np.arange(vmin,vmax+1,2) |
112 | 113 | tickpos = np.linspace(ticks[0]+0.5, ticks[-1]-0.5, len(ticks)) |
113 | | - cax = plt.colorbar(ticks=tickpos) |
| 114 | + cax = plt.colorbar(pcol, ticks=tickpos, pad=0.02) |
114 | 115 | cax.set_ticklabels(ticks) |
115 | | - cax.set_label('log10(residual)') |
| 116 | + cax.ax.tick_params(labelsize=fs) |
| 117 | + |
| 118 | + cax.set_label('log10(residual)', **axis_font) |
| 119 | + plt.tick_params(axis='both', which='major', labelsize=fs) |
| 120 | + ax.xaxis.labelpad = -0.5 |
| 121 | + ax.yaxis.labelpad = -0.5 |
116 | 122 |
|
117 | | - ax.set_xlabel('step') |
118 | | - ax.set_ylabel('iteration') |
| 123 | + ax.set_xlabel('step', **axis_font) |
| 124 | + ax.set_ylabel('iteration', **axis_font) |
119 | 125 |
|
120 | 126 | ax.set_yticks(np.arange(1,maxiter,2)+0.5, minor=False) |
121 | 127 | ax.set_xticks(np.arange(0,nsteps,xtick_dist)+0.5, minor=False) |
|
124 | 130 |
|
125 | 131 | plt.tight_layout() |
126 | 132 |
|
127 | | - fname = 'GRAYSCOTT_steps_vs_iteration_hf_'+strategy+'.png' |
128 | | - plt.savefig(fname, rasterized=True, transparent=True, bbox_inches='tight') |
| 133 | + fname = 'GRAYSCOTT_steps_vs_iteration_hf_'+strategy+'.pdf' |
| 134 | + plt.savefig(fname, bbox_inches='tight') |
| 135 | + os.system('pdfcrop '+fname+' '+fname) |
129 | 136 |
|
130 | 137 | # exit() |
131 | 138 |
|
|
0 commit comments