Skip to content

Commit ed683c7

Browse files
committed
quick hack to do multiple plots
1 parent 18cf5e4 commit ed683c7

File tree

1 file changed

+51
-43
lines changed

1 file changed

+51
-43
lines changed

figures/burgers/characteristics.py

Lines changed: 51 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -20,65 +20,73 @@ def funr(x):
2020
state[x < 0.5] = 0.2
2121
return state
2222

23-
npts_plot = 1000
24-
xplot = np.linspace(0.0, 1.0, npts_plot)
23+
def make_plot(icfun=None, label=""):
2524

26-
nchar = 20
27-
xchar = np.linspace(0.0, 1.0, nchar)
25+
npts_plot = 1000
26+
xplot = np.linspace(0.0, 1.0, npts_plot)
2827

29-
state = funr(xplot)
30-
print(type(state))
28+
nchar = 20
29+
xchar = np.linspace(0.0, 1.0, nchar)
3130

32-
plt.subplot(211)
31+
state = icfun(xplot)
32+
print(type(state))
3333

34-
plt.plot(xplot, state, lw=2)
34+
plt.clf()
3535

36+
plt.subplot(211)
3637

37-
ax = plt.gca()
38-
ax.spines['right'].set_visible(False)
39-
ax.spines['top'].set_visible(False)
40-
ax.spines['right'].set_visible(False)
41-
ax.spines['top'].set_visible(False)
42-
ax.spines['right'].set_visible(False)
43-
ax.spines['top'].set_visible(False)
44-
ax.xaxis.set_ticks_position('bottom')
45-
ax.yaxis.set_ticks_position('left')
38+
plt.plot(xplot, state, lw=2)
4639

47-
plt.ylim(-0.1, 1.1)
4840

49-
plt.xlabel(r"$x$", fontsize="large")
50-
plt.ylabel(r"$u$", fontsize="large")
41+
ax = plt.gca()
42+
ax.spines['right'].set_visible(False)
43+
ax.spines['top'].set_visible(False)
44+
ax.spines['right'].set_visible(False)
45+
ax.spines['top'].set_visible(False)
46+
ax.spines['right'].set_visible(False)
47+
ax.spines['top'].set_visible(False)
48+
ax.xaxis.set_ticks_position('bottom')
49+
ax.yaxis.set_ticks_position('left')
5150

51+
plt.ylim(-0.1, 1.1)
5252

53+
plt.xlabel(r"$x$", fontsize="large")
54+
plt.ylabel(r"$u$", fontsize="large")
5355

54-
plt.subplot(212)
5556

56-
uchar = funr(xchar)
57-
t = np.linspace(0.0, 1.0, 100)
58-
for n in range(nchar):
59-
xc = xchar[n] + uchar[n]*t
60-
plt.plot(xc, t, color="0.5")
6157

62-
ax = plt.gca()
63-
ax.spines['right'].set_visible(False)
64-
ax.spines['top'].set_visible(False)
65-
ax.spines['right'].set_visible(False)
66-
ax.spines['top'].set_visible(False)
67-
ax.spines['right'].set_visible(False)
68-
ax.spines['top'].set_visible(False)
69-
ax.xaxis.set_ticks_position('bottom')
70-
ax.yaxis.set_ticks_position('left')
58+
plt.subplot(212)
7159

72-
plt.xlabel(r"$x$", fontsize="large")
73-
plt.ylabel(r"$t$", fontsize="large")
60+
uchar = icfun(xchar)
61+
t = np.linspace(0.0, 1.0, 100)
62+
for n in range(nchar):
63+
xc = xchar[n] + uchar[n]*t
64+
plt.plot(xc, t, color="0.5")
7465

75-
plt.xlim(0.0, 1.0)
76-
plt.ylim(0.0, 1.1)
66+
ax = plt.gca()
67+
ax.spines['right'].set_visible(False)
68+
ax.spines['top'].set_visible(False)
69+
ax.spines['right'].set_visible(False)
70+
ax.spines['top'].set_visible(False)
71+
ax.spines['right'].set_visible(False)
72+
ax.spines['top'].set_visible(False)
73+
ax.xaxis.set_ticks_position('bottom')
74+
ax.yaxis.set_ticks_position('left')
7775

78-
f = plt.gcf()
79-
f.set_size_inches(6.0, 8.0)
76+
plt.xlabel(r"$x$", fontsize="large")
77+
plt.ylabel(r"$t$", fontsize="large")
8078

81-
plt.tight_layout()
79+
plt.xlim(0.0, 1.0)
80+
plt.ylim(0.0, 1.1)
8281

83-
plt.savefig("burgers-characteristics-rare.pdf")
82+
f = plt.gcf()
83+
f.set_size_inches(6.0, 8.0)
8484

85+
plt.tight_layout()
86+
87+
plt.savefig(f"burgers-characteristics-{label}.png")
88+
89+
if __name__ == "__main__":
90+
91+
make_plot(funr, "rare")
92+
make_plot(funs, "shock")

0 commit comments

Comments
 (0)