Plots grid
A set of plots spread over a 2x4 grid comparing the norms of two quantities for different matrix/preconditioner properties.

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
%%% Full, compilable sources including data files are on Github:
%%% https://github.com/bvieuble/TeXFantasy/tree/main/plots/fig3
%%% Appears in my article ``Mixed precision strategies for preconditioned
%%% GMRES: a comprehensive analysis''.
% Compiled with LuaLaTeX
% TeX-command-extra-options: "-shell-escape"
\documentclass[convert={outext=.png},border=10pt]{standalone}
\usepackage{fontspec}
\setmainfont{Roboto}
\usepackage{pgfplots}
\pgfplotsset{compat=newest}
\usepackage{luacode}
\usepackage{xcolor}
\definecolor{fg}{RGB}{150,150,150} % Foreground color
\definecolor{purple}{RGB}{116,83,162}
\definecolor{green}{RGB}{100,180,28}
\begin{document}%
\begin{luacode*}
myutils = require("utils")
myconfig = require("config")
\end{luacode*}
%
\newcommand{\lefterrmatvec}
{ %
\begin{axis}[
legend columns = -1,
legend style={at={(\varlegendx\linewidth,\varlegendy\linewidth)},
fill=none, draw=fg, anchor=center, font=\footnotesize},
legend entries={\color{fg}$\|A\widehat{v}_{j}\|_2$; \;,
\color{fg}$\||A||\widehat{v}_{j}|\|_{2}$},
legend to name = \varlegendname,
axis x line=left,
axis y line=middle,
grid = major,
scale only axis=true,
width=\varxsize\linewidth,
height=\varysize\linewidth,
grid style={dashed, gray!30},
ymode=log,
ymin=1e-18,
ymax=1e1,
ytick={1e0, 1e-16},
yticklabels/.expand once=\varyticklabel,
y tick label style={font=\small,rotate=90},
xtick=\empty,
tick align=outside,
enlargelimits=false,
every axis title/.style={at={(0.5,1.2)},font=\normalsize},
title={\small\vartitle},
at={(\varcoordx,\varcoordy)},
]
\addplot[\varlinea,color=\varcolora,thick]
table[x expr=\coordindex,y=\varplota,col sep=comma] {\vardata};
\addplot[\varlineb,color=\varcolorb,thick]
table[x expr=\coordindex,y=\varplotb,col sep=comma] {\vardata};
\end{axis}%
}%
%
\begin{tikzpicture}[fg]%
\begin{luacode*}
grid = myutils.get_grid(#myconfig.plots, myconfig.gridcols,
myconfig.xsize, myconfig.ysize)
for i = 1, #myconfig.plots
do
title = myconfig.plots[i][2]
plotdata = myconfig.plots[i][1]
pathcsv = "data.csv"
tex.print("\\def\\varplota{" .. plotdata .. "-a}")
tex.print("\\def\\varplotb{" .. plotdata .. "-b}")
tex.print("\\def\\vardata{" .. pathcsv .. "}")
tex.print("\\def\\vartitle{" .. title .. "}")
tex.print("\\def\\varcoordx{" .. grid.coordx[i] .. "}")
tex.print("\\def\\varcoordy{" .. grid.coordy[i] .. "}")
tex.print("\\def\\varxsize{" .. myconfig.xsize .. "}")
tex.print("\\def\\varysize{" .. myconfig.ysize .. "}")
tex.print("\\def\\varxlabel{" .. grid.xlabel[i] .. "}")
tex.print("\\def\\varylabel{" .. grid.ylabel[i] .. "}")
tex.print("\\def\\varytick{" .. grid.ytick[i] .. "}")
tex.print("\\def\\varyticklabel{" .. grid.yticklabel[i] .. "}")
tex.print("\\def\\varlinea{" .. myutils.plotstyle.lines[1] .. "}")
tex.print("\\def\\varlineb{" .. myutils.plotstyle.lines[2] .. "}")
tex.print("\\def\\varcolora{" .. myutils.plotstyle.colors[1] .. "}")
tex.print("\\def\\varcolorb{" .. myutils.plotstyle.colors[2] .. "}")
if i == #myconfig.plots then
tex.print("\\def\\varlegendx{" .. grid.legendx .. "}")
tex.print("\\def\\varlegendy{" .. grid.legendy .. "}")
tex.print("\\def\\varlegendname{plotlegend}")
tex.print("\\lefterrmatvec")
else
tex.print("\\def\\varlegendname{}")
tex.print("\\lefterrmatvec")
end
end
tex.print("\\ref{plotlegend}")
\end{luacode*}
\end{tikzpicture}%
\end{document}