Bar plot
A bar plot representing the memory consumption of three algorithms over different problems.
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
%%% Full, compilable sources including data files are on Github:
%%% https://github.com/bvieuble/TeXFantasy/tree/main/bars/fig1
%%% Appears in my article ``Combining sparse approximate factorizations with
%%% mixed precision iterative refinement''.
% Compiled with XeLaTeX
% TeX-command-extra-options: "-shell-escape"
\documentclass[convert={outext=.png},border=10pt]{standalone}
\usepackage{tikz}
\usepackage{pgfplots, pgfplotstable, pgfplotstablefilter}
\pgfplotsset{compat=newest}
\input{color_theme.tex}
% Reinit stacked bar command
\makeatletter
\newcommand\resetstackedplots{
\makeatletter
\pgfplots@stacked@isfirstplottrue
\makeatother
}
% Load data and make groups of plots
\pgfplotstableread[col sep=comma]{data.csv}{\data}
\pgfplotstablefilter[group equals 1]{\data}{\groupa}
\pgfplotstablefilter[group equals 2]{\data}{\groupb}
\pgfplotstablefilter[group equals 3]{\data}{\groupc}
% Get the number of elements in each group
\pgfplotstablegetrowsof{\groupa}
\pgfmathsetmacro{\nbrowsa}{\pgfplotsretval}
\pgfplotstablegetrowsof{\groupb}
\pgfmathsetmacro{\nbrowsb}{\pgfplotsretval}
\pgfplotstablegetrowsof{\groupc}
\pgfmathsetmacro{\nbrowsc}{\pgfplotsretval}
\begin{document}
\begin{tikzpicture}
\begin{axis}
[
point meta=explicit symbolic,
nodes near coords,
every node near coord/.append style={font=\normalsize,above},
legend style={at={(0.75,0.95)},
anchor=north,legend columns=-1},
ybar stacked,
ymajorgrids,
width=1.1\linewidth,
height=0.5\linewidth,
ylabel={\normalsize Normalized memory by DMUMPS},
axis lines=left,
x tick label style={font=\normalsize},
x tick style={thick},
xmin=-0.5,
xmax=\nbrowsa-0.5,
xtick=data,
xticklabels from table={\groupa}{name},
xticklabel style={font=\normalsize},
every extra x tick/.style={tick style={draw=none},
xticklabel style={font=\normalsize}
},
ymin=0,
ymax=1.6,
ytick={0, 0.25, 0.5, 0.75, 1, 2},
yticklabels={0, 0.25, 0.5, 0.75, 1, 2},
name=axis1,
at={(0,0)}
]
\pgfplotsinvokeforeach{0,...,\nbrowsa-1}
{
\node at (axis cs:#1-0.25,0.1) [circle,scale=0.75,draw=none,
fill=blue!0,inner sep=1pt] {D};
\node at (axis cs:#1,0.1) [circle,scale=0.75,draw=none,fill=blue!0,
inner sep=1pt] {E};
\node at (axis cs:#1+0.25,0.1) [circle,scale=0.75,draw=none,
fill=blue!0,inner sep=1pt] {C};
}
\addplot [fill=myblue-mild,bar width=0.1,
bar shift=-0.05,draw=none,forget plot]
table[x expr=\coordindex, y=factorss] {\groupa};
\addplot [fill=myred-mild,bar width=0.1,
bar shift=-0.05,draw=none,forget plot]
table[x expr=\coordindex, y=actives] {\groupa};
\resetstackedplots
\addplot [fill=myblue-mild,bar width=0.1,
bar shift=0.05,draw=none,forget plot]
table[x expr=\coordindex, y=factorsd] {\groupa};
\addplot [fill=mygreen-mild,bar width=0.1,
bar shift=0.05,draw=none]
table[x expr=\coordindex, y=krylov] {\groupa};
\addplot [fill=mygreen-mild,bar width=0.1,
bar shift=0.05,draw=none,forget plot]
table[x expr=\coordindex, y=aq,meta=max-kry] {\groupa};
\resetstackedplots
\addplot [fill=myblue-mild,bar width=0.2,draw=none,forget plot,
bar shift=-0.25]
table[x expr=\coordindex,y=factorss] {\groupa};
\addplot [fill=mygreen-mild,bar width=0.1,draw=none,forget plot,
bar shift=-0.2]
table[x expr=\coordindex,y=aq] {\groupa};
\resetstackedplots
\addplot [fill=myblue-mild,bar width=0.2,draw=none,forget plot,
bar shift=-0.25]
table[x expr=\coordindex,y=factorss] {\groupa};
\addplot [fill=myred-mild,bar width=0.1,
bar shift=-0.3,draw=none,forget plot]
table[x expr=\coordindex,y=actives] {\groupa};
\resetstackedplots
\addplot [fill=myblue-mild,bar width=0.2,draw=none,
bar shift=0.25]
table[x expr=\coordindex,y=factorsd] {\groupa};
\addplot [fill=myred-mild,bar width=0.1,draw=none,
bar shift=0.2]
table[x expr=\coordindex,y=actived] {\groupa};
\resetstackedplots
\addplot [fill=myblue-mild,bar width=0.2,draw=none,forget plot,
bar shift=0.25]
table[x expr=\coordindex,y=factorsd] {\groupa};
\addplot [fill=mygreen-mild,bar width=0.1,draw=none,
bar shift=0.3]
table[x expr=\coordindex,y=aq] {\groupa};
\legend{Krylov, Factors, Active, $A_q$}
\end{axis}
\begin{axis}
[
point meta=explicit symbolic,
nodes near coords,
legend style={at={(0.8,0.95)},
anchor=north,legend columns=-1},
every node near coord/.append style={font=\normalsize,above},
ybar stacked,
ymajorgrids,
width=1.1\linewidth,
height=0.5\linewidth,
ylabel={\normalsize Normalized memory by DMUMPS},
axis lines=left,
x tick label style={font=\normalsize},
x tick style={thick},
xmin=-0.5,
xmax=\nbrowsb-0.5,
xtick=data,
xticklabels from table={\groupb}{name},
xticklabel style={font=\normalsize},
ymin=0,
ymax=1.6,
ytick={0, 0.25, 0.5, 0.75, 1, 2},
yticklabels={0, 0.25, 0.5, 0.75, 1, 2},
name=axis2,
at={(0,-0.45\linewidth)}
]
\pgfplotsinvokeforeach{0,...,\nbrowsb-1} {
\node at (axis cs:#1-0.25,0.1) [circle,scale=0.75,draw=none,
fill=blue!0,inner sep=1pt] {D};
\node at (axis cs:#1,0.1) [circle,scale=0.75,draw=none,fill=blue!0,
inner sep=1pt] {E};
\node at (axis cs:#1+0.25,0.1) [circle,scale=0.75,draw=none,
fill=blue!0,inner sep=1pt] {C};
}
\addplot [fill=myblue-mild,bar width=0.1,
bar shift=-0.05,draw=none,forget plot]
table[x expr=\coordindex, y=factorss] {\groupb};
\addplot [fill=myred-mild,bar width=0.1,
bar shift=-0.05,draw=none,forget plot]
table[x expr=\coordindex, y=actives] {\groupb};
\resetstackedplots
\addplot [fill=myblue-mild,bar width=0.1,
bar shift=0.05,draw=none,forget plot]
table[x expr=\coordindex, y=factorsd] {\groupb};
\addplot [fill=mygreen-mild,bar width=0.1,
bar shift=0.05,draw=none,forget plot]
table[x expr=\coordindex, y=krylov] {\groupb};
\addplot [fill=mygreen-mild,bar width=0.1,
bar shift=0.05,draw=none,forget plot]
table[x expr=\coordindex, y=aq, meta=max-kry] {\groupb};
\resetstackedplots
\addplot [fill=myblue-mild,bar width=0.2,draw=none,forget plot,
bar shift=-0.25]
table[x expr=\coordindex,y=factorss] {\groupb};
\addplot [fill=mygreen-mild,bar width=0.1,draw=none,forget plot,
bar shift=-0.2]
table[x expr=\coordindex,y=aq,meta=meta] {\groupb};
\resetstackedplots
\addplot [fill=myblue-mild,bar width=0.2,draw=none,forget plot,
bar shift=-0.25]
table[x expr=\coordindex,y=factorss] {\groupb};
\addplot [fill=myred-mild,bar width=0.1,
bar shift=-0.3,draw=none,forget plot]
table[x expr=\coordindex,y=actives] {\groupb};
\resetstackedplots
\addplot [fill=myblue-mild,bar width=0.2,draw=none,
bar shift=0.25]
table[x expr=\coordindex,y=factorsd] {\groupb};
\addplot [fill=myred-mild,bar width=0.1,draw=none,
bar shift=0.2]
table[x expr=\coordindex,y=actived] {\groupb};
\resetstackedplots
\addplot [fill=myblue-mild,bar width=0.2,draw=none,forget plot,
bar shift=0.25]
table[x expr=\coordindex,y=factorsd] {\groupb};
\addplot [fill=mygreen-mild,bar width=0.1,draw=none,
bar shift=0.3]
table[x expr=\coordindex,y=aq] {\groupb};
\end{axis}
\node[rectangle,draw,inner sep=1pt] at (2,3.75) (box)
{\small
\begin{tabular}{l}
\small C: LU, $u_f$=\textsc{d} \\
\small D: LU, $u_f$=\textsc{s} \\
\small E: GMRES, $u_f$=\textsc{s}
\end{tabular}};
\end{tikzpicture}
\end{document}