forked from python-hydro/pyro2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_tools.py
More file actions
59 lines (48 loc) · 1.76 KB
/
Copy pathplot_tools.py
File metadata and controls
59 lines (48 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
"""Some basic support routines for configuring the plots during
runtime visualization"""
import matplotlib.pyplot as plt
from mpl_toolkits.axes_grid1 import AxesGrid
import math
def setup_axes(myg, num):
""" create a grid of axes whose layout depends on the aspect ratio of the
domain """
L_x = myg.xmax - myg.xmin
L_y = myg.ymax - myg.ymin
f = plt.figure(1)
cbar_title = False
if L_x > 2*L_y:
# we want num rows:
axes = AxesGrid(f, 111,
nrows_ncols=(num, 1),
share_all=True,
cbar_mode="each",
cbar_location="top",
cbar_pad="10%",
cbar_size="25%",
axes_pad=(0.25, 0.65),
add_all=True, label_mode="L")
cbar_title = True
elif L_y > 2*L_x:
# we want num columns: rho |U| p e
axes = AxesGrid(f, 111,
nrows_ncols=(1, num),
share_all=True,
cbar_mode="each",
cbar_location="right",
cbar_pad="10%",
cbar_size="25%",
axes_pad=(0.65, 0.25),
add_all=True, label_mode="L")
else:
# 2-d grid of plots
ny = int(math.sqrt(num))
nx = num//ny
axes = AxesGrid(f, 111,
nrows_ncols=(nx, ny),
share_all=True,
cbar_mode="each",
cbar_location="right",
cbar_pad="2%",
axes_pad=(0.65, 0.25),
add_all=True, label_mode="L")
return f, axes, cbar_title