Skip to content

Commit 1961111

Browse files
author
Daniel Ruprecht
committed
beautification of stability plots
1 parent b160fcd commit 1961111

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

examples/fwsw/plot_stability.py

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,17 @@
88
from examples.fwsw.ProblemClass import swfw_scalar
99
import numpy as np
1010

11+
from pylab import rcParams
1112
import matplotlib.pyplot as plt
13+
from subprocess import call
1214

1315
if __name__ == "__main__":
1416

1517
N_s = 100
1618
N_f = 400
1719

1820
lambda_s = 1j*np.linspace(0.0, 2.0, N_s)
19-
lambda_f = 1j*np.linspace(0.0, 8.0, N_f)
21+
lambda_f = 1j*np.linspace(2.0, 8.0, N_f)
2022

2123
pparams = {}
2224
# the following are not used in the computation
@@ -63,15 +65,24 @@
6365
stab[j,i] = stab_fh
6466

6567
###
66-
fig = plt.figure(figsize=(12,12))
68+
rcParams['figure.figsize'] = 2.5, 2.5
69+
fs = 8
70+
fig = plt.figure()
6771
#pcol = plt.pcolor(lambda_s.imag, lambda_f.imag, np.absolute(stab), vmin=0.99, vmax=2.01)
6872
#pcol.set_edgecolor('face')
69-
levels = np.array([0.95, 0.99, 1.01])
70-
CS = plt.contour(lambda_s.imag, lambda_f.imag, np.absolute(stab), levels, colors='k')
71-
plt.clabel(CS, fontsize=9)
72-
plt.plot([0, 4], [0, 4], color='k', linewidth=2.5)
73+
levels = np.array([0.95, 0.99, 1.01, 1.05])
74+
# levels = np.array([1.0])
75+
CS1 = plt.contour(lambda_s.imag, lambda_f.imag, np.absolute(stab), levels, colors='k',linestyles='dashed')
76+
CS2 = plt.contour(lambda_s.imag, lambda_f.imag, np.absolute(stab), [1.0], colors='k')
77+
plt.clabel(CS1, fontsize=fs-2)
78+
plt.clabel(CS2, fontsize=fs-2)
79+
#plt.plot([0, 2], [0, 2], color='k', linewidth=1)
7380
plt.gca().set_xticks([0.0, 1.0, 2.0, 3.0])
81+
plt.gca().tick_params(axis='both', which='both', labelsize=fs)
7482
plt.xlim([np.min(lambda_s.imag), np.max(lambda_s.imag)])
75-
plt.xlabel('$\Delta t \lambda_{slow}$', fontsize=18, labelpad=0.0)
76-
plt.ylabel('$\Delta t \lambda_{fast}$', fontsize=18)
77-
plt.show()
83+
plt.xlabel('$\Delta t \lambda_{slow}$', fontsize=fs, labelpad=0.0)
84+
plt.ylabel('$\Delta t \lambda_{fast}$', fontsize=fs)
85+
filename = 'sdc-fwsw-stability-K'+str(K)+'-M'+str(swparams['num_nodes'])+'.pdf'
86+
fig.savefig(filename, bbox_inches='tight')
87+
call(["pdfcrop", filename, filename])
88+

0 commit comments

Comments
 (0)