/
preamble.tex
430 lines (401 loc) · 13.7 KB
/
preamble.tex
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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
% set fonts for nicer pdf view
\IfFileExists{lmodern.sty}{\usepackage{lmodern}}{}
\fancyheadoffset{12pt}
\renewcommand{\sectionmark}[1]{} % Don't use sections in headers
\renewcommand{\subsectionmark}[1]{} % Don't use subsections in headers
\usepackage{pdflscape}
\usepackage{geometry}
\newenvironment{wide}{
\pagebreak
\newgeometry{
top=15mm,
inner=15mm,
outer=15mm,
bottom=15mm,
headheight=15pt,
headsep=5mm,
footnotesep=5mm,
footskip=10mm}
\begin{landscape}
% Use TiKZ?
% http://tex.stackexchange.com/questions/40501/using-restoregeometry-in-environment-next-page-runs-off-the-page-bottom/40503#40503
\setlength\LTleft{0pt} % default: \fill
\setlength\LTright{0pt} % default: \fill
}{
\end{landscape}
\pagebreak
\aftergroup\restoregeometry
}
\newenvironment{portraitdatapage}{
\pagebreak
\newgeometry{
top=15mm,
inner=15mm,
outer=15mm,
bottom=15mm,
headheight=15pt,
headsep=5mm,
footnotesep=5mm,
footskip=10mm}
% Use TiKZ?
% http://tex.stackexchange.com/questions/40501/using-restoregeometry-in-environment-next-page-runs-off-the-page-bottom/40503#40503
\setlength\LTleft{0pt} % default: \fill
\setlength\LTright{0pt} % default: \fill
}{
\pagebreak
\aftergroup\restoregeometry
}
\usepackage{url}
\usepackage{numprint}
\npstyleenglish
\newcommand{\readsinglelinefile}[1]{
\newread\inputstream%
\immediate\openin\inputstream=#1%
\immediate\read\inputstream to \singlelinecontents%
\singlelinecontents%
\immediate\closein\inputstream%
}
\providecommand{\versiononly}{\IfFileExists{.generated.version}{\readsinglelinefile{.generated.version}}{(Unknown~document~version)}}%
\providecommand{\versionandtoday}{\versiononly~--~\today}
\usepackage{longtable}
\setlength\LTcapwidth{\textwidth} % default: 4in (rather less than \textwidth...)
\usepackage{caption}
\usepackage{pgfplotstable}
\usepackage{booktabs}
\usepackage{colortbl}
\usepackage{array}
\pgfplotsset{compat=1.11}% supress warning
\pgfplotstableset{
% Write all longtable tables to disk.
every table/.append style={outfile={.generated.report-table\@arabic\c@LT@tables.tex}},
% Use cached/written files as input.
include outfiles,
% Change to true to force re-generation. It's easier to just delete all generated files.
% force remake=true,
}
\newcolumntype{i}{>{\begin{pgfplotstablecoltype}[int detect]}r<{\end{pgfplotstablecoltype}}}
\newcolumntype{f}{>{\begin{pgfplotstablecoltype}[fixed zerofill]}r<{\end{pgfplotstablecoltype}}}
\newcolumntype{t}{>{\arraybackslash}p{.3\linewidth}}
\newcolumntype{T}{>{\arraybackslash}p{.9\linewidth}}
% TODO: reduce code-duplication between \tsvtablestyle/wide/widedatasets/superwidedatasets
\newcommand{\tsvtablestyle}[0]{
\pgfplotstableset{
format=file,
col sep=tab,
multicolumn names={c},
column type=r,
int detect,
zerofill=true,
precision=3,
1000 sep={\ },
begin table=\begin{longtable*},
end table=\end{longtable*},
every odd row/.style={before row={\rowcolor[gray]{0.95}}},
every head row/.style={before row=\toprule,after row={
\toprule
\addlinespace[0pt]
\endhead
},
},
every last row/.style={after row={
\bottomrule
}
},
}
}
\newcommand{\tsvtable}[3]{
\tsvtablestyle
\pgfplotstabletypeset[
columns={#2},#3
]{#1}
}
\newcommand{\tsvtablestylewide}[1]{
\pgfplotstableset{
format=file,
col sep=tab,
multicolumn names={c},
column type=r,
int detect,
zerofill=true,
precision=3,
1000 sep={\ },
begin table=\begin{longtable},
end table=\end{longtable},
every odd row/.style={before row={\rowcolor[gray]{0.95}}},
every head row/.style={before row=\toprule,after row={
\toprule
\addlinespace[0pt]
\endhead
},
},
every last row/.style={after row={
\bottomrule
\caption{#1}}
},
}
}
\newcommand{\tsvtablewide}[4]{
\tsvtablestylewide{#2}
\pgfplotstabletypeset[
columns={#3},#4
]{#1}
}
\newcommand{\tsvtablewidedatasets}[4]{
\tsvtablestylewide{#2}
\pgfplotstabletypeset[
columns={#3},every nth row={4[-1]}{after row={\addlinespace[0pt]\midrule\addlinespace[0pt]}},fixed,display columns/0/.style={string type, column type=l},display columns/1/.style={string type, column type=i|},#4
]{#1}
}
\newcommand{\tsvtablesuperwidedatasets}[4]{
\tsvtablestylewide{#2}
\pgfplotstabletypeset[
columns={#3},every nth row={4[-1]}{after row={\addlinespace[0pt]\midrule\addlinespace[0pt]}},fixed,display columns/0/.style={string type, column type=l},display columns/1/.style={string type, column type=i|},%
% Remove dataset dates.
display columns/0/.append style={string replace*={2014-09-01.}{}},%
display columns/0/.append style={string replace*={2014-08-29.}{}},%
display columns/0/.append style={string replace*={2014-07-23.}{}},%
display columns/0/.append style={string replace*={2014w35.}{}},%
display columns/0/.append style={string replace*={2014-07-10.}{}},%
% Shorten health status datasets.
display columns/0/.append style={string replace*={healthstatus.2013.}{hs.}},%
display columns/0/.append style={string replace*={.domain-registrars}{.registrars}},%
display columns/0/.append style={string replace*={.financial-services}{.financial}},%
display columns/0/.append style={string replace*={.higher-education}{.education}},%
display columns/0/.append style={string replace*={.public-authorities}{.pubauth}},%
% Shorten dataset counts.
display columns/0/.append style={string replace*={100000}{100k}},%
display columns/0/.append style={string replace*={10000}{10k}},%
% Shorten Alexa datasets.
display columns/0/.append style={string replace*={alexa.top.se.10k.}{alexa.top.se.}},%
display columns/0/.append style={string replace*={alexa.top.dk.10k.}{alexa.top.dk.}},%
% Shorten dataset type.
display columns/0/.append style={string replace*={random.}{rnd.}},%
display columns/0/.append style={string replace*={-https-www}{-sw}},%
display columns/0/.append style={string replace*={-https}{-s}},%
display columns/0/.append style={string replace*={-http-www}{-hw}},%
display columns/0/.append style={string replace*={-http}{-h}},%
,#4
]{#1}
}
\newenvironment{futurework}{
\begin{center}
\begin{minipage}{.8\columnwidth}
\hspace{12pt}
\hrule
\hspace{12pt}
}{
\hspace{12pt}
\hrule
\hspace{12pt}
\end{minipage}
\end{center}
}
% Speed up pgfplots/tikz figure generation by caching results.
% LyX needs to be configured per user;
% In LyX Preferences, File Handling, Converters:
% For LaTeX (pdflatex) -> PDF (pdflatex) set the Converted field to:
% pdflatex -shell-escape $$i
% (Adding -shell-escape is what is important.)
\usepgfplotslibrary{external}
% When using LyX, the command is executed in a temporary working directory; can't use a folder prefix.
\tikzexternalize[prefix=.generated.]
% Use to remake all or remake a single figure.
%\tikzset{external/force remake}
%\tikzset{external/remake next}
\usepgfplotslibrary{groupplots}
\pgfplotsset{allDatasetsXbar/.style=
{
enlarge x limits=false,
bar width=6pt,
fill opacity=0.9,
xmin=0,
xmax=1,
xtick={0,.2,.4,.6,.8,1},
minor xtick={.1,.3,.5,.7,.9},
xminorgrids=true,
xmajorgrids=true,
ytick=data,
y dir=reverse,
yticklabel pos=right,
symbolic y coords={alexa.2014-09-01.random.10000-http,alexa.2014-09-01.random.10000-http-www,alexa.2014-09-01.random.10000-https,alexa.2014-09-01.random.10000-https-www,alexa.2014-09-01.top.10000-http,alexa.2014-09-01.top.10000-http-www,alexa.2014-09-01.top.10000-https,alexa.2014-09-01.top.10000-https-www,alexa.2014-09-01.top.dk.10000-http,alexa.2014-09-01.top.dk.10000-http-www,alexa.2014-09-01.top.dk.10000-https,alexa.2014-09-01.top.dk.10000-https-www,alexa.2014-09-01.top.se.10000-http,alexa.2014-09-01.top.se.10000-http-www,alexa.2014-09-01.top.se.10000-https,alexa.2014-09-01.top.se.10000-https-www,com.2014-08-29.random.10000-http,com.2014-08-29.random.10000-http-www,com.2014-08-29.random.10000-https,com.2014-08-29.random.10000-https-www,dk.2014-07-23.random.10000-http,dk.2014-07-23.random.10000-http-www,dk.2014-07-23.random.10000-https,dk.2014-07-23.random.10000-https-www,net.2014-08-29.random.10000-http,net.2014-08-29.random.10000-http-www,net.2014-08-29.random.10000-https,net.2014-08-29.random.10000-https-www,reach50.2014w35.se-http,reach50.2014w35.se-http-www,reach50.2014w35.se-https,reach50.2014w35.se-https-www,se.2014-07-10.random.100000-http,se.2014-07-10.random.100000-http-www,se.2014-07-10.random.100000-https,se.2014-07-10.random.100000-https-www,se.healthstatus.2013.counties-http,se.healthstatus.2013.counties-http-www,se.healthstatus.2013.counties-https,se.healthstatus.2013.counties-https-www,se.healthstatus.2013.domain-registrars-http,se.healthstatus.2013.domain-registrars-http-www,se.healthstatus.2013.domain-registrars-https,se.healthstatus.2013.domain-registrars-https-www,se.healthstatus.2013.financial-services-http,se.healthstatus.2013.financial-services-http-www,se.healthstatus.2013.financial-services-https,se.healthstatus.2013.financial-services-https-www,se.healthstatus.2013.gocs-http,se.healthstatus.2013.gocs-http-www,se.healthstatus.2013.gocs-https,se.healthstatus.2013.gocs-https-www,se.healthstatus.2013.higher-education-http,se.healthstatus.2013.higher-education-http-www,se.healthstatus.2013.higher-education-https,se.healthstatus.2013.higher-education-https-www,se.healthstatus.2013.isps-http,se.healthstatus.2013.isps-http-www,se.healthstatus.2013.isps-https,se.healthstatus.2013.isps-https-www,se.healthstatus.2013.media-http,se.healthstatus.2013.media-http-www,se.healthstatus.2013.media-https,se.healthstatus.2013.media-https-www,se.healthstatus.2013.municipalities-http,se.healthstatus.2013.municipalities-http-www,se.healthstatus.2013.municipalities-https,se.healthstatus.2013.municipalities-https-www,se.healthstatus.2013.public-authorities-http,se.healthstatus.2013.public-authorities-http-www,se.healthstatus.2013.public-authorities-https,se.healthstatus.2013.public-authorities-https-www},
legend image code/.code={%
\draw[#1] (0pt,-4pt) rectangle (8pt,4pt);
},
},
allDatasetsXbarFullPage/.style=
{
enlarge y limits=0.008,
width=.65\textwidth,
height=1.47\textwidth,
font=\small,
legend columns=-1,
legend style={at={(0.5,-16pt)},anchor=north}
},
allDatasetsXbarMiniResults/.style=
{
enlarge y limits=0.1,
width=.4\textwidth,
height=.325\textwidth,
font=\tiny,
legend columns=-1,
legend style={at={(0.5,-12pt)},anchor=north},
symbolic y coords={alexa.2014-09-01.top.10000-http-www,alexa.2014-09-01.top.10000-https-www,alexa.2014-09-01.top.se.10000-http-www,alexa.2014-09-01.top.se.10000-https-www,se.2014-07-10.random.100000-http-www,se.2014-07-10.random.100000-https-www,se.healthstatus.2013.municipalities-http-www,se.healthstatus.2013.municipalities-https-www,},
xticklabel style={
/pgf/number format/fixed,
/pgf/number format/fixed zerofill=false,
/pgf/number format/precision=1
},
title style={at={(.5,.95)}},
},
xticklabel style={
/pgf/number format/fixed,
/pgf/number format/fixed zerofill,
/pgf/number format/precision=2
},
yticklabel style={
/pgf/number format/fixed,
/pgf/number format/fixed zerofill,
/pgf/number format/precision=2
}
}
\pgfplotsset{allDatasetsStackedXbar/.style=
{
xbar stacked=plus,
},
}
\pgfplotsset{allDatasetsMultiXbar/.style=
{
xbar,
},
allDatasetsMultiXbarPart2/.style=
{
bar width=4pt,
% bar direction=y,
ymajorgrids=true,
major y grid style={loosely dashed},
},
}
\newcommand{\XBarPlotFromDataset}[5]{
\addplot[
fill=#4,#5
]
table[y=Dataset,x=#2]
{#1};
\addlegendentry{#3}
}
\pgfplotsset{datasetsCDF/.style=
{
xmin=0,
xmax=1,
ymin=0,
ymax=1,
grid=both,
xtick={0,.1,...,1.1},
ytick={0,.1,...,1.1},
enlargelimits=false,
% Marks 0% and 99%.
mark repeat=99,
% Using a custom position below.
% legend pos=south east,
legend style={
at={(.99,.01)},
anchor=south east,
cells={anchor=west},
},
},
datasetsCDFFullPage/.style=
{
width=\textwidth,
height=1.46\textwidth,
},
datasetsCDFMiniResults/.style=
{
width=.4\textwidth,
height=.325\textwidth,
font=\tiny,
xtick={0,.2,...,1.0},
ytick={0,.2,...,1.0},
minor xtick={0,.1,...,1.1},
minor ytick={0,.1,...,1.1},
xticklabel style={
/pgf/number format/fixed,
/pgf/number format/fixed zerofill=false,
/pgf/number format/precision=1
},
yticklabel style={
/pgf/number format/fixed,
/pgf/number format/fixed zerofill=false,
/pgf/number format/precision=1
},
title style={at={(.5,.95)}},
}
}
\pgfplotsset{datasetsOccurances/.style=
{
ymin=,
xmin=0.1,
xmax=100,
xtick={0.1,1,2,3,4,5,10,20,50,100},
minor xtick={6,7,8,9,30,40,60,70,80,90},
xticklabel={%
\ifnum\ticknum=9%
$100^+$%
\else%
\pgfmathfloatparsenumber{\tick}%
\pgfmathfloatexp{\pgfmathresult}%
\pgfmathprintnumber[fixed,precision=0]{\pgfmathresult}%
\fi%
},
yticklabel style={
/pgf/number format/fixed,
/pgf/number format/fixed zerofill,
/pgf/number format/precision=2
},
% Marks 0.1.
mark repeat=1,
mark indices={1},
},
datasetsOccurancesMiniResults/.style=
{
width=.35\textwidth,
height=.325\textwidth,
font=\tiny,
xmax=15,
xtick={0.1,1,5,10,15},
ytick={0,.2,...,1.0},
minor xtick={2,3,4,6,7,8,9,11,12,13,14},
xticklabel={%
\pgfmathfloatparsenumber{\tick}%
% \pgfmathfloatexp{\pgfmathresult}%
\pgfmathprintnumber[fixed,precision=0]{\pgfmathresult}%
},
minor ytick={0,.1,...,1.1},
yticklabel style={
/pgf/number format/fixed,
/pgf/number format/fixed zerofill=false,
/pgf/number format/precision=1
},
title style={at={(.5,.95)}},
},
}
\newcommand{\CDFPlotFromDataset}[3]{
\addplot+[#3,solid,mark=*,every mark/.append style={#3,solid},]
table[x=colnames,y=#2-http-www]
{#1};
\addlegendentry{#2-http-www}
\addplot+[#3,dashed,mark=square*,every mark/.append style={#3,solid},]
table[x=colnames,y=#2-https-www]
{#1};
\addlegendentry{#2-https-www}
}
\newcommand{\CDFPlotFromDefaultDatasets}[1]{
\CDFPlotFromDataset{#1}{alexa.2014-09-01.top.10000}{red}
\CDFPlotFromDataset{#1}{alexa.2014-09-01.top.se.10000}{blue}
\CDFPlotFromDataset{#1}{se.2014-07-10.random.100000}{brown}
\CDFPlotFromDataset{#1}{se.healthstatus.2013.municipalities}{violet}
% \CDFPlotFromDataset{#1}{se.healthstatus.2013.media}{teal}
}
\newcommand{\CDFPlotFromDefaultDatasetsFile}[1]{
\pgfplotstabletranspose[colnames from=Dataset]\tableTransposedDatasetsFromFile{#1}
\CDFPlotFromDefaultDatasets{\tableTransposedDatasetsFromFile}
}