-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_plot.py
More file actions
115 lines (97 loc) · 3.08 KB
/
setup_plot.py
File metadata and controls
115 lines (97 loc) · 3.08 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import matplotlib.pyplot as plt
from matplotlib import font_manager as fm
from matplotlib.pyplot import gca
import matplotlib as mpl
from cycler import cycler
import math
linestyle_tuple = [
("solid", "solid"), # Same as (0, ()) or '-'
("dotted", "dotted"), # Same as (0, (1, 1)) or '.'
("dashed", "dashed"), # Same as '--'
("dashdot", "dashdot"),
("loosely dotted", (0, (1, 10))),
("dotted", (0, (1, 1))),
("densely dotted", (0, (1, 1))),
("loosely dashed", (0, (5, 10))),
("dashed", (0, (5, 5))),
("densely dashed", (0, (5, 1))),
("loosely dashdotted", (0, (3, 10, 1, 10))),
("dashdotted", (0, (3, 5, 1, 5))),
("densely dashdotted", (0, (3, 1, 1, 1))),
("dashdotdotted", (0, (3, 5, 1, 5, 1, 5))),
("loosely dashdotdotted", (0, (3, 10, 1, 10, 1, 10))),
("densely dashdotdotted", (0, (3, 1, 1, 1, 1, 1))),
]
linestyle_dict = {k: v for k, v in linestyle_tuple}
def setup_global():
font_entry = fm.FontEntry(
fname="/pscratch/sd/o/ocankur/dask/perlmutter-omni-analysis/sc24_scripts/ldms-analysis-scripts/dask_scripts/march_analysis/pssg-plots/gillsans.ttf",
name="gill-sans",
)
# set font
fm.fontManager.ttflist.insert(0, font_entry)
mpl.rcParams["font.family"] = font_entry.name
mpl.use("Agg")
mpl.rcParams["axes.spines.right"] = False
mpl.rcParams["axes.spines.top"] = False
mpl.rcParams["font.size"] = 18
# mpl.rcParams["font.size"] = 14
mpl.rcParams["lines.linewidth"] = 2
mpl.rcParams["lines.markersize"] = 8
mpl.rcParams.update({"legend.labelspacing": 0.1})
def setup_local():
plt.clf()
gca().yaxis.grid(linestyle="dashed")
gca().spines["left"].set_color("#606060")
gca().spines["bottom"].set_color("#606060")
global_cycler = cycler(color=get_colors()) + cycler(linestyle=get_linestyles())
gca().set_prop_cycle(global_cycler)
def set_aspect_ratio(ratio=3 / 5, logx=None, logy=None):
xleft, xright = gca().get_xlim()
print("xleft: ", xleft)
print("xright: ", xright)
if logx is not None:
xleft = math.log(xleft, logx)
xright = math.log(xright, logx)
ybottom, ytop = gca().get_ylim()
print("ybottom: ", ybottom)
print("ytop: ", ytop)
if logy is not None:
ytop = math.log(ytop, logy)
ybottom = math.log(ybottom, logy)
gca().set_aspect(abs((xright - xleft) / (ybottom - ytop)) * ratio)
def get_colors():
return [
"#D55E00",
"#009E73",
"#0072B2",
"#CC79A7",
"#000000",
"#E03A3D",
"#0072B2",
"#CC79A7",
]
def get_hatches():
return ["xxx", "xxxxxx", "\\\\\\\\", "-", "/", "+"]
def get_linestyles():
return [
linestyle_dict["solid"],
linestyle_dict["dotted"],
linestyle_dict["dashed"],
linestyle_dict["dashdotted"],
linestyle_dict["dashdotdotted"],
linestyle_dict["solid"],
linestyle_dict["dotted"],
linestyle_dict["dashed"],
]
def get_markers():
return [
"^",
"s",
"o",
"d",
"x",
"o",
"d",
"s",
]