Spectral Integral Suite in C++
plotter.py
Go to the documentation of this file.
1 #!/usr/bin/python
2 
3 # %%
4 import matplotlib
5 # Then, "ALWAYS use sans-serif fonts"
6 matplotlib.rcParams['font.family'] = "CMU Serif"
7 #matplotlib.rcParams['font.serif'] = "Computer Modern Roman"
8 
9 # %% Example 1
10 import numpy as np
11 import matplotlib.pyplot as plt
12 from pylab import genfromtxt;
13 plt.style.use(['presentation.mplstyle', 'grayscale'])
14 
15 import matplotlib.pyplot as plt
16 plt.style.use(['presentation.mplstyle', 'grayscale'])
17 
18 mat0 = genfromtxt("../data/Ex_01.txt");
19 plt.plot(mat0[:,0], mat0[:,1],"-k",fillstyle="none")
20 plt.xlabel("$y$", fontsize=20)
21 plt.ylabel("$u(y)$", fontsize=20)
22 plt.xticks(fontsize = 18)
23 plt.yticks(fontsize = 18)
24 plt.savefig('../pics/Ex_01.svg', bbox_inches='tight')
25 plt.clf()
26 
27 # %% Example 2
28 import numpy as np
29 import matplotlib.pyplot as plt
30 from pylab import genfromtxt;
31 plt.style.use(['presentation.mplstyle', 'grayscale'])
32 
33 import matplotlib.pyplot as plt
34 plt.style.use(['presentation.mplstyle', 'grayscale'])
35 
36 mat0 = genfromtxt("../data/Ex_02.txt");
37 plt.plot(mat0[:,0], mat0[:,1],"-k",fillstyle="none")
38 plt.xlabel("$y$", fontsize=20)
39 plt.ylabel("$u(y)$", fontsize=20)
40 plt.xticks(fontsize = 18)
41 plt.yticks(fontsize = 18)
42 plt.savefig('../pics/Ex_02.svg', bbox_inches='tight')
43 plt.clf()
44 
45 
46 # %% Example 3
47 #import numpy as np
48 import numpy as np
49 import matplotlib.pyplot as plt
50 from pylab import genfromtxt;
51 plt.style.use(['presentation.mplstyle', 'grayscale'])
52 mat0 = genfromtxt("../data/Ex_03.txt")
53 #print(mat0)
54 lineA = plt.plot(mat0[0:-1:3,0], mat0[0:-1:3,1],"-k",fillstyle="none",markeredgewidth=2)
55 lineB = plt.plot(mat0[0:-1:3,0], mat0[0:-1:3,2],"ok",markeredgewidth = 2)
56 plt.legend(['Analytical','SISC++'],fontsize = 20)
57 plt.xlabel("$y$", fontsize=20)
58 plt.ylabel("$u(y)$", fontsize=20)
59 plt.xticks(fontsize = 18)
60 plt.yticks(fontsize = 18)
61 
62 #plt.show()
63 plt.savefig('../pics/Ex_03.svg', bbox_inches='tight')
64 plt.clf()
65 
66 
67 # %% Example 12:
68 import numpy as np
69 import matplotlib.pyplot as plt
70 from pylab import genfromtxt;
71 plt.style.use(['presentation.mplstyle', 'grayscale'])
72 mat1 = genfromtxt("../data/Ex12.txt")
73 print(mat1)
74 lineA = plt.semilogy(mat1[:,0], mat1[:,1],"-ok",fillstyle="none",markeredgewidth=2,markersize=9)
75 lineB = plt.semilogy(mat1[:,0], mat1[:,2],"-^k",fillstyle="none",markeredgewidth = 2,markersize=9)
76 plt.legend(['$\sigma_0$','$\sigma_1$'],fontsize = 20)
77 plt.xlabel("$\omega$", fontsize=20)
78 #plt.ylabel("$u(y)$", fontsize=20)
79 plt.title('Singular values')
80 plt.xticks(fontsize = 18)
81 plt.yticks(fontsize = 18)
82 #plt.show()
83 plt.savefig('../pics/Ex_12.svg', bbox_inches='tight')
84 plt.clf()
85 # %%
86 import numpy as np
87 import matplotlib.pyplot as plt
88 from matplotlib.font_manager import FontProperties
89 
91 #font.set_family('CMU Serif')
92 #font.set_name('Roman')
93 font.set_file('/Users/gokul/Library/Fonts/cmunbx.ttf')
94 #cmunbx
95 #cmunrm
96 #font.set_weight('Bold')
97 font.set_size(24)
98 #del matplotlib.font_manager.weight_dict['roman']
99 #matplotlib.font_manager._rebuild()
100 from pylab import genfromtxt;
101 plt.style.use(['presentation.mplstyle', 'grayscale'])
102 mat1 = genfromtxt("../data/Ex_12_2.txt")
103 print(mat1)
104 lineA = plt.semilogy(mat1[:,0], mat1[:,1],"-ok",fillstyle="none",markeredgewidth=2,markersize=9)
105 #plt.legend(['$\sigma_0$','$\sigma_1$'],fontsize = 20)
106 plt.xlabel("$\omega$", fontsize=20)
107 #plt.ylabel("$u(y)$", fontsize=20)
108 plt.title('Power spectral density',FontProperties=font)
109 plt.xticks(fontsize = 18)
110 plt.yticks(fontsize = 18)
111 plt.show()
112 #plt.savefig('../pics/Ex_12_2.svg', bbox_inches='tight')
113 #plt.clf()
114 
115 # %%
FontProperties
Definition: plotter.py:108