2 Python script to create plots from the solution of a
9 import matplotlib.pyplot
as plt
20 if not os.path.exists(plt_dir_name):
21 os.makedirs(plt_dir_name)
26 matplotlib.rc(
'font', **font)
29 for var
in range(a_nvars):
31 fig = plt.figure(figsize=figsize)
33 ax.set( xlim=(np.min(a_x), np.max(a_x)),
34 ylim=(np.min(a_U[var::a_nvars]),
35 np.max(a_U[var::a_nvars]) ) )
36 ax.plot(a_x, a_U[var::a_nvars], lw=2)
37 ax.set_title(
'var {:}, t={:.3}'.format(var,a_time))
38 plt.grid(visible=
True, linestyle=
':', linewidth=1)
40 plt_fname = plt_dir_name+
'/'+a_fname
42 plt_fname = plt_dir_name+
'/var'+f
'{var:02d}'+
'_'+a_fname
43 print(
'Saving %s' % plt_fname)
44 plt.savefig(plt_fname)
47 print(
'Error in plotBinarySolution: unable to generate plot for var %d' % var)
48 print(
'Error in plotBinarySolution: nvars is %d' % a_nvars)
53 matplotlib.rc(
'font', **font)
59 y2d, x2d = np.meshgrid(y, x)
61 for var
in range(a_nvars):
63 fig = plt.figure(figsize=figsize)
65 ax.set( xlim=(np.min(x), np.max(x)),
66 ylim=(np.min(y), np.max(y)) )
67 sol2d = np.transpose(a_U.reshape(a_size[1],a_size[0],a_nvars))
68 plot = ax.pcolor(x2d, y2d, sol2d[var,:,:], cmap=colormap)
69 ax.set_title(
'var {:}, t={:.3}'.format(var,a_time))
70 fig.colorbar(plot, ax=ax)
72 plt_fname = plt_dir_name+
'/'+a_fname
74 plt_fname = plt_dir_name+
'/var'+f
'{var:02d}'+
'_'+a_fname
75 print(
'Saving %s' % plt_fname)
76 plt.savefig(plt_fname)
79 print(
'Error in plotBinarySolution: unable to generate plot for var %d' % var)
80 print(
'Error in plotBinarySolution: nvars is %d' % a_nvars)
84 print(
'plotSolution.py: No plotting implemented for a_ndims=%d', a_ndims)