| 1 |
% Copyright 2019 by Till Tantau |
| 2 |
% |
| 3 |
% This file may be distributed and/or modified |
| 4 |
% |
| 5 |
% 1. under the LaTeX Project Public License and/or |
| 6 |
% 2. under the GNU Public License. |
| 7 |
% |
| 8 |
% See the file doc/generic/pgf/licenses/LICENSE for more details. |
| 9 |
|
| 10 |
\ProvidesFileRCS{tikzlibrarydatavisualization.code.tex} |
| 11 |
|
| 12 |
\usepgfmodule{datavisualization}% |
| 13 |
\usetikzlibrary{backgrounds}% |
| 14 |
|
| 15 |
|
| 16 |
\tikzset{/tikz/data visualization/.is family, |
| 17 |
/tikz/data visualization/.unknown/.code={ |
| 18 |
\let\tikz@dv@key\pgfkeyscurrentname% |
| 19 |
\pgfkeys{/tikz/\tikz@dv@key/.try={#1}}% |
| 20 |
\ifpgfkeyssuccess% |
| 21 |
\else% |
| 22 |
\edef\pgf@temp{/errors/unknown key={/tikz/data visualization/\tikz@dv@key}}% |
| 23 |
\expandafter\pgfkeys\expandafter{\pgf@temp{#1}}% |
| 24 |
\fi% |
| 25 |
}, |
| 26 |
/tikz/data visualization/data/.unknown/.code={% |
| 27 |
% Redirect to /pgf/data |
| 28 |
\let\tikz@dv@key\pgfkeyscurrentname% |
| 29 |
\pgfkeys{/pgf/data/\tikz@dv@key/.try={#1}}% |
| 30 |
\ifpgfkeyssuccess% |
| 31 |
\else% |
| 32 |
\edef\pgf@temp{/errors/unknown key={/pgf/data/\tikz@dv@key}}% |
| 33 |
\expandafter\pgfkeys\expandafter{\pgf@temp{#1}}% |
| 34 |
\fi% |
| 35 |
}, |
| 36 |
}% |
| 37 |
|
| 38 |
\def\tikzdatavisualizationset{\pgfqkeys{/tikz/data visualization}}% |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
% The main \datavisualization command |
| 44 |
% |
| 45 |
% This command must, as always, be given inside a tikz picture. It |
| 46 |
% will add a data visualization to the picture; use "shift" option and |
| 47 |
% friends to place the data visualization somewhere other than at the |
| 48 |
% origin. |
| 49 |
% |
| 50 |
% The \datavisualization is followed by a sequence of blocks and ended |
| 51 |
% with a semicolon. Each block may be one of the following: |
| 52 |
% |
| 53 |
% "data" blocks. |
| 54 |
% |
| 55 |
% Syntax: data [options] % options specify an external source |
| 56 |
% Syntax: data [options] { inline data } |
| 57 |
% |
| 58 |
% The optional arguments may either specify an |
| 59 |
% external data source or the data may follow inline. |
| 60 |
% |
| 61 |
% The options are executed for the path /pgf/data. The style |
| 62 |
% /tikz/every data is executed for each data, which can be useful to |
| 63 |
% generally set, say, a certain data format. |
| 64 |
% |
| 65 |
% |
| 66 |
% "data set" blocks. |
| 67 |
% |
| 68 |
% Syntax: data set [options] {name} = { ... } |
| 69 |
% Syntax: data set [options] {name} += { ... } |
| 70 |
% Syntax: data set [options] {name} |
| 71 |
% |
| 72 |
% The first syntax allows you to define a data set. The data block |
| 73 |
% inside {...} will be stored inside the data set |
| 74 |
% "name". Subsequently, the data set can be referenced by using the |
| 75 |
% third syntax. The second syntax allows you to extend the |
| 76 |
% definition of an already defined data set. |
| 77 |
% |
| 78 |
% |
| 79 |
% "info" and "info'" blocks. |
| 80 |
% |
| 81 |
% Syntax: info [options] {code} |
| 82 |
% Syntax: info' [options] {code} |
| 83 |
% |
| 84 |
% A block starting with "info" or "info'" may contain any code. It |
| 85 |
% will be executed after the visualization (info) or before the |
| 86 |
% visualization (info'). |
| 87 |
% |
| 88 |
% |
| 89 |
% Options blocks. |
| 90 |
% |
| 91 |
% Syntax: [options] |
| 92 |
% |
| 93 |
% The options will be executed immediately. |
| 94 |
% |
| 95 |
% Scope blocks. |
| 96 |
% |
| 97 |
% Syntax: scope[options] { blocks } |
| 98 |
% |
| 99 |
% The blocks are executed inside a scope for which the options are |
| 100 |
% set. This can be used to group data blocks. |
| 101 |
% |
| 102 |
% Examples: |
| 103 |
% |
| 104 |
% \datavisualization[schoolbook plot] |
| 105 |
% data [source=my_data_file.csv] |
| 106 |
% ; |
| 107 |
% |
| 108 |
% \datavisualization[schoolbook plot] |
| 109 |
% data [format=key value pairs] |
| 110 |
% { |
| 111 |
% x=0, y=0 |
| 112 |
% x=1, y=1 |
| 113 |
% x=2, y=4 |
| 114 |
% x=3, y=9 |
| 115 |
% }; |
| 116 |
% |
| 117 |
% \datavisualization[schoolbook plot] |
| 118 |
% data [format=function] |
| 119 |
% { |
| 120 |
% var x: interval [0:3]; |
| 121 |
% func y = \value x*\value x; |
| 122 |
% } |
| 123 |
% [at begin visualization={ |
| 124 |
% \fill [black!10] (visualization cs:x=0,y=0) -- (visualization cs:x=3,y=9); |
| 125 |
% }] |
| 126 |
% info[red] |
| 127 |
% { |
| 128 |
% \draw (visualization cs:x=0,y=0) -- (visualization cs:x=3,y=9); |
| 129 |
% }; |
| 130 |
% |
| 131 |
% \datavisualization[schoolbook plot] |
| 132 |
% data [/data point/label=first experiment,source=file_1] |
| 133 |
% data [/data point/label=second experiment,source=file_2] |
| 134 |
% data [/data point/label=third experiment,source=file_3] |
| 135 |
% data [/data point/label=prediction,format=function] |
| 136 |
% { var x: interval [0,1]; func y = rand(\value x); } |
| 137 |
% ; |
| 138 |
|
| 139 |
\def\tikz@lib@datavisualization{ |
| 140 |
\begingroup% |
| 141 |
\let\tikz@path@do@at@end=\relax% |
| 142 |
% Ok, first, start a new data visualization |
| 143 |
\pgfoonew \tikz@main@dv=new data visualization()% |
| 144 |
% Next, create a scope for the dv |
| 145 |
\pgfset{local bounding box=data visualization bounding box}% |
| 146 |
% Clear the axis list |
| 147 |
\pgfkeyslet{/tikz/data visualization/axes list}\pgfutil@empty% |
| 148 |
\pgfkeyslet{/tikz/data visualization/axes actions}\pgfutil@empty% |
| 149 |
\pgfkeyslet{/tikz/data visualization/label actions}\pgfutil@empty% |
| 150 |
\pgfkeyslet{/tikz/data visualization/legend actions}\pgfutil@empty% |
| 151 |
\pgfkeyslet{/tikz/data visualization/grid actions}\pgfutil@empty% |
| 152 |
\pgfkeyslet{/tikz/data visualization/major grid actions}\pgfutil@empty% |
| 153 |
\pgfkeyslet{/tikz/data visualization/minor grid actions}\pgfutil@empty% |
| 154 |
\pgfkeyslet{/tikz/data visualization/subminor grid actions}\pgfutil@empty% |
| 155 |
\pgfkeyslet{/tikz/data visualization/ticks actions}\pgfutil@empty% |
| 156 |
\pgfkeyslet{/tikz/data visualization/major ticks actions}\pgfutil@empty% |
| 157 |
\pgfkeyslet{/tikz/data visualization/minor ticks actions}\pgfutil@empty% |
| 158 |
\pgfkeyslet{/tikz/data visualization/subminor ticks actions}\pgfutil@empty% |
| 159 |
\tikz@[email protected] visualization(% |
| 160 |
)% |
| 161 |
\tikz@[email protected] visualization(% |
| 162 |
\tikz@lib@dv@alias@dv@bb |
| 163 |
\pgfkeysvalueof{/tikz/data visualization/grid actions} |
| 164 |
\pgfkeysvalueof{/tikz/data visualization/subminor grid actions} |
| 165 |
\pgfkeysvalueof{/tikz/data visualization/minor grid actions} |
| 166 |
\pgfkeysvalueof{/tikz/data visualization/major grid actions} |
| 167 |
\pgfkeysvalueof{/tikz/data visualization/ticks actions} |
| 168 |
\pgfkeysvalueof{/tikz/data visualization/subminor ticks actions} |
| 169 |
\pgfkeysvalueof{/tikz/data visualization/minor ticks actions} |
| 170 |
\pgfkeysvalueof{/tikz/data visualization/major ticks actions} |
| 171 |
\pgfkeysvalueof{/tikz/data visualization/axes actions} |
| 172 |
\pgfkeysvalueof{/tikz/data visualization/label actions} |
| 173 |
\pgfkeysvalueof{/tikz/data visualization/legend actions} |
| 174 |
)% |
| 175 |
% |
| 176 |
\pgfset{/pgf/data/continue code=\tikz@lib@dv@parse@loop}% |
| 177 |
% Now enter parse loop |
| 178 |
\tikz@lib@dv@parse@loop |
| 179 |
}% |
| 180 |
|
| 181 |
\def\tikz@lib@dv@parse@loop{% |
| 182 |
\pgfutil@ifnextchar d\tikz@lib@dv@handle@data{% |
| 183 |
\pgfutil@ifnextchar ;\tikz@lib@dv@parse@end{% |
| 184 |
\pgfutil@ifnextchar \par\tikz@lib@dv@handle@par{% |
| 185 |
\pgfutil@ifnextchar s\tikz@lib@dv@handle@beginscope{% |
| 186 |
\pgfutil@ifnextchar i\tikz@lib@dv@handle@info{% |
| 187 |
\pgfutil@ifnextchar [\tikz@lib@dv@handle@options{% |
| 188 |
\pgfutil@ifnextchar \egroup\tikz@lib@dv@handle@endscope{% |
| 189 |
\tikzerror{Semicolon expected}% |
| 190 |
\endgroup% |
| 191 |
}% |
| 192 |
}% |
| 193 |
}% |
| 194 |
}% |
| 195 |
}% |
| 196 |
}% |
| 197 |
}% |
| 198 |
}% |
| 199 |
\def\tikz@lib@dv@parse@end;{% |
| 200 |
% Go! |
| 201 |
\tikz@[email protected]()% |
| 202 |
\tikz@[email protected]()% |
| 203 |
\endgroup% |
| 204 |
\tikz@path@do@at@end% |
| 205 |
}% |
| 206 |
\def\tikz@lib@dv@handle@par\par{\tikz@lib@dv@parse@loop}% |
| 207 |
|
| 208 |
\def\tikz@lib@dv@handle@options[#1]{% |
| 209 |
\tikzdatavisualizationset{#1}% |
| 210 |
\tikz@lib@dv@parse@loop% |
| 211 |
}% |
| 212 |
|
| 213 |
\def\tikz@lib@dv@handle@beginscope scope{% |
| 214 |
\begingroup% |
| 215 |
\pgfutil@ifnextchar[\tikz@lib@dv@beg@opt{\tikz@lib@dv@beg@opt[]}%} |
| 216 |
}% |
| 217 |
\def\tikz@lib@dv@beg@opt[#1]{% |
| 218 |
\pgfkeys{/pgf/data/.cd,/pgf/every data/.try,#1}% |
| 219 |
\pgf@dv@do@adddata{\pgfkeysvalueof{/pgf/data visualization/obj}.add data({{\begingroup\pgfkeys{/pgf/data/.cd,/pgf/every data/.try,#1}}})}% |
| 220 |
\pgfutil@ifnextchar\bgroup{ |
| 221 |
\afterassignment\tikz@lib@dv@parse@loop% |
| 222 |
\let\tikz@dummy=%get rid of \bgroup |
| 223 |
}{% |
| 224 |
\tikzerror{Opening brace expected}% |
| 225 |
\tikz@lib@dv@parse@loop% |
| 226 |
}% |
| 227 |
}% |
| 228 |
\def\tikz@lib@dv@handle@endscope{% |
| 229 |
\pgf@dv@do@adddata{\pgfkeysvalueof{/pgf/data visualization/obj}.add data(\endgroup)}% |
| 230 |
\endgroup% |
| 231 |
\afterassignment\tikz@lib@dv@parse@loop% |
| 232 |
\let\tikz@dummy=%get rid of \egroup |
| 233 |
}% |
| 234 |
|
| 235 |
\def\tikz@lib@dv@handle@data data{% |
| 236 |
\pgfutil@ifnextchar g{\tikz@lib@dv@handle@data@group}{% |
| 237 |
\pgfutil@ifnextchar p{\tikz@lib@dv@handle@data@point}{% |
| 238 |
\pgfdata}}}% |
| 239 |
|
| 240 |
\def\tikz@lib@dv@handle@data@group group{\pgfutil@ifnextchar[{\tikz@lib@dv@handle@data@group@opt}{\tikz@lib@dv@handle@data@group@opt[]}}%}% |
| 241 |
|
| 242 |
\def\tikz@lib@dv@handle@data@group@opt[#1]#2{% |
| 243 |
\pgfutil@ifnextchar={\tikz@lib@dv@handle@data@group@def{#1}{#2}}{% |
| 244 |
\pgfutil@ifnextchar+{\tikz@lib@dv@handle@data@group@extend{#1}{#2}}{% |
| 245 |
\tikz@lib@dv@handle@data@group@use{#1}{#2}}}}% |
| 246 |
|
| 247 |
\def\tikz@lib@dv@handle@data@group@def#1#2={% |
| 248 |
\pgfkeys{/pgf/data/new group={#2}}% |
| 249 |
\tikz@lib@dv@handle@data@group@extend{#1}{#2}+=% |
| 250 |
}% |
| 251 |
|
| 252 |
\def\tikz@lib@dv@handle@data@group@extend#1#2+={% |
| 253 |
\pgfutil@ifnextchar\bgroup{ |
| 254 |
\begingroup% |
| 255 |
\pgfkeys{/pgf/data/store in group={#2}}% |
| 256 |
\pgf@dv@do@adddata{\pgfkeysvalueof{/pgf/data visualization/obj}.add data({{\begingroup\pgfkeys{/pgf/data/.cd,/pgf/every data/.try,#1}}})}% |
| 257 |
\afterassignment\tikz@lib@dv@parse@loop% |
| 258 |
\let\tikz@dummy=%get rid of \bgroup |
| 259 |
}{% |
| 260 |
\tikzerror{Opening brace expected}% |
| 261 |
\tikz@lib@dv@parse@loop% |
| 262 |
}% |
| 263 |
}% |
| 264 |
|
| 265 |
\def\tikz@lib@dv@handle@data@group@use#1#2{% |
| 266 |
\pgfdata[#1,use group=#2]% |
| 267 |
}% |
| 268 |
|
| 269 |
\def\tikz@lib@dv@handle@data@point point{\pgfutil@ifnextchar[{\tikz@lib@dv@handle@data@point@opt}{\tikz@lib@dv@handle@data@point@opt[]}}%]% |
| 270 |
\def\tikz@lib@dv@handle@data@point@opt[#1]{% |
| 271 |
\pgf@dv@do@adddata{\pgfkeysvalueof{/pgf/data visualization/obj}.add data({{\bgroup\pgfkeys{/data point/.cd,#1}\pgfdatapoint\egroup}})}% |
| 272 |
\tikz@lib@dv@parse@loop% |
| 273 |
}% |
| 274 |
|
| 275 |
\def\tikz@lib@dv@handle@info info{% |
| 276 |
\pgfutil@ifnextchar'{\tikz@lib@dv@handle@info@prime}{\tikz@lib@dv@handle@info@noprime}}% |
| 277 |
\def\tikz@lib@dv@handle@info@noprime{% |
| 278 |
\pgfutil@ifnextchar[{\tikz@lib@dv@handle@info@block@opt}{\tikz@lib@dv@handle@info@block@opt[]}}%}% |
| 279 |
\def\tikz@lib@dv@handle@info@block@opt[#1]#2{% |
| 280 |
\tikz@[email protected] visualization({\scope[#1]#2\endscope})% |
| 281 |
\tikz@lib@dv@parse@loop |
| 282 |
}% |
| 283 |
\def\tikz@lib@dv@handle@info@prime'{% |
| 284 |
\pgfutil@ifnextchar[{\tikz@lib@dv@handle@info@block@opt@prime}{\tikz@lib@dv@handle@info@block@opt@prime[]}}%}% |
| 285 |
\def\tikz@lib@dv@handle@info@block@opt@prime[#1]#2{% |
| 286 |
\tikz@[email protected] visualization({\scope[#1]#2\endscope})% |
| 287 |
\tikz@lib@dv@parse@loop |
| 288 |
}% |
| 289 |
|
| 290 |
|
| 291 |
\pgfset{/pgf/every data/.style={/tikz/every data/.try,/tikz/data visualization/every data/.try}}% |
| 292 |
|
| 293 |
|
| 294 |
% |
| 295 |
% Performing before/after stuff via keys |
| 296 |
% |
| 297 |
|
| 298 |
\tikzdatavisualizationset{ |
| 299 |
before survey/.code=\tikz@[email protected] survey({#1}), |
| 300 |
after survey/.code=\tikz@[email protected] survey({#1}), |
| 301 |
before visualization/.code=\tikz@[email protected] visualization({#1}), |
| 302 |
after visualization/.code=\tikz@[email protected] visualization({#1}), |
| 303 |
at start survey/.code=\tikz@[email protected] start survey({#1}), |
| 304 |
at end survey/.code=\tikz@[email protected] end survey({#1}), |
| 305 |
at start visualization/.code=\tikz@[email protected] start visualization({#1}), |
| 306 |
at end visualization/.code=\tikz@[email protected] end visualization({#1}), |
| 307 |
}% |
| 308 |
|
| 309 |
|
| 310 |
\def\tikz@lib@dv@alias@dv@bb{ |
| 311 |
\pgfnodealias{data bounding box}{data visualization bounding box}% |
| 312 |
\pgfkeys{/pgf/freeze local bounding box=data bounding box}% |
| 313 |
}% |
| 314 |
|
| 315 |
% |
| 316 |
% The data point key |
| 317 |
% |
| 318 |
\tikzdatavisualizationset{ |
| 319 |
data point/.code={ |
| 320 |
\pgf@dv@do@adddata{\pgfkeysvalueof{/pgf/data visualization/obj}.add data({{\bgroup\pgfkeys{/data point/.cd,#1}\pgfdatapoint\egroup}})}% |
| 321 |
} |
| 322 |
}% |
| 323 |
|
| 324 |
|
| 325 |
% |
| 326 |
% Object setup |
| 327 |
% |
| 328 |
|
| 329 |
% The following key is used to create objects for the rendering |
| 330 |
% pipeline. They cannot be created "directly" because when it is known |
| 331 |
% that the objects needs to be created, in principle, many keys may |
| 332 |
% not yet be known. |
| 333 |
% |
| 334 |
% The following options are used: |
| 335 |
% |
| 336 |
% store = key that will store the object (handle) |
| 337 |
% class = class of the object |
| 338 |
% arg1 = argument1 of the constructor |
| 339 |
% ... |
| 340 |
% arg8 = argument8 of the constructor |
| 341 |
% when = specifies when the object will be created. Defaults to |
| 342 |
% "before survey", other possible values are "after survey" and |
| 343 |
% "before/after visualization" |
| 344 |
% before creation = code to be executed just before the object is |
| 345 |
% created |
| 346 |
% after creation = code to be executed just after the object has been created |
| 347 |
% |
| 348 |
% The following styles may be useful: |
| 349 |
% |
| 350 |
% arg1 from key = use the contents of the given key as arg1. Similar |
| 351 |
% for other args |
| 352 |
% arg1 handle from key = the contents of the given key should contain |
| 353 |
% an object. Then arg1 will be a handle to this |
| 354 |
% object. Similar for other args |
| 355 |
|
| 356 |
\tikzdatavisualizationset{% |
| 357 |
new object/.code={% |
| 358 |
\def\tikz@dv@grabbed@when{before survey}% |
| 359 |
\let\tikz@dv@grabbed@store\pgfutil@empty |
| 360 |
\pgfkeys{/tikz/data visualization/new object/grab/.cd,#1}% |
| 361 |
\ifx\tikz@dv@grabbed@store\pgfutil@empty |
| 362 |
\else |
| 363 |
\pgfkeyslet{\tikz@dv@grabbed@store}\pgfutil@empty% |
| 364 |
\fi |
| 365 |
\edef\tikz@marshal{\noexpand\tikz@main@dv.\tikz@dv@grabbed@when(\noexpand\tikz@dv@newobject{\tikz@dv@grabbed@store}}% |
| 366 |
\tikz@marshal{#1})% |
| 367 |
}, |
| 368 |
new object/grab/store/.store in=\tikz@dv@grabbed@store, |
| 369 |
new object/grab/when/.store in=\tikz@dv@grabbed@when, |
| 370 |
new object/grab/.unknown/.code={},%ignore |
| 371 |
}% |
| 372 |
|
| 373 |
\def\tikz@dv@newobject#1#2{% |
| 374 |
\def\tikz@dv@new@obj@store{#1}% |
| 375 |
\ifx\tikz@dv@new@obj@store\pgfutil@empty% |
| 376 |
\let\tikz@dv@new@obj=\pgfutil@empty% |
| 377 |
\else% |
| 378 |
\pgfkeysgetvalue\tikz@dv@new@obj@store\tikz@dv@new@obj% |
| 379 |
\fi% |
| 380 |
\ifx\tikz@dv@new@obj\pgfutil@empty |
| 381 |
\let\tikz@dv@arg@a=\tikz@lib@notused% |
| 382 |
\let\tikz@dv@arg@b=\tikz@lib@notused% |
| 383 |
\let\tikz@dv@arg@c=\tikz@lib@notused% |
| 384 |
\let\tikz@dv@arg@d=\tikz@lib@notused% |
| 385 |
\let\tikz@dv@arg@e=\tikz@lib@notused% |
| 386 |
\let\tikz@dv@arg@f=\tikz@lib@notused% |
| 387 |
\let\tikz@dv@arg@g=\tikz@lib@notused% |
| 388 |
\let\tikz@dv@arg@h=\tikz@lib@notused% |
| 389 |
\let\tikz@dv@new@after=\relax% |
| 390 |
\pgfkeys{/tikz/data visualization/new object/parse/.cd,#2} |
| 391 |
\edef\pgf@marshal{\noexpand\pgfoonew\noexpand\tikzdvobj=new \tikz@dv@new@class(}% |
| 392 |
\tikz@dv@add@arg{}\tikz@dv@arg@a% |
| 393 |
\tikz@dv@add@arg{\expandafter,}\tikz@dv@arg@b% |
| 394 |
\tikz@dv@add@arg{\expandafter,}\tikz@dv@arg@c% |
| 395 |
\tikz@dv@add@arg{\expandafter,}\tikz@dv@arg@d% |
| 396 |
\tikz@dv@add@arg{\expandafter,}\tikz@dv@arg@e% |
| 397 |
\tikz@dv@add@arg{\expandafter,}\tikz@dv@arg@f% |
| 398 |
\tikz@dv@add@arg{\expandafter,}\tikz@dv@arg@g% |
| 399 |
\tikz@dv@add@arg{\expandafter,}\tikz@dv@arg@h% |
| 400 |
\expandafter\def\expandafter\pgf@marshal\expandafter{\pgf@marshal)}% |
| 401 |
\pgf@marshal% |
| 402 |
\tikzdvobj.default connects()% |
| 403 |
\ifx\tikz@dv@new@obj@store\pgfutil@empty% |
| 404 |
\else% |
| 405 |
\pgfkeyslet\tikz@dv@new@obj@store\tikzdvobj% |
| 406 |
\fi% |
| 407 |
\tikz@dv@new@after% |
| 408 |
\fi |
| 409 |
}% |
| 410 |
\def\tikz@lib@notused{\tikz@lib@notused}% |
| 411 |
|
| 412 |
\def\tikz@dv@add@arg#1#2{% |
| 413 |
\ifx#2\tikz@lib@notused% |
| 414 |
\else% |
| 415 |
\expandafter\expandafter\expandafter\def% |
| 416 |
\expandafter\expandafter\expandafter\pgf@marshal% |
| 417 |
\expandafter\expandafter\expandafter{\expandafter\pgf@marshal#1#2}% |
| 418 |
\fi% |
| 419 |
}% |
| 420 |
|
| 421 |
\tikzdatavisualizationset{% |
| 422 |
new object/parse/.cd, |
| 423 |
store/.code=,% ignore |
| 424 |
when/.code=,% ignore |
| 425 |
class/.store in=\tikz@dv@new@class, |
| 426 |
before creation/.code={#1}, |
| 427 |
after creation/.store in=\tikz@dv@new@after, |
| 428 |
arg1/.store in=\tikz@dv@arg@a, |
| 429 |
arg2/.store in=\tikz@dv@arg@b, |
| 430 |
arg3/.store in=\tikz@dv@arg@c, |
| 431 |
arg4/.store in=\tikz@dv@arg@d, |
| 432 |
arg5/.store in=\tikz@dv@arg@e, |
| 433 |
arg6/.store in=\tikz@dv@arg@f, |
| 434 |
arg7/.store in=\tikz@dv@arg@g, |
| 435 |
arg8/.store in=\tikz@dv@arg@h, |
| 436 |
arg1 from key/.code=\pgfkeysgetvalue{#1}{\tikz@dv@arg@a}, |
| 437 |
arg2 from key/.code=\pgfkeysgetvalue{#1}{\tikz@dv@arg@b}, |
| 438 |
arg3 from key/.code=\pgfkeysgetvalue{#1}{\tikz@dv@arg@c}, |
| 439 |
arg4 from key/.code=\pgfkeysgetvalue{#1}{\tikz@dv@arg@d}, |
| 440 |
arg5 from key/.code=\pgfkeysgetvalue{#1}{\tikz@dv@arg@e}, |
| 441 |
arg6 from key/.code=\pgfkeysgetvalue{#1}{\tikz@dv@arg@f}, |
| 442 |
arg7 from key/.code=\pgfkeysgetvalue{#1}{\tikz@dv@arg@g}, |
| 443 |
arg8 from key/.code=\pgfkeysgetvalue{#1}{\tikz@dv@arg@h} |
| 444 |
arg1 handle from key/.code=\tikz@dv@handle@from@key{#1}{\tikz@dv@handle@a}{\tikz@dv@arg@a}, |
| 445 |
arg2 handle from key/.code=\tikz@dv@handle@from@key{#1}{\tikz@dv@handle@b}{\tikz@dv@arg@b}, |
| 446 |
arg3 handle from key/.code=\tikz@dv@handle@from@key{#1}{\tikz@dv@handle@c}{\tikz@dv@arg@c}, |
| 447 |
arg4 handle from key/.code=\tikz@dv@handle@from@key{#1}{\tikz@dv@handle@d}{\tikz@dv@arg@d}, |
| 448 |
arg5 handle from key/.code=\tikz@dv@handle@from@key{#1}{\tikz@dv@handle@e}{\tikz@dv@arg@e}, |
| 449 |
arg6 handle from key/.code=\tikz@dv@handle@from@key{#1}{\tikz@dv@handle@f}{\tikz@dv@arg@f}, |
| 450 |
arg7 handle from key/.code=\tikz@dv@handle@from@key{#1}{\tikz@dv@handle@g}{\tikz@dv@arg@g}, |
| 451 |
arg8 handle from key/.code=\tikz@dv@handle@from@key{#1}{\tikz@dv@handle@h}{\tikz@dv@arg@h} |
| 452 |
}% |
| 453 |
|
| 454 |
\def\tikz@dv@handle@from@key#1#2#3{% |
| 455 |
\pgfkeysvalueof{#1}.get handle(#2)% |
| 456 |
\def#3{#2}% |
| 457 |
}% |
| 458 |
|
| 459 |
|
| 460 |
|
| 461 |
|
| 462 |
% |
| 463 |
% Data visualization coordinate system |
| 464 |
% |
| 465 |
% |
| 466 |
% This cs is used to refer to points in a datavisualization. The |
| 467 |
% parameters are keys that are set in the /data point key |
| 468 |
% directory. Then, a (virtual) data point is created and the |
| 469 |
% calculated position is returned |
| 470 |
|
| 471 |
\tikzdeclarecoordinatesystem{visualization} |
| 472 |
{% |
| 473 |
\tikzset{/data point/.cd,#1}% |
| 474 |
\pgfpointdvlocaldatapoint% |
| 475 |
}% |
| 476 |
|
| 477 |
|
| 478 |
|
| 479 |
|
| 480 |
% |
| 481 |
% |
| 482 |
% Axes |
| 483 |
% |
| 484 |
% |
| 485 |
|
| 486 |
|
| 487 |
|
| 488 |
% |
| 489 |
% Axis base |
| 490 |
% |
| 491 |
|
| 492 |
\tikzdatavisualizationset{% |
| 493 |
new axis base/.style={ |
| 494 |
new object={ |
| 495 |
class=scaling mapper, |
| 496 |
store=/tikz/data visualization/#1/scaling mapper, |
| 497 |
before creation={ |
| 498 |
\pgfkeysgetvalue{/tikz/data visualization/#1/scaling}\tikz@temp |
| 499 |
\ifx\tikz@temp\pgfutil@empty% |
| 500 |
\pgfkeysgetvalue{/tikz/data visualization/#1/scaling/default}\tikz@temp |
| 501 |
\fi |
| 502 |
\expandafter\tikz@dv@lib@parse@scaling\tikz@temp\pgf@stop% |
| 503 |
\pgfkeyslet{/tikz/data visualization/#1/scaling}\tikz@temp |
| 504 |
}, |
| 505 |
arg1 from key=/tikz/data visualization/#1/attribute, |
| 506 |
arg2/.expanded=\pgfkeysvalueof{/tikz/data visualization/#1/attribute}/scaled, |
| 507 |
arg3 from key=/tikz/data visualization/#1/scaling, |
| 508 |
arg4 from key=/tikz/data visualization/#1/function |
| 509 |
}, |
| 510 |
#1/attribute/.initial={#1}, |
| 511 |
#1/function/.initial=, |
| 512 |
#1/scaling/.initial=, |
| 513 |
#1/scaling/default/.initial=0 at 0 and 1 at 1, |
| 514 |
#1/ticks at/.initial=, |
| 515 |
#1/default ticks at/.initial=, |
| 516 |
#1/major ticks/.initial=, |
| 517 |
#1/minor ticks/.initial=, |
| 518 |
#1/subminor ticks/.initial=, |
| 519 |
#1/grid at/.initial=, |
| 520 |
#1/default grid at/.initial=, |
| 521 |
#1/major grid/.initial=, |
| 522 |
#1/minor grid/.initial=, |
| 523 |
#1/subminor grid/.initial=, |
| 524 |
#1/label/.initial=, |
| 525 |
#1/padding min/.initial=, |
| 526 |
#1/padding max/.initial=, |
| 527 |
#1/.code={ |
| 528 |
\let\tikz@temp\tikz@dv@axis% |
| 529 |
\def\tikz@dv@axis{/tikz/data visualization/#1}% |
| 530 |
\expandafter\tikz@do@axis@options\expandafter{\tikz@temp}{##1}% |
| 531 |
}, |
| 532 |
#1/@compute at positions/.initial=\tikz@lib@dv@compute@at@linear, |
| 533 |
axes list/.append={\tikz@lib@dv@do@axis{#1}} |
| 534 |
}, |
| 535 |
all axes/.code={ |
| 536 |
\def\tikz@lib@dv@args{#1}% |
| 537 |
\pgfkeysvalueof{/tikz/data visualization/axes list}% |
| 538 |
}, |
| 539 |
% General styling |
| 540 |
styling/.style=, |
| 541 |
style/.style={styling/.append style={#1}}, |
| 542 |
@node styling/.initial=, |
| 543 |
node styling/.style={% |
| 544 |
/utils/exec={\pgfkeysgetvalue{/tikz/data visualization/@node styling}\tikz@temp\expandafter\tikzset\expandafter{\tikz@temp}}}, |
| 545 |
node style/.style={/tikz/data visualization/@node styling/.append={,#1}}, |
| 546 |
% General extends (both axes, grid and ticks) |
| 547 |
low/.initial=0, |
| 548 |
high/.initial=0, |
| 549 |
padded/.style={low=padded min,high=padded max}, |
| 550 |
tick length/.style={low={-#1},high={#1}}, |
| 551 |
% General tick and grid keys: |
| 552 |
common/.initial=, |
| 553 |
major/.initial=, |
| 554 |
minor/.initial=, |
| 555 |
subminor/.initial=, |
| 556 |
@setup at setters/.style={ |
| 557 |
common/.code=\tikz@lib@dv@add@{common}{##1}, |
| 558 |
major/.code=\tikz@lib@dv@add@{major}{##1}, |
| 559 |
minor/.code=\tikz@lib@dv@add@{minor}{##1}, |
| 560 |
subminor/.code=\tikz@lib@dv@add@{subminor}{##1} |
| 561 |
}, |
| 562 |
@setup at setters, |
| 563 |
% Tick keys |
| 564 |
direction axis/.initial=, |
| 565 |
% Tick text modifiers |
| 566 |
tick text low even padding/.initial=0pt, |
| 567 |
tick text high even padding/.initial=0pt, |
| 568 |
tick text low odd padding/.initial=0pt, |
| 569 |
tick text high odd padding/.initial=0pt, |
| 570 |
tick text odd padding/.style={tick text low odd padding={-#1},tick text high odd padding={#1}}, |
| 571 |
tick text even padding/.style={tick text low even padding={-#1},tick text high even padding={#1}}, |
| 572 |
tick text padding/.style={tick text odd padding={#1},tick text even padding={#1}}, |
| 573 |
stack/.style={tick text even padding={#1}}, |
| 574 |
stack'/.style={tick text odd padding={#1}}, |
| 575 |
stack/.default=1em, |
| 576 |
stack'/.default=1em, |
| 577 |
tick text at low/.is if=tikz@dv@min@tick@node, |
| 578 |
tick text at high/.is if=tikz@dv@max@tick@node, |
| 579 |
no tick text/.style={tick text at low=false,tick text at high=false}, |
| 580 |
% |
| 581 |
every major ticks/.style={style={line cap=round},tick length=2pt}, |
| 582 |
every minor ticks/.style={style={solid, help lines,thin,line cap=round},tick length=1.4pt}, |
| 583 |
every subminor ticks/.style={style={solid, help lines,line cap=round},tick length=0.8pt}, |
| 584 |
clean ticks/.style={node style={fill=white}}, |
| 585 |
% Default grid styles |
| 586 |
every grid/.style={high=max,low=min}, |
| 587 |
every major grid/.style={style={solid, help lines,thin,black!25}}, |
| 588 |
every minor grid/.style={style={solid, help lines,black!25}}, |
| 589 |
every subminor grid/.style={style={solid, help lines,black!10}}, |
| 590 |
at default ticks/.code={% |
| 591 |
\expandafter\pgfkeysalso\expandafter{\tikz@lib@dv@ticks@default@at}}, |
| 592 |
at ticks/.code={% |
| 593 |
\expandafter\pgfkeysalso\expandafter{\tikz@lib@dv@ticks@default@at}% |
| 594 |
\expandafter\pgfkeysalso\expandafter{\tikz@lib@dv@ticks@at}}, |
| 595 |
}% |
| 596 |
|
| 597 |
\def\tikz@lib@dv@add@#1#2{\pgfkeysaddvalue{/tikz/data visualization/#1}{}{,#2}}% |
| 598 |
|
| 599 |
\def\tikz@dv@lib@parse@scaling#1 at#2and #3 at#4\pgf@stop{% |
| 600 |
\pgfmathsetmacro{\tikz@dv@lib@min@at}{#2} |
| 601 |
\pgfmathsetmacro{\tikz@dv@lib@max@at}{#4} |
| 602 |
\edef\tikz@temp{#1 at \tikz@dv@lib@min@at and #3 at \tikz@dv@lib@max@at}% |
| 603 |
}% |
| 604 |
|
| 605 |
|
| 606 |
% Ticks at |
| 607 |
\tikzdatavisualizationset{ |
| 608 |
at/.code={\def\tikz@dv@at@list{#1}}, |
| 609 |
also at/.code={\expandafter\def\expandafter\tikz@dv@at@list\expandafter{\tikz@dv@at@list,#1}}, |
| 610 |
major at/.style={major={at={#1}}}, |
| 611 |
minor at/.style={minor={at={#1}}}, |
| 612 |
subminor at/.style={subminor={at={#1}}}, |
| 613 |
major also at/.style={major={also at={#1}}}, |
| 614 |
minor also at/.style={minor={also at={#1}}}, |
| 615 |
subminor also at/.style={subminor={also at={#1}}}, |
| 616 |
options at/.code={\expandafter\def\expandafter\tikz@dv@style@at@list\expandafter{\tikz@dv@style@at@list,{#1}}}, |
| 617 |
no tick text at/.style={options at={#1 as [no tick text]}} |
| 618 |
}% |
| 619 |
|
| 620 |
|
| 621 |
\def\tikz@lib@dv@do@axis#1{% |
| 622 |
\def\tikz@marshal{#1=} |
| 623 |
\expandafter\expandafter\expandafter\tikzdatavisualizationset% |
| 624 |
\expandafter\expandafter\expandafter{\expandafter\tikz@marshal\expandafter{\tikz@lib@dv@args}} |
| 625 |
}% |
| 626 |
|
| 627 |
\def\tikz@do@axis@options#1#2{ |
| 628 |
\pgfkeys{/tikz/data visualization/axis options/.cd,#2} |
| 629 |
\def\tikz@dv@axis{#1} |
| 630 |
}% |
| 631 |
\let\tikz@dv@axis\pgfutil@empty |
| 632 |
|
| 633 |
\tikzdatavisualizationset{ |
| 634 |
every ticks/.style={ |
| 635 |
node style={% |
| 636 |
font=\pgfutil@font@footnotesize, |
| 637 |
inner sep=1pt, |
| 638 |
outer sep=.1666em, |
| 639 |
rounded corners=1.5pt |
| 640 |
} |
| 641 |
}, |
| 642 |
every data set label/.style={ |
| 643 |
every ticks, |
| 644 |
node style={ |
| 645 |
font=\pgfutil@font@small, |
| 646 |
} |
| 647 |
}, |
| 648 |
@color of visualizer labels/.style={text=black}, |
| 649 |
every label in legend/.style={ |
| 650 |
node style={ |
| 651 |
fill=none, |
| 652 |
} |
| 653 |
}, |
| 654 |
every axis label/.style={ |
| 655 |
node style={% |
| 656 |
font=\pgfutil@font@small, |
| 657 |
} |
| 658 |
} |
| 659 |
}% |
| 660 |
|
| 661 |
|
| 662 |
\tikzset{ |
| 663 |
/tikz/data visualization/axis options/.cd, |
| 664 |
% |
| 665 |
% Basic setters |
| 666 |
% |
| 667 |
attribute/.style={\tikz@dv@axis/attribute={#1}}, |
| 668 |
function/.style={\tikz@dv@axis/function={#1}}, |
| 669 |
scaling/.style={\tikz@dv@axis/scaling={#1}}, |
| 670 |
padding min/.style={\tikz@dv@axis/padding min={#1}}, |
| 671 |
padding max/.style={\tikz@dv@axis/padding max={#1}}, |
| 672 |
padding/.style={padding min={-#1},padding max={#1}}, |
| 673 |
label/.code={% |
| 674 |
\def\pgf@temp{#1}% |
| 675 |
\ifx\pgf@temp\tikz@lib@dv@auto@attribute% |
| 676 |
\tikzdatavisualizationset{\tikz@dv@axis/label/.expanded=$\noexpand\mathit{\pgfkeysvalueof{\tikz@dv@axis/attribute}}$}% |
| 677 |
\else |
| 678 |
\tikzdatavisualizationset{\tikz@dv@axis/label={#1}}% |
| 679 |
\fi |
| 680 |
}, |
| 681 |
label/.default=\tikz@lib@dv@auto@attribute, |
| 682 |
% |
| 683 |
% Strategies |
| 684 |
% |
| 685 |
tick placement strategy/.style={\tikz@dv@axis/@compute at positions={#1}}, |
| 686 |
linear steps/.style={tick placement strategy=\tikz@lib@dv@compute@at@linear}, |
| 687 |
% |
| 688 |
% Attribute setter |
| 689 |
% |
| 690 |
goto/.code={\tikz@dv@goto{\tikz@dv@axis}{#1}}, |
| 691 |
goto pos/.code={\tikz@dv@goto@pos{\tikz@dv@axis}{#1}}, |
| 692 |
anchor at min/.code={\tikz@lib@dv@special@at{\tikz@dv@axis}{\tikz@dv@min@anchor}}, |
| 693 |
anchor at max/.code={\tikz@lib@dv@special@at{\tikz@dv@axis}{\tikz@dv@max@anchor}}, |
| 694 |
% |
| 695 |
% Visualization setters |
| 696 |
% |
| 697 |
visualize axis/.code=\expandafter\tikz@lib@dv@av\expandafter{\tikz@dv@axis}{#1}, |
| 698 |
% |
| 699 |
% Ticks settings |
| 700 |
% |
| 701 |
ticks/.style={\tikz@dv@axis/ticks at/.append={,#1}}, |
| 702 |
ticks/.default=some, |
| 703 |
visualize ticks/.code=\expandafter\tikz@lib@dv@tv\expandafter{\tikz@dv@axis}{#1}, |
| 704 |
% |
| 705 |
% Grid settings |
| 706 |
% |
| 707 |
grid/.style={\tikz@dv@axis/grid at/.append={,#1}}, |
| 708 |
grid/.default=at default ticks, |
| 709 |
visualize grid/.code=\expandafter\tikz@lib@dv@gv\expandafter{\tikz@dv@axis}{#1}, |
| 710 |
% |
| 711 |
ticks and grid/.style={\tikz@dv@axis/ticks at/.append={,#1},\tikz@dv@axis/grid at/.append={,#1}}, |
| 712 |
% |
| 713 |
% Visualizing axis labels |
| 714 |
% |
| 715 |
visualize label/.code=\expandafter\tikz@lib@dv@lv\expandafter{\tikz@dv@axis}{#1}, |
| 716 |
}% |
| 717 |
|
| 718 |
\def\tikz@lib@dv@auto@attribute{\tikz@lib@dv@auto@attribute}% |
| 719 |
|
| 720 |
|
| 721 |
% Range options |
| 722 |
\tikzdatavisualizationset{ |
| 723 |
axis options/.cd, |
| 724 |
% |
| 725 |
% Including a value in the range |
| 726 |
% |
| 727 |
include value/.style={% |
| 728 |
/tikz/data visualization/before survey/.expanded={% |
| 729 |
\noexpand\pgfkeysgetvalue{\tikz@dv@axis/scaling mapper}\noexpand\tikz@dv@axis@mapper% |
| 730 |
\noexpand\foreach \noexpand\tikz@lib@dv@temp in {#1} {% |
| 731 |
\noexpand\tikz@dv@[email protected] in value(\noexpand\tikz@lib@dv@temp)% |
| 732 |
}% |
| 733 |
}% |
| 734 |
}, |
| 735 |
% |
| 736 |
% Directly setting the min or max |
| 737 |
% |
| 738 |
min value/.style={ |
| 739 |
/tikz/data visualization/at end survey/.expanded={% |
| 740 |
\noexpand\pgfkeysgetvalue{\tikz@dv@axis/scaling mapper}\noexpand\tikz@dv@axis@mapper% |
| 741 |
\noexpand\tikz@lib@dv@set\noexpand\tikz@dv@axis@mapper{#1}{min}% |
| 742 |
} |
| 743 |
}, |
| 744 |
max value/.style={ |
| 745 |
/tikz/data visualization/at end survey/.expanded={% |
| 746 |
\noexpand\pgfkeysgetvalue{\tikz@dv@axis/scaling mapper}\noexpand\tikz@dv@axis@mapper% |
| 747 |
\noexpand\tikz@lib@dv@set\noexpand\tikz@dv@axis@mapper{#1}{max}% |
| 748 |
} |
| 749 |
}, |
| 750 |
}% |
| 751 |
|
| 752 |
\def\tikz@lib@dv@set#1#2#3{% |
| 753 |
\pgfdvmathenter{\pgf@dv@value}{#2}% |
| 754 |
#1.get in range interval()% |
| 755 |
\pgfdvinrangeinterval.let #3(\pgf@dv@value)% |
| 756 |
}% |
| 757 |
|
| 758 |
% Layer options |
| 759 |
\tikzdatavisualizationset{ |
| 760 |
axis layer/.style=on background layer, |
| 761 |
ticks layer/.style=on background layer, |
| 762 |
ticks node layer/.style=, |
| 763 |
grid layer/.style=on background layer, |
| 764 |
}% |
| 765 |
|
| 766 |
|
| 767 |
% Axis visualization |
| 768 |
% |
| 769 |
% #1 = name of the to-be-visualized axis name |
| 770 |
% #2 = options for the visualization |
| 771 |
|
| 772 |
\def\tikz@lib@dv@av#1#2{ |
| 773 |
\tikzdatavisualizationset{ |
| 774 |
axes actions/.append={\tikz@lib@dv@show@axis{#1}{#2}} |
| 775 |
} |
| 776 |
}% |
| 777 |
|
| 778 |
\def\tikz@lib@dv@show@axis#1#2{% |
| 779 |
\scope[data visualization/axis layer,/tikz/data visualization/.cd,low=min,high=max,every axis/.try,#2] |
| 780 |
\pgfkeysgetvalue{#1/scaling mapper}\tikz@dv@axis@mapper% |
| 781 |
% Ok, calculate direction vector: |
| 782 |
\tikzpointandanchordirection{\tikz@dv@[email protected] in to(min)}{\tikz@dv@[email protected] in to(max)} |
| 783 |
\xdef\tikz@dv@axis@dir{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}} |
| 784 |
\path[draw,/tikz/data visualization/styling] |
| 785 |
\pgfextra{ |
| 786 |
{ |
| 787 |
\tikz@dv@goto{#1}{\pgfkeysvalueof{/tikz/data visualization/low}}% |
| 788 |
\pgfpathdvmoveto% |
| 789 |
} |
| 790 |
{ |
| 791 |
\tikz@dv@goto{#1}{\pgfkeysvalueof{/tikz/data visualization/high}}% |
| 792 |
\pgfpathdvlineto% |
| 793 |
} |
| 794 |
}; |
| 795 |
\endscope |
| 796 |
}% |
| 797 |
|
| 798 |
\def\tikz@dv@goto#1#2{% |
| 799 |
\edef\pgf@@temp{#2}% |
| 800 |
\ifx\pgf@@temp\tikz@lib@dv@padded@min@text% |
| 801 |
\pgfkeysvalueof{#1/scaling mapper}.set in to(min)% |
| 802 |
\pgfkeysvalueof{#1/scaling mapper}.get out()% |
| 803 |
\pgfkeysgetvalue{#1/padding min}\pgf@temp% |
| 804 |
\pgfmathparse{\pgf@temp}% |
| 805 |
\pgfkeyslet{/data point/\pgfdvout/offset}\pgfmathresult% |
| 806 |
\else% |
| 807 |
\ifx\pgf@@temp\tikz@lib@dv@padded@max@text% |
| 808 |
\pgfkeysvalueof{#1/scaling mapper}.set in to(max)% |
| 809 |
\pgfkeysvalueof{#1/scaling mapper}.get out()% |
| 810 |
\pgfkeysgetvalue{#1/padding max}\pgf@temp% |
| 811 |
\pgfmathparse{\pgf@temp}% |
| 812 |
\pgfkeyslet{/data point/\pgfdvout/offset}\pgfmathresult% |
| 813 |
\else% |
| 814 |
\pgfkeysvalueof{#1/scaling mapper}.set in to(#2)% |
| 815 |
\fi% |
| 816 |
\fi% |
| 817 |
}% |
| 818 |
|
| 819 |
\def\tikz@dv@goto@pos#1#2{% |
| 820 |
\pgfkeyssetvalue{/data point/\pgfkeysvalueof{#1/attribute}/out pos}{#2}% |
| 821 |
}% |
| 822 |
|
| 823 |
\def\tikz@lib@dv@padded@min@text{padded min}% |
| 824 |
\def\tikz@lib@dv@padded@max@text{padded max}% |
| 825 |
|
| 826 |
\def\tikz@lib@dv@special@at#1#2{% |
| 827 |
% Ok, calculate direction vector: |
| 828 |
\tikzpointandanchordirection{\pgfkeysvalueof{#1/scaling mapper}.set in to(min)}{\pgfkeysvalueof{#1/scaling mapper}.set in to(max)} |
| 829 |
\tikzset{anchor/.expanded={#2}} |
| 830 |
}% |
| 831 |
|
| 832 |
|
| 833 |
% Ticks visualization |
| 834 |
% |
| 835 |
% #1 = name of axis on which ticks should be shown |
| 836 |
% #2 = options for the visualization |
| 837 |
|
| 838 |
\def\tikz@lib@dv@tv#1#2{ |
| 839 |
\tikzdatavisualizationset{ |
| 840 |
ticks actions/.append={\tikz@lib@dv@default@action{ticks}{#1}{#2}}, |
| 841 |
major ticks actions/.append={\tikz@lib@dv@show@ticks{major}{#1}{#2}}, |
| 842 |
minor ticks actions/.append={\tikz@lib@dv@show@ticks{minor}{#1}{#2}}, |
| 843 |
subminor ticks actions/.append={\tikz@lib@dv@show@ticks{subminor}{#1}{#2}} |
| 844 |
} |
| 845 |
}% |
| 846 |
|
| 847 |
\def\tikz@lib@dv@default@action#1#2#3{% |
| 848 |
\let\tikz@marshal\pgfutil@empty% |
| 849 |
{% |
| 850 |
\let\tikz@lib@dv@ticks@at\pgfutil@empty% |
| 851 |
\pgfkeysgetvalue{#2/ticks at}\tikz@lib@dv@ticks@default@at% |
| 852 |
\pgfkeysgetvalue{#2/#1 at}\tikz@lib@dv@settings% |
| 853 |
\pgfkeysgetvalue{#2/scaling mapper}\tikz@lib@dv@mapper |
| 854 |
% Normal minor etc. have no effect. |
| 855 |
\tikzdatavisualizationset{major/.code=,minor/.code=,subminor/.code=,common/.code=} |
| 856 |
\expandafter\tikzdatavisualizationset\expandafter{\tikz@lib@dv@settings}% |
| 857 |
\tikzdatavisualizationset{@setup at setters}% |
| 858 |
\pgfkeysgetvalue{/tikz/data visualization/compute step}\tikz@temp@step% |
| 859 |
\ifx\tikz@temp@step\pgfutil@empty% |
| 860 |
% do nothing |
| 861 |
\else% |
| 862 |
\pgfkeysvalueof{#2/@compute at positions}% |
| 863 |
\xdef\tikz@marshal{ |
| 864 |
major={\pgfkeysvalueof{/tikz/data visualization/major}}, |
| 865 |
minor={\pgfkeysvalueof{/tikz/data visualization/minor}}, |
| 866 |
subminor={\pgfkeysvalueof{/tikz/data visualization/subminor}}} |
| 867 |
\fi |
| 868 |
}% |
| 869 |
\pgfkeyslet{#2/default #1 at}\tikz@marshal |
| 870 |
}% |
| 871 |
|
| 872 |
\def\tikz@lib@dv@show@ticks#1#2#3{% |
| 873 |
% First, check whether there is anything to do at all: |
| 874 |
\pgfkeysgetvalue{#2/default ticks at}\tikz@lib@dv@default@settings% |
| 875 |
\ifx\tikz@lib@dv@default@settings\pgfutil@empty% |
| 876 |
\pgfkeysgetvalue{#2/ticks at}\tikz@lib@dv@settings% |
| 877 |
\else% |
| 878 |
\pgfkeysgetvalue{#2/ticks at}\tikz@lib@dv@settings% |
| 879 |
\expandafter\expandafter\expandafter\def% |
| 880 |
\expandafter\expandafter\expandafter\tikz@lib@dv@settings% |
| 881 |
\expandafter\expandafter\expandafter{\expandafter\tikz@lib@dv@default@settings\expandafter,\tikz@lib@dv@settings} |
| 882 |
\fi% |
| 883 |
\ifx\tikz@lib@dv@settings\pgfutil@empty% |
| 884 |
% Great, nothing to do |
| 885 |
\else |
| 886 |
{% |
| 887 |
\let\tikz@dv@at@list\pgfutil@empty% |
| 888 |
\let\tikz@dv@style@at@list\pgfutil@empty% |
| 889 |
\pgfkeysgetvalue{#2/scaling mapper}\tikz@lib@dv@mapper |
| 890 |
\scope[/tikz/data visualization/.cd,every ticks/.try,every #1 ticks/.try,#3]% |
| 891 |
% Setup options |
| 892 |
\expandafter\tikzdatavisualizationset\expandafter{\tikz@lib@dv@settings}% |
| 893 |
\pgfkeysgetvalue{/tikz/data visualization/common}\tikz@temp |
| 894 |
\expandafter\tikzdatavisualizationset\expandafter{\tikz@temp} |
| 895 |
\pgfkeysgetvalue{/tikz/data visualization/#1}\tikz@temp |
| 896 |
\expandafter\tikzdatavisualizationset\expandafter{\tikz@temp} |
| 897 |
\pgfkeysgetvalue{/tikz/data visualization/\pgfkeysvalueof{/tikz/data visualization/direction axis}/scaling mapper}\pgf@dv@tick@dir@mapper |
| 898 |
% Ok, now it's time to draw the ticks! |
| 899 |
\foreach \tikz@dv@tick@pos[count=\tikz@dv@tick@count] in \tikz@dv@at@list |
| 900 |
{ |
| 901 |
\ifx\tikz@dv@tick@pos\pgfutil@empty |
| 902 |
\c@pgf@counta=\tikz@dv@tick@count\relax% |
| 903 |
\advance\c@pgf@counta by-1\relax% |
| 904 |
\edef\tikz@dv@tick@count{\the\c@pgf@counta}% |
| 905 |
\else |
| 906 |
\expandafter\tikz@lib@dv@parse\tikz@dv@tick@pos\pgf@stop% |
| 907 |
\expandafter\tikzdatavisualizationset\expandafter{\tikz@lib@dv@tick@opt}% |
| 908 |
\tikz@lib@[email protected] in to(\tikz@dv@tick@pos)% |
| 909 |
% First, compute position of tick: |
| 910 |
\pgf@process{\pgfpointdvlocaldatapoint} |
| 911 |
\xdef\pgf@dv@tick@origin{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}} |
| 912 |
% Ok, calculate direction vector: |
| 913 |
\tikzpointandanchordirection{\pgf@dv@tick@[email protected] in to(min)}{\pgf@dv@tick@[email protected] in to(max)} |
| 914 |
\xdef\pgf@dv@tick@dir{\noexpand\pgfqpoint{\the\pgf@x}{\the\pgf@y}} |
| 915 |
% Now, show something: |
| 916 |
\tikz@lib@handle@at@style% |
| 917 |
\pgfkeysgetvalue{/tikz/data visualization/high}\tikz@dv@max@val% |
| 918 |
\pgfkeysgetvalue{/tikz/data visualization/low}\tikz@dv@min@val% |
| 919 |
\iftikz@dv@max@tick@node\pgfmathsetmacro\tikz@dv@max@val{% |
| 920 |
\tikz@dv@max@val+(\pgfkeysvalueof{% |
| 921 |
/tikz/data visualization/tick text high |
| 922 |
\ifodd\tikz@dv@tick@count odd \else even \fi padding}% |
| 923 |
)}% |
| 924 |
\fi% |
| 925 |
\iftikz@dv@min@tick@node\pgfmathsetmacro\tikz@dv@min@val{% |
| 926 |
\tikz@dv@min@val+(\pgfkeysvalueof{% |
| 927 |
/tikz/data visualization/tick text low |
| 928 |
\ifodd\tikz@dv@tick@count odd \else even \fi padding}% |
| 929 |
)}% |
| 930 |
\fi% |
| 931 |
\pgf@process{\pgfpointadd{\pgf@dv@tick@origin}{\pgfpointscale{\tikz@dv@max@val}{\pgf@dv@tick@dir}}} |
| 932 |
\xdef\tikz@dv@max@tick{\the\pgf@x,\the\pgf@y} |
| 933 |
\pgf@process{\pgfpointadd{\pgf@dv@tick@origin}{\pgfpointscale{\tikz@dv@min@val}{\pgf@dv@tick@dir}}} |
| 934 |
\xdef\tikz@dv@min@tick{\the\pgf@x,\the\pgf@y} |
| 935 |
\scope[data visualization/ticks layer] |
| 936 |
\tikzdatavisualizationset{every \ifodd\tikz@dv@tick@count odd \else even \fi tick/.try} |
| 937 |
\draw [/tikz/data visualization/styling] (\tikz@dv@min@tick) -- (\tikz@dv@max@tick); |
| 938 |
\endscope |
| 939 |
\iftikz@dv@min@tick@node |
| 940 |
\scope[data visualization/ticks node layer] |
| 941 |
\tikzdatavisualizationset{every \ifodd\tikz@dv@tick@count odd \else even \fi tick/.try} |
| 942 |
\path [/tikz/data visualization/styling] (\tikz@dv@min@tick) \tikz@dv@handle@tick{\tikz@dv@min@anchor}; |
| 943 |
\endscope |
| 944 |
\fi |
| 945 |
\iftikz@dv@max@tick@node |
| 946 |
\scope[data visualization/ticks node layer] |
| 947 |
\tikzdatavisualizationset{every \ifodd\tikz@dv@tick@count odd \else even \fi tick/.try} |
| 948 |
\path [/tikz/data visualization/styling] (\tikz@dv@max@tick) \tikz@dv@handle@tick{\tikz@dv@max@anchor}; |
| 949 |
\endscope |
| 950 |
\fi |
| 951 |
\fi |
| 952 |
} |
| 953 |
\endscope |
| 954 |
} |
| 955 |
\fi |
| 956 |
}% |
| 957 |
|
| 958 |
\def\tikz@lib@dv@parse#1\pgf@stop{% |
| 959 |
\pgfutil@in@{as}{#1}% |
| 960 |
\ifpgfutil@in@% |
| 961 |
\tikz@lib@dv@parse@as#1\pgf@stop% |
| 962 |
\else% |
| 963 |
\tikz@lib@dv@parse@as#1as\tikz@lib@dv@typeset\pgf@stop% |
| 964 |
\fi% |
| 965 |
}% |
| 966 |
\def\tikz@lib@dv@parse@as#1as{% |
| 967 |
\def\tikz@dv@tick@pos{#1}% |
| 968 |
\pgfutil@ifnextchar[{\tikz@lib@dv@parse@as@opt}{\tikz@lib@dv@parse@as@opt[]}%] |
| 969 |
}% |
| 970 |
\def\tikz@lib@dv@parse@as@opt[#1]{% |
| 971 |
\def\tikz@lib@dv@tick@opt{#1}% |
| 972 |
\pgfutil@ifnextchar\pgf@stop{\tikz@lib@dv@parse@as@text\tikz@lib@dv@typeset}{\tikz@lib@dv@parse@as@text} |
| 973 |
}% |
| 974 |
\def\tikz@lib@dv@parse@as@text#1\pgf@stop{% |
| 975 |
\def\tikz@lib@dv@tick@text{#1}% |
| 976 |
}% |
| 977 |
|
| 978 |
\def\tikz@lib@dv@typeset{% |
| 979 |
\pgfdvmathenter{\tikz@lib@dv@typesetnum}{\tikz@dv@tick@pos}% |
| 980 |
\pgfdvmathexitbyscientificformat{\tikz@lib@dv@typesetnum}{\tikz@lib@dv@typesetnum}% hmm... not sure about this... |
| 981 |
\pgfkeysvalueof{/tikz/data visualization/tick prefix}% |
| 982 |
\pgfkeys{/tikz/data visualization/tick typesetter=\tikz@lib@dv@typesetnum}% |
| 983 |
\pgfkeysvalueof{/tikz/data visualization/tick suffix}% |
| 984 |
}% |
| 985 |
|
| 986 |
\newif\iftikz@dv@min@tick@node |
| 987 |
\newif\iftikz@dv@max@tick@node |
| 988 |
|
| 989 |
\def\tikz@dv@handle@tick#1{% |
| 990 |
\pgfextra{ |
| 991 |
\ifx\tikz@lib@dv@tick@text\pgfutil@empty% |
| 992 |
\global\let\tikz@dv@tick@marshal=\pgfutil@empty% Skip! |
| 993 |
\else |
| 994 |
\def\tikz@dv@tick@marshal{node[anchor=#1,/tikz/data visualization/node styling]}% |
| 995 |
\expandafter\pgfutil@g@addto@macro\expandafter\tikz@dv@tick@marshal\expandafter{\expandafter{\tikz@lib@dv@tick@text}} |
| 996 |
\fi |
| 997 |
\expandafter}% |
| 998 |
\tikz@dv@tick@marshal |
| 999 |
}% |
| 1000 |
|
| 1001 |
|
| 1002 |
\def\tikz@lib@handle@at@style{% |
| 1003 |
\ifx\tikz@dv@style@at@list\pgfutil@empty% nothing to do |
| 1004 |
\else% |
| 1005 |
\let\tikz@dv@lib@this@at@style=\pgfutil@empty% |
| 1006 |
\pgfdvmathenter{\tikz@temp}{\tikz@dv@tick@pos}% |
| 1007 |
\pgfdvmathexitbyscientificformat{\tikz@dv@compare@to}{\tikz@temp}% |
| 1008 |
\foreach \tikz@dv@at@style in \tikz@dv@style@at@list {% |
| 1009 |
\ifx\tikz@dv@at@style\pgfutil@empty% |
| 1010 |
\else% |
| 1011 |
\expandafter\tikz@dv@lib@handle@one@at@style\tikz@dv@at@style\tikz@stop% |
| 1012 |
\fi% |
| 1013 |
} |
| 1014 |
\ifx\tikz@dv@lib@this@at@style\pgfutil@empty% |
| 1015 |
\else% |
| 1016 |
\expandafter\tikzdatavisualizationset\expandafter{\tikz@dv@lib@this@at@style}% |
| 1017 |
\fi% |
| 1018 |
\fi% |
| 1019 |
}% |
| 1020 |
|
| 1021 |
\def\tikz@dv@lib@handle@one@at@style#1as#2[#3]#4\tikz@stop{% |
| 1022 |
\pgfdvmathenter{\tikz@lib@dv@at@math@var}{#1}% |
| 1023 |
\pgfdvmathexitbyscientificformat{\tikz@dv@temp}{\tikz@lib@dv@at@math@var}% |
| 1024 |
\ifx\tikz@dv@temp\tikz@dv@compare@to% |
| 1025 |
% Bingo! |
| 1026 |
\expandafter\gdef\expandafter\tikz@dv@lib@this@at@style\expandafter{\tikz@dv@lib@this@at@style,#3}% |
| 1027 |
\fi% |
| 1028 |
}% |
| 1029 |
|
| 1030 |
|
| 1031 |
% Help function |
| 1032 |
\def\tikzpointandanchordirection#1#2{% |
| 1033 |
% This function works like pgfpointdvdirection, but also computes |
| 1034 |
% appropriate "min" and "max" anchors. |
| 1035 |
\pgf@process{\pgfpointdvdirection{#1}{#2}} |
| 1036 |
{ |
| 1037 |
\pgf@ya=\pgf@y |
| 1038 |
\pgf@y=-\pgf@x |
| 1039 |
\pgf@x=\pgf@ya |
| 1040 |
\tikz@auto@anchor |
| 1041 |
\xdef\tikz@dv@max@anchor{\tikz@anchor} |
| 1042 |
\tikz@auto@anchor@prime |
| 1043 |
\xdef\tikz@dv@min@anchor{\tikz@anchor} |
| 1044 |
} |
| 1045 |
}% |
| 1046 |
|
| 1047 |
|
| 1048 |
|
| 1049 |
|
| 1050 |
% Grid visualization |
| 1051 |
% |
| 1052 |
% #1 = name of axis on which grid lines should be shown |
| 1053 |
% #2 = options for the visualization |
| 1054 |
|
| 1055 |
\def\tikz@lib@dv@gv#1#2{ |
| 1056 |
\tikzdatavisualizationset{ |
| 1057 |
grid actions/.append={\tikz@lib@dv@default@action{grid}{#1}{#2}}, |
| 1058 |
major grid actions/.append={\tikz@lib@dv@show@grid{major}{#1}{#2}}, |
| 1059 |
minor grid actions/.append={\tikz@lib@dv@show@grid{minor}{#1}{#2}}, |
| 1060 |
subminor grid actions/.append={\tikz@lib@dv@show@grid{subminor}{#1}{#2}}, |
| 1061 |
} |
| 1062 |
}% |
| 1063 |
|
| 1064 |
\def\tikz@lib@dv@show@grid#1#2#3{% |
| 1065 |
% First, check whether there is anything to do at all: |
| 1066 |
\pgfkeysgetvalue{#2/default grid at}\tikz@lib@dv@default@settings% |
| 1067 |
\ifx\tikz@lib@dv@default@settings\pgfutil@empty% |
| 1068 |
\pgfkeysgetvalue{#2/grid at}\tikz@lib@dv@settings% |
| 1069 |
\else% |
| 1070 |
\pgfkeysgetvalue{#2/grid at}\tikz@lib@dv@settings% |
| 1071 |
\expandafter\expandafter\expandafter\def% |
| 1072 |
\expandafter\expandafter\expandafter\tikz@lib@dv@settings% |
| 1073 |
\expandafter\expandafter\expandafter{\expandafter\tikz@lib@dv@default@settings\expandafter,\tikz@lib@dv@settings} |
| 1074 |
\fi% |
| 1075 |
\ifx\tikz@lib@dv@settings\pgfutil@empty% |
| 1076 |
% Great, nothing to do |
| 1077 |
\else |
| 1078 |
{% |
| 1079 |
\let\tikz@dv@at@list\pgfutil@empty |
| 1080 |
\let\tikz@dv@style@at@list\pgfutil@empty |
| 1081 |
\pgfkeysgetvalue{#2/scaling mapper}\tikz@lib@dv@mapper |
| 1082 |
\let\tikz@lib@dv@ticks@default@at\pgfutil@empty% |
| 1083 |
\scope[data visualization/grid layer,/tikz/data visualization/.cd,every #1 grid/.try,every grid,#3] |
| 1084 |
% Setup options |
| 1085 |
\pgfkeysgetvalue{#2/ticks at}\tikz@lib@dv@ticks@at% |
| 1086 |
\expandafter\tikzdatavisualizationset\expandafter{\tikz@lib@dv@settings}% |
| 1087 |
\pgfkeysgetvalue{/tikz/data visualization/common}\tikz@temp |
| 1088 |
\expandafter\tikzdatavisualizationset\expandafter{\tikz@temp} |
| 1089 |
\pgfkeysgetvalue{/tikz/data visualization/#1}\tikz@temp |
| 1090 |
\expandafter\tikzdatavisualizationset\expandafter{\tikz@temp} |
| 1091 |
\edef\tikz@lib@dv@dir@axis{/tikz/data visualization/\pgfkeysvalueof{/tikz/data visualization/direction axis}}% |
| 1092 |
% Ok, now it's time to draw the grid! |
| 1093 |
\foreach \tikz@dv@grid@pos in \tikz@dv@at@list |
| 1094 |
{ |
| 1095 |
\ifx\tikz@dv@grid@pos\pgfutil@empty |
| 1096 |
\else |
| 1097 |
\expandafter\tikz@lib@dv@parse\tikz@dv@grid@pos\pgf@stop% |
| 1098 |
\expandafter\tikzdatavisualizationset\expandafter{\tikz@lib@dv@tick@opt}% |
| 1099 |
\tikz@lib@[email protected] in to(\tikz@dv@tick@pos)% |
| 1100 |
\draw[/tikz/data visualization/styling] |
| 1101 |
\pgfextra{ |
| 1102 |
% First, compute start of grid: |
| 1103 |
\tikz@dv@goto{\tikz@lib@dv@dir@axis}{\pgfkeysvalueof{/tikz/data visualization/low}}% |
| 1104 |
\pgfpathdvmoveto% |
| 1105 |
\tikz@dv@goto{\tikz@lib@dv@dir@axis}{\pgfkeysvalueof{/tikz/data visualization/high}}% |
| 1106 |
\pgfpathdvlineto% |
| 1107 |
}; |
| 1108 |
\fi |
| 1109 |
} |
| 1110 |
\endscope |
| 1111 |
} |
| 1112 |
\fi |
| 1113 |
}% |
| 1114 |
|
| 1115 |
|
| 1116 |
|
| 1117 |
|
| 1118 |
|
| 1119 |
|
| 1120 |
|
| 1121 |
|
| 1122 |
|
| 1123 |
% |
| 1124 |
% Label visualization |
| 1125 |
% |
| 1126 |
|
| 1127 |
\def\tikz@lib@dv@lv#1#2{ |
| 1128 |
\tikzdatavisualizationset{ |
| 1129 |
label actions/.append={\tikz@lib@dv@show@label{#1}{#2}} |
| 1130 |
} |
| 1131 |
}% |
| 1132 |
|
| 1133 |
\def\tikz@lib@dv@show@label#1#2{% |
| 1134 |
% First, check whether there is anything to do at all: |
| 1135 |
\pgfkeysgetvalue{#1/label}\tikz@dv@lib@label% |
| 1136 |
\ifx\tikz@dv@lib@label\pgfutil@empty% |
| 1137 |
% Great, nothing to do |
| 1138 |
\else |
| 1139 |
\scope[anchor=center,/tikz/data visualization/.cd,every axis label/.try,#2] |
| 1140 |
\expandafter\tikz@lib@dv@parse@node\tikz@dv@lib@label\pgf@stop |
| 1141 |
\endscope |
| 1142 |
\fi |
| 1143 |
}% |
| 1144 |
|
| 1145 |
\def\tikz@lib@dv@parse@node{\pgfutil@ifnextchar[\tikz@lib@dv@parse@node@opt{\tikz@lib@dv@parse@node@opt[]}}%}% |
| 1146 |
\def\tikz@lib@dv@parse@node@opt[#1]#2\pgf@stop{ |
| 1147 |
\tikzdatavisualizationset{#1} |
| 1148 |
\pgftransformshift{\pgfpointdvlocaldatapoint}% |
| 1149 |
\node [/tikz/data visualization/node styling] {#2}; |
| 1150 |
}% |
| 1151 |
|
| 1152 |
|
| 1153 |
|
| 1154 |
% |
| 1155 |
% Tick placement strategies |
| 1156 |
% |
| 1157 |
|
| 1158 |
\tikzdatavisualizationset{ |
| 1159 |
compute step/.initial=, |
| 1160 |
step/.style={compute step=\def\tikz@lib@dv@step{#1}}, |
| 1161 |
minor steps between steps/.initial=, |
| 1162 |
minor steps between steps/.default=9, |
| 1163 |
phase/.initial=0, |
| 1164 |
tick typesetter/.code=\pgfmathprintnumber{#1}, |
| 1165 |
tick prefix/.initial=, |
| 1166 |
tick suffix/.initial=, |
| 1167 |
tick unit/.style={tick suffix={$\,\pgfutil@font@normalfont#1$}},% this is an alias |
| 1168 |
}% |
| 1169 |
|
| 1170 |
\def\tikz@lib@dv@compute@at@linear{% |
| 1171 |
% Setup about: |
| 1172 |
\let\tikz@lib@dv@compute@about=\tikz@lib@dv@about@linear% |
| 1173 |
\let\tikz@lib@dv@step\relax% |
| 1174 |
\pgfkeysvalueof{/tikz/data visualization/compute step} |
| 1175 |
\ifx\tikz@lib@dv@step\relax% |
| 1176 |
\else% |
| 1177 |
% Gather interesting values |
| 1178 |
\tikz@lib@[email protected] in range interval()% |
| 1179 |
\pgfdvinrangeinterval.get min and max()% |
| 1180 |
\pgfkeysgetvalue{/tikz/data visualization/phase}\tikz@temp |
| 1181 |
\pgfdvmathenter{\tikz@dv@lib@phase}{\tikz@temp} |
| 1182 |
\pgfdvmathenter{\tikz@dv@lib@step}{\tikz@lib@dv@step} |
| 1183 |
\pgfdvmathifless{\pgfdvmathalwayszero}{\tikz@dv@lib@step}{% |
| 1184 |
% Compute start: |
| 1185 |
\pgfdvmathsub{\tikz@dv@lib@temp}{\pgfdvmin}{\tikz@dv@lib@phase}% temp = dvmin - phase |
| 1186 |
\pgfdvmathdiv{\tikz@dv@lib@temp}{\tikz@dv@lib@temp}{\tikz@dv@lib@step}% temp = temp/step |
| 1187 |
\pgfdvmathfloor{\tikz@dv@lib@temp}{\tikz@dv@lib@temp}% temp = floor(temp) |
| 1188 |
\pgfdvmathmul{\tikz@lib@dv@current}{\tikz@dv@lib@temp}{\tikz@dv@lib@step}% current = temp*step ... |
| 1189 |
\pgfdvmathadd{\tikz@lib@dv@current}{\tikz@lib@dv@current}{\tikz@dv@lib@phase}% + phase |
| 1190 |
\let\tikz@lib@dv@ats\pgfutil@empty% |
| 1191 |
\let\tikz@lib@dv@minor@ats\pgfutil@empty% |
| 1192 |
\tikz@lib@[email protected] function(\tikz@temp)% |
| 1193 |
\ifx\tikz@temp\pgfutil@empty% |
| 1194 |
\pgfdvmathenter{\tikz@one@hundreth}{0.001}% |
| 1195 |
\pgfdvmathsub{\tikz@lib@temp}{\pgfdvmax}{\pgfdvmin}% |
| 1196 |
\pgfdvmathmul{\tikz@lib@dv@epsilon}{\tikz@lib@temp}{\tikz@one@hundreth}% epsilon = (max - min)/1000 |
| 1197 |
\else |
| 1198 |
\let\tikz@lib@dv@epsilon\pgfdvmathalwayszero |
| 1199 |
\fi |
| 1200 |
\pgfdvmathsub{\tikz@lib@dv@min@minus@epsilon}{\pgfdvmin}{\tikz@lib@dv@epsilon}% |
| 1201 |
\pgfdvmathadd{\tikz@lib@dv@max@plus@epsilon}{\pgfdvmax}{\tikz@lib@dv@epsilon}% |
| 1202 |
\pgfkeysgetvalue{/tikz/data visualization/minor steps between steps}\tikz@lib@dv@substeps% |
| 1203 |
\ifx\tikz@lib@dv@substeps\pgfutil@empty |
| 1204 |
\else |
| 1205 |
\pgfmathsetmacro\tikz@temp{\tikz@lib@dv@substeps+1}% |
| 1206 |
\pgfdvmathenter{\tikz@dv@lib@substeps}{\tikz@temp}% |
| 1207 |
\pgfdvmathdiv{\tikz@lib@dv@substep}{\tikz@dv@lib@step}{\tikz@dv@lib@substeps}% |
| 1208 |
\fi |
| 1209 |
\loop% |
| 1210 |
\ifx\tikz@lib@dv@substeps\pgfutil@empty% |
| 1211 |
\else% |
| 1212 |
\let\tikz@lib@dv@subcurrent=\tikz@lib@dv@current% |
| 1213 |
\pgfmathsetcount{\c@pgf@counta}{\tikz@lib@dv@substeps}% |
| 1214 |
\let\tikz@lib@dv@next=\tikz@lib@dv@subloop% |
| 1215 |
\tikz@lib@dv@subloop |
| 1216 |
\fi% |
| 1217 |
\pgfdvmathifless{\tikz@lib@dv@current}{\tikz@lib@dv@min@minus@epsilon}{}{% |
| 1218 |
\pgfdvmathexitbyserializing{\tikz@temp}{\tikz@lib@dv@current}% |
| 1219 |
\edef\tikz@lib@dv@ats{\tikz@lib@dv@ats,\tikz@temp}% |
| 1220 |
} |
| 1221 |
\pgfdvmathadd{\tikz@lib@dv@current}{\tikz@lib@dv@current}{\tikz@dv@lib@step}% |
| 1222 |
\pgfdvmathifless{\tikz@lib@dv@current}{\tikz@lib@dv@max@plus@epsilon}{\tikz@lib@dv@continuetrue}{\tikz@lib@dv@continuefalse}% |
| 1223 |
\iftikz@lib@dv@continue% |
| 1224 |
\repeat% |
| 1225 |
\tikzdatavisualizationset{major/.expanded={at={\tikz@lib@dv@ats}},minor/.expanded={at={\tikz@lib@dv@minor@ats}}}% |
| 1226 |
}{% |
| 1227 |
\pgfdvmathexitbyserializing{\tikz@temp}{\pgfdvmin}% |
| 1228 |
\tikzdatavisualizationset{major/.expanded={at={\tikz@temp}}}% |
| 1229 |
}% |
| 1230 |
\fi% |
| 1231 |
}% |
| 1232 |
\newif\iftikz@lib@dv@continue |
| 1233 |
|
| 1234 |
\def\tikz@lib@dv@subloop{ |
| 1235 |
\pgfdvmathadd{\tikz@lib@dv@subcurrent}{\tikz@lib@dv@subcurrent}{\tikz@lib@dv@substep}% |
| 1236 |
\pgfdvmathifless{\tikz@lib@dv@subcurrent}{\pgfdvmin}{}{% |
| 1237 |
\pgfdvmathifless{\tikz@lib@dv@subcurrent}{\pgfdvmax}{% |
| 1238 |
\pgfdvmathexitbyserializing{\tikz@temp}{\tikz@lib@dv@subcurrent}% |
| 1239 |
\edef\tikz@lib@dv@minor@ats{\tikz@lib@dv@minor@ats,\tikz@temp} |
| 1240 |
}{}} |
| 1241 |
\advance\c@pgf@counta by-1\relax% |
| 1242 |
\ifnum\c@pgf@counta=0\relax% |
| 1243 |
\let\tikz@lib@dv@next=\relax |
| 1244 |
\fi |
| 1245 |
\tikz@lib@dv@next |
| 1246 |
}% |
| 1247 |
|
| 1248 |
|
| 1249 |
|
| 1250 |
% |
| 1251 |
% Ticks about settings |
| 1252 |
% |
| 1253 |
|
| 1254 |
\tikzdatavisualizationset{ |
| 1255 |
about/.style={compute step=\tikz@lib@dv@compute@about{#1}}, |
| 1256 |
about strategy/.initial=, |
| 1257 |
standard about strategy/.style={about strategy={1.5/1.0,2.3/2.0,4/2.5,7/5,11/10}}, |
| 1258 |
standard about strategy, |
| 1259 |
euro about strategy/.style={about strategy={1.5/1.0,3/2.0,7/5,11/10}}, |
| 1260 |
decimal about strategy/.style={about strategy={3/1.0,11/10}}, |
| 1261 |
half about strategy/.style={about strategy={2/1.0,7/5,11/10}}, |
| 1262 |
quarter about strategy/.style={about strategy={1.8/1.0,4/2.5,7/5,11/10}}, |
| 1263 |
int about strategy/.style={about strategy={1.5/1.0,2.5/2.0,3.5/3.0,4.5/4.0,7/5,11/10}}, |
| 1264 |
none/.style={compute step=}, |
| 1265 |
few/.style={about=3}, |
| 1266 |
some/.style={about=5}, |
| 1267 |
many/.style={about=10}, |
| 1268 |
}% |
| 1269 |
|
| 1270 |
\def\tikz@lib@dv@about@linear#1{% |
| 1271 |
\tikz@lib@[email protected] in range interval()% |
| 1272 |
\pgfdvinrangeinterval.get min and max()% |
| 1273 |
\pgfdvmathsub{\tikz@lib@dv@diff}{\pgfdvmax}{\pgfdvmin} |
| 1274 |
\pgfdvmathenter{\tikz@lib@dv@about@val}{#1}% |
| 1275 |
\pgfdvmathdiv{\tikz@lib@dv@around}{\tikz@lib@dv@diff}{\tikz@lib@dv@about@val}% |
| 1276 |
% Make mantisse sensible |
| 1277 |
\pgfmathfloattomacro{\tikz@lib@dv@around}{\tikz@lib@dv@flags}{\tikz@lib@dv@mant}{\tikz@lib@dv@exp}% |
| 1278 |
\pgf@xc=\tikz@lib@dv@mant pt % |
| 1279 |
\pgfkeysgetvalue{/tikz/data visualization/about strategy}\tikz@lib@dv@strat |
| 1280 |
\foreach \tikz@lib@dv@threshold/\tikz@lib@replace in \tikz@lib@dv@strat |
| 1281 |
{ |
| 1282 |
\ifdim\pgf@xc<\tikz@lib@dv@threshold pt% |
| 1283 |
\global\pgf@xc=\tikz@lib@replace pt% |
| 1284 |
\breakforeach |
| 1285 |
\fi |
| 1286 |
}% |
| 1287 |
\ifdim\pgf@xc<10pt% |
| 1288 |
\pgfmathfloatcreate{\tikz@lib@dv@flags}{\pgf@sys@tonumber{\pgf@xc}}{\tikz@lib@dv@exp}% |
| 1289 |
\else |
| 1290 |
\begingroup |
| 1291 |
\c@pgf@countd=\tikz@lib@dv@exp |
| 1292 |
\advance\c@pgf@countd by1 |
| 1293 |
\edef\tikz@lib@dv@exp{\the\c@pgf@countd}% |
| 1294 |
\pgfmath@smuggleone\tikz@lib@dv@exp |
| 1295 |
\endgroup |
| 1296 |
\divide\pgf@xc by 10\relax |
| 1297 |
\pgfmathfloatcreate{\tikz@lib@dv@flags}{\pgf@sys@tonumber{\pgf@xc}}{\tikz@lib@dv@exp}% |
| 1298 |
\fi |
| 1299 |
\pgfmathfloattofixed{\pgfmathresult}% |
| 1300 |
\let\tikz@lib@dv@step=\pgfmathresult |
| 1301 |
}% |
| 1302 |
|
| 1303 |
|
| 1304 |
|
| 1305 |
|
| 1306 |
|
| 1307 |
% |
| 1308 |
% Logarithmic axes |
| 1309 |
% |
| 1310 |
|
| 1311 |
\tikzset{ |
| 1312 |
/tikz/data visualization/axis options/.cd, |
| 1313 |
exponential steps/.style={tick placement strategy=\tikz@lib@dv@compute@at@log}, |
| 1314 |
% |
| 1315 |
% Basic setters |
| 1316 |
% |
| 1317 |
logarithmic/.style={ |
| 1318 |
\tikz@dv@axis/function=\pgfdvmathln{\pgfvalue}{\pgfvalue}, |
| 1319 |
\tikz@dv@axis/scaling/default=1 at 0 and 10 at 1, |
| 1320 |
exponential steps |
| 1321 |
} |
| 1322 |
}% |
| 1323 |
|
| 1324 |
\def\tikz@lib@dv@compute@at@log{% |
| 1325 |
% Setup about: |
| 1326 |
\let\tikz@lib@dv@compute@about=\tikz@lib@dv@about@log% |
| 1327 |
\let\tikz@lib@dv@step\relax% |
| 1328 |
\pgfkeysvalueof{/tikz/data visualization/compute step} |
| 1329 |
\ifx\tikz@lib@dv@step\relax% |
| 1330 |
\else% |
| 1331 |
% Gather interesting values |
| 1332 |
\tikz@lib@[email protected] in range interval()% |
| 1333 |
\pgfdvinrangeinterval.get min and max()% |
| 1334 |
\pgfdvmathlog{\pgfdvminlog}{\pgfdvmin}% |
| 1335 |
\pgfdvmathlog{\pgfdvmaxlog}{\pgfdvmax}% |
| 1336 |
\pgfkeysgetvalue{/tikz/data visualization/phase}\tikz@temp |
| 1337 |
\pgfdvmathenter{\tikz@dv@lib@phase}{\tikz@temp} |
| 1338 |
\pgfdvmathenter{\tikz@dv@lib@step}{\tikz@lib@dv@step} |
| 1339 |
% Compute start: |
| 1340 |
\pgfdvmathsub{\tikz@dv@lib@temp}{\pgfdvminlog}{\tikz@dv@lib@phase}% temp = dvmin - phase |
| 1341 |
\pgfdvmathdiv{\tikz@dv@lib@temp}{\tikz@dv@lib@temp}{\tikz@dv@lib@step}% temp = temp/step |
| 1342 |
\pgfdvmathfloor{\tikz@dv@lib@temp}{\tikz@dv@lib@temp}% temp = floor(temp) |
| 1343 |
\pgfdvmathmul{\tikz@lib@dv@current}{\tikz@dv@lib@temp}{\tikz@dv@lib@step}% current = temp*step ... |
| 1344 |
\pgfdvmathadd{\tikz@lib@dv@current}{\tikz@lib@dv@current}{\tikz@dv@lib@phase}% + phase |
| 1345 |
\let\tikz@lib@dv@ats\pgfutil@empty% |
| 1346 |
\let\tikz@lib@dv@minor@ats\pgfutil@empty% |
| 1347 |
\pgfdvmathenter{\tikz@one@hundreth}{0.001}% |
| 1348 |
\pgfdvmathsub{\tikz@lib@temp}{\pgfdvmaxlog}{\pgfdvminlog}% |
| 1349 |
\pgfdvmathmul{\tikz@lib@dv@epsilon}{\tikz@lib@temp}{\tikz@one@hundreth}% epsilon = (max - min)/100 |
| 1350 |
\pgfdvmathsub{\tikz@lib@dv@min@minus@epsilon}{\pgfdvminlog}{\tikz@lib@dv@epsilon}% |
| 1351 |
\pgfdvmathadd{\tikz@lib@dv@max@plus@epsilon}{\pgfdvmaxlog}{\tikz@lib@dv@epsilon}% |
| 1352 |
\pgfkeysgetvalue{/tikz/data visualization/minor steps between steps}\tikz@lib@dv@substeps% |
| 1353 |
\ifx\tikz@lib@dv@substeps\pgfutil@empty |
| 1354 |
\else |
| 1355 |
\pgfmathsetmacro\tikz@temp{\tikz@lib@dv@substeps+1}% |
| 1356 |
\pgfdvmathenter{\tikz@dv@lib@substeps}{\tikz@temp}% |
| 1357 |
\fi |
| 1358 |
\loop% |
| 1359 |
\ifx\tikz@lib@dv@substeps\pgfutil@empty% |
| 1360 |
\else% |
| 1361 |
\let\tikz@lib@dv@subcurrent=\tikz@lib@dv@current% |
| 1362 |
\pgfdvmathadd{\tikz@lib@dv@subcurrent@next}{\tikz@lib@dv@subcurrent}{\tikz@dv@lib@step}% |
| 1363 |
\pgfdvmathpowten{\tikz@lib@dv@subcurrent}{\tikz@lib@dv@subcurrent}% |
| 1364 |
\pgfdvmathpowten{\tikz@lib@dv@subcurrent@max}{\tikz@lib@dv@subcurrent@next}% |
| 1365 |
\pgfdvmathsub{\tikz@lib@dv@subcurrent@diff}{\tikz@lib@dv@subcurrent@max}{\tikz@lib@dv@subcurrent}% |
| 1366 |
\pgfdvmathdiv{\tikz@lib@dv@substep}{\tikz@lib@dv@subcurrent@diff}{\tikz@dv@lib@substeps}% |
| 1367 |
\pgfmathsetcount{\c@pgf@counta}{\tikz@lib@dv@substeps}% |
| 1368 |
\let\tikz@lib@dv@next=\tikz@lib@dv@subloop% |
| 1369 |
\tikz@lib@dv@subloop |
| 1370 |
\fi% |
| 1371 |
\pgfdvmathifless{\tikz@lib@dv@current}{\tikz@lib@dv@min@minus@epsilon}{}{% |
| 1372 |
\pgfdvmathpowten{\tikz@lib@dv@current@pow}{\tikz@lib@dv@current}% |
| 1373 |
\pgfdvmathexitbyserializing{\tikz@temp}{\tikz@lib@dv@current@pow}% |
| 1374 |
\edef\tikz@lib@dv@ats{\tikz@lib@dv@ats,\tikz@temp}% |
| 1375 |
} |
| 1376 |
\pgfdvmathadd{\tikz@lib@dv@current}{\tikz@lib@dv@current}{\tikz@dv@lib@step}% |
| 1377 |
\pgfdvmathifless{\tikz@lib@dv@current}{\tikz@lib@dv@max@plus@epsilon}{\tikz@lib@dv@continuetrue}{\tikz@lib@dv@continuefalse}% |
| 1378 |
\iftikz@lib@dv@continue% |
| 1379 |
\repeat% |
| 1380 |
\tikzdatavisualizationset{major/.expanded={at={\tikz@lib@dv@ats}},minor/.expanded={at={\tikz@lib@dv@minor@ats}}}% |
| 1381 |
\fi% |
| 1382 |
}% |
| 1383 |
|
| 1384 |
|
| 1385 |
\def\tikz@lib@dv@about@log#1{% |
| 1386 |
\tikz@lib@[email protected] in range interval()% |
| 1387 |
\pgfdvinrangeinterval.get min and max()% |
| 1388 |
\pgfdvmathlog{\pgfdvmin}{\pgfdvmin}% |
| 1389 |
\pgfdvmathlog{\pgfdvmax}{\pgfdvmax}% |
| 1390 |
\pgfdvmathsub{\tikz@lib@dv@diff}{\pgfdvmax}{\pgfdvmin} |
| 1391 |
\pgfdvmathenter{\tikz@lib@dv@about@val}{#1}% |
| 1392 |
\pgfdvmathdiv{\tikz@lib@dv@around}{\tikz@lib@dv@diff}{\tikz@lib@dv@about@val}% |
| 1393 |
% Make mantisse sensible |
| 1394 |
\pgfmathfloattomacro{\tikz@lib@dv@around}{\tikz@lib@dv@flags}{\tikz@lib@dv@mant}{\tikz@lib@dv@exp} |
| 1395 |
\ifdim\tikz@lib@dv@exp pt<0pt% |
| 1396 |
\pgfmathfloatcreate{1}{1.0}{0}% |
| 1397 |
\else |
| 1398 |
\pgf@xc=\tikz@lib@dv@mant pt\relax% |
| 1399 |
\ifdim\pgf@xc<2.5pt |
| 1400 |
\pgfmathfloatcreate{1}{1.0}{\tikz@lib@dv@exp} |
| 1401 |
\else\ifdim\pgf@xc<5.1pt |
| 1402 |
\pgfmathfloatcreate{1}{3.0}{\tikz@lib@dv@exp} |
| 1403 |
\else |
| 1404 |
\pgfmathfloatcreate{1}{6.0}{\tikz@lib@dv@exp} |
| 1405 |
\fi\fi |
| 1406 |
\fi% |
| 1407 |
\pgfmathfloattofixed{\pgfmathresult} |
| 1408 |
\let\tikz@lib@dv@step=\pgfmathresult |
| 1409 |
}% |
| 1410 |
|
| 1411 |
|
| 1412 |
|
| 1413 |
|
| 1414 |
|
| 1415 |
|
| 1416 |
|
| 1417 |
% |
| 1418 |
% Cartesian axes |
| 1419 |
% |
| 1420 |
|
| 1421 |
\tikzdatavisualizationset{% |
| 1422 |
new Cartesian axis/.style={ |
| 1423 |
new axis base={#1}, |
| 1424 |
new object={ |
| 1425 |
class=linear transformer, |
| 1426 |
store=/tikz/data visualization/#1/linear transformer, |
| 1427 |
arg1/.expanded=\pgfkeysvalueof{/tikz/data visualization/#1/attribute}/scaled, |
| 1428 |
arg2 from key=/tikz/data visualization/#1/unit vector, |
| 1429 |
}, |
| 1430 |
#1/scaling/default/.initial=0 at 0 and 1 at 1cm, |
| 1431 |
#1/unit vector/.initial=\pgfqpoint{1pt}{0pt}, |
| 1432 |
} |
| 1433 |
}% |
| 1434 |
|
| 1435 |
\tikzset{ |
| 1436 |
/tikz/data visualization/axis options/.cd, |
| 1437 |
unit vector/.code=\tikz@scan@one@point\tikz@lib@dv@uv#1, |
| 1438 |
length/.style={\tikz@dv@axis/scaling=min at 0 and max at {#1}}, |
| 1439 |
unit length/.code={\tikz@dv@parse@unit@length{#1}}, |
| 1440 |
power unit length/.style={\tikz@dv@axis/scaling=1 at 0 and 10 at {#1}} |
| 1441 |
}% |
| 1442 |
|
| 1443 |
\def\tikz@lib@dv@uv#1{% |
| 1444 |
\pgfkeyssetvalue{\tikz@dv@axis/unit vector}{#1} |
| 1445 |
}% |
| 1446 |
|
| 1447 |
\def\tikz@dv@parse@unit@length#1{ |
| 1448 |
\pgfutil@in@{per}{#1} |
| 1449 |
\ifpgfutil@in@% |
| 1450 |
\tikz@dv@parse@unit@length@#1\pgf@stop% |
| 1451 |
\else% |
| 1452 |
\tikz@dv@parse@unit@length@#1per1units\pgf@stop% |
| 1453 |
\fi% |
| 1454 |
}% |
| 1455 |
\def\tikz@dv@parse@unit@length@#1per#2units\pgf@stop{ |
| 1456 |
\pgfkeysalso{\tikz@dv@axis/scaling=0 at 0 and {#2} at {#1}} |
| 1457 |
}% |
| 1458 |
|
| 1459 |
|
| 1460 |
% |
| 1461 |
% Common visualizer interface |
| 1462 |
% |
| 1463 |
|
| 1464 |
\tikzdatavisualizationset{ |
| 1465 |
new visualizer/.style n args={3}{ |
| 1466 |
#1/.code={ |
| 1467 |
\def\tikz@visualizer{#1}% |
| 1468 |
\pgfkeys{/tikz/data visualization/visualizer options/.cd,##1} |
| 1469 |
\pgf@dv@do@adddata{\pgfkeysvalueof{/pgf/data visualization/obj}.add data(\pgfkeys{/data point/set={#1}})}% |
| 1470 |
}, |
| 1471 |
/utils/exec={ |
| 1472 |
\advance\tikzdvvisualizercounter by 1\relax |
| 1473 |
\edef\tikz@temp{/data point/set/#1/.initial=\the\tikzdvvisualizercounter} |
| 1474 |
\expandafter\tikzset\expandafter{\tikz@temp} |
| 1475 |
}, |
| 1476 |
/data point/#1/execute at begin/.initial={ |
| 1477 |
\pgfkeyssetvalue{/data point/set}{#1} |
| 1478 |
\scope[ |
| 1479 |
#2, |
| 1480 |
/tikz/data visualization/every visualizer/.try, |
| 1481 |
/tikz/data visualization/visualizers/#1/signal, |
| 1482 |
/tikz/data visualization/visualizers/#1/styling/.try] |
| 1483 |
}, |
| 1484 |
/data point/#1/execute at end/.initial={ |
| 1485 |
\path; % invokes every path implicitly |
| 1486 |
\endscope |
| 1487 |
}, |
| 1488 |
/tikz/data visualization/visualizers/#1/signal/.code=\[email protected](), |
| 1489 |
/tikz/data visualization/visualizers/#1/styling/.style=, |
| 1490 |
/tikz/data visualization/visualizers/#1/label in legend options/.style={#3}, |
| 1491 |
}, |
| 1492 |
style sheet/.style={/data point/set/.style sheet={#1}}, |
| 1493 |
/pgf/data/set/.style={/data point/set={#1}}, |
| 1494 |
}% |
| 1495 |
|
| 1496 |
\tikzdatavisualizationset{ |
| 1497 |
new sub visualizer/.style n args={4}{ |
| 1498 |
#4/#1/.code={ |
| 1499 |
\def\tikz@visualizer{#4/#1}% |
| 1500 |
\pgfkeys{/tikz/data visualization/visualizer options/.cd,##1} |
| 1501 |
}, |
| 1502 |
/data point/#4/#1/execute at begin/.initial={ |
| 1503 |
\pgfkeyssetvalue{/data point/set}{#4} |
| 1504 |
\scope[ |
| 1505 |
#2, |
| 1506 |
/tikz/data visualization/every visualizer/.try, |
| 1507 |
/tikz/data visualization/visualizers/#4/signal, |
| 1508 |
/tikz/data visualization/visualizers/#4/styling/.try, |
| 1509 |
/tikz/data visualization/visualizers/#4/#1/styling/.try] |
| 1510 |
}, |
| 1511 |
/data point/#4/#1/execute at end/.initial={ |
| 1512 |
\path; % invokes every path implicitly |
| 1513 |
\endscope |
| 1514 |
}, |
| 1515 |
/tikz/data visualization/visualizers/#4/#1/styling/.style=, |
| 1516 |
/tikz/data visualization/visualizers/#4/#1/label in legend options/.style={#3}, |
| 1517 |
} |
| 1518 |
}% |
| 1519 |
|
| 1520 |
|
| 1521 |
\def\tikz@do@visualizer#1#2{% |
| 1522 |
\tikzdatavisualizationset{ |
| 1523 |
#2={#1} |
| 1524 |
} |
| 1525 |
}% |
| 1526 |
|
| 1527 |
\newcount\tikzdvvisualizercounter |
| 1528 |
|
| 1529 |
\newif\iftikz@dv@visualizer@label@inline |
| 1530 |
|
| 1531 |
\tikzdatavisualizationset{visualizer options/.cd, |
| 1532 |
@set/.style 2 args={ |
| 1533 |
/tikz/data visualization/visualizers/\tikz@visualizer/styling/.append style={/utils/exec={\let\tikz@dv@plot@handler=#1}}, |
| 1534 |
/tikz/data visualization/visualizers/\tikz@visualizer/label in legend options/.append style={#2} |
| 1535 |
}, |
| 1536 |
no lines/.style={@set={\pgfplothandlerdiscard}{default label in legend mark}}, |
| 1537 |
smooth line/.style={@set={\pgfplothandlercurveto}{default label in legend path}}, |
| 1538 |
smooth cycle/.style={@set={\pgfplothandlerclosedcurve}{default label in legend closed path}}, |
| 1539 |
straight line/.style={@set={\pgfplothandlerlineto}{default label in legend path}}, |
| 1540 |
straight cycle/.style={@set={\pgfplothandlerpolygon}{default label in legend closed path}}, |
| 1541 |
polygon/.style={straight cycle},% alias |
| 1542 |
gap line/.style={@set={\pgfplothandlergaplineto}{default label in legend path}}, |
| 1543 |
gap cycle/.style={@set={\pgfplothandlergapcycle}{gap circular label in legend line}} |
| 1544 |
}% |
| 1545 |
|
| 1546 |
|
| 1547 |
|
| 1548 |
% |
| 1549 |
% Label visualizer |
| 1550 |
% |
| 1551 |
|
| 1552 |
\tikzdatavisualizationset{ |
| 1553 |
new label visualizer/.style 2 args={ |
| 1554 |
new object={ |
| 1555 |
when=before visualization, |
| 1556 |
class=label visualizer, |
| 1557 |
before creation={ |
| 1558 |
\begingroup |
| 1559 |
\def\tikz@visualizer{#1}% |
| 1560 |
\pgfkeys{/tikz/data visualization/visualizer label options/.cd, |
| 1561 |
#2} |
| 1562 |
\pgfkeysgetvalue{/tikz/data visualization/visualizer label options/text}\tikz@dv@temp@lab |
| 1563 |
\def\tikz@tempa{ |
| 1564 |
\scope[ |
| 1565 |
/utils/exec=\def\tikz@visualizer{#1},% |
| 1566 |
/tikz/data visualization/visualizer label options/.cd, |
| 1567 |
#2] |
| 1568 |
\tikzdatavisualizationset{every data set label/.try} |
| 1569 |
\path [ |
| 1570 |
/data point/set={#1},/utils/exec=\[email protected](), |
| 1571 |
/tikz/data visualization/.cd,every label in data/.try] |
| 1572 |
(label visualizer coordinate') -- |
| 1573 |
(label visualizer coordinate) |
| 1574 |
node [ |
| 1575 |
auto, |
| 1576 |
at end, |
| 1577 |
/tikz/data visualization/node styling] |
| 1578 |
} |
| 1579 |
\expandafter\def\expandafter\tikz@tempb\expandafter{\expandafter{\tikz@dv@temp@lab};}% |
| 1580 |
\expandafter\expandafter\expandafter\gdef% |
| 1581 |
\expandafter\expandafter\expandafter\tikz@dv@label@code% |
| 1582 |
\expandafter\expandafter\expandafter{\expandafter\expandafter\expandafter\relax% |
| 1583 |
\expandafter\expandafter\expandafter{\expandafter\tikz@tempa\tikz@tempb\endscope}} |
| 1584 |
\global\let\tikz@dv@label@attribute=\tikz@dv@label@attribute |
| 1585 |
\global\let\tikz@dv@label@threshold=\tikz@dv@label@threshold |
| 1586 |
\endgroup |
| 1587 |
}, |
| 1588 |
arg1/.expand once=\tikz@dv@label@attribute, |
| 1589 |
arg2=\tikz@dv@label@threshold, |
| 1590 |
arg3/.expand once=\tikz@dv@label@code, |
| 1591 |
arg4=\pgfdvvisualizerfilter{#1} |
| 1592 |
}, |
| 1593 |
/utils/exec=\tikz@create@label@count{#1} |
| 1594 |
}, |
| 1595 |
% Label style |
| 1596 |
text colored/.style={node style={text=visualizer color}} |
| 1597 |
}% |
| 1598 |
|
| 1599 |
\def\tikz@create@label@count#1{ |
| 1600 |
\tikzdatavisualizationset{ |
| 1601 |
new object={ |
| 1602 |
when=before survey, |
| 1603 |
store=/tikz/data visualization/visualizers/#1/count/obj, |
| 1604 |
class=count, |
| 1605 |
arg1=set/#1/count, |
| 1606 |
after creation={\tikzdvobj.set filter(\pgfdvvisualizerfilter{#1})} |
| 1607 |
} |
| 1608 |
} |
| 1609 |
}% |
| 1610 |
|
| 1611 |
\pgfkeys{ |
| 1612 |
/tikz/data visualization/visualizer label options/.cd, |
| 1613 |
when/.code args={#1 is#2}{% |
| 1614 |
\def\tikz@dv@label@attribute{#1}% |
| 1615 |
\def\tikz@dv@label@threshold{#2}% |
| 1616 |
}, |
| 1617 |
index/.code={% |
| 1618 |
\edef\tikz@dv@label@attribute{set/\tikz@visualizer/count}% |
| 1619 |
\def\tikz@dv@label@threshold{#1}% |
| 1620 |
}, |
| 1621 |
pos/.code={% |
| 1622 |
\edef\tikz@dv@label@attribute{set/\tikz@visualizer/count}% |
| 1623 |
\pgfkeysvalueof{/tikz/data visualization/visualizers/\tikz@visualizer/count/obj}.get max(\tikz@lib@max) |
| 1624 |
\edef\tikz@dv@label@threshold{(#1*\tikz@lib@max)}% |
| 1625 |
}, |
| 1626 |
auto/.code={% |
| 1627 |
\edef\tikz@dv@label@attribute{set/\tikz@visualizer/count}% |
| 1628 |
\pgfkeysvalueof{/tikz/data visualization/visualizers/\tikz@visualizer/count/obj}.get max(\tikz@lib@max) |
| 1629 |
\edef\tikz@dv@label@threshold{({(\pgfkeysvalueof{/data point/set/\tikz@visualizer}-0.5)/\the\tikzdvvisualizercounter*\tikz@lib@max})} |
| 1630 |
}, |
| 1631 |
text/.initial=, |
| 1632 |
text'/.style={text={#1},node style=swap,/utils/exec=\def\tikz@lib@dv@pin@sign{-}}, |
| 1633 |
node style/.style={/tikz/data visualization/node style={#1}}, |
| 1634 |
text colored/.style=/tikz/data visualization/text colored, |
| 1635 |
pin angle/.store in=\tikz@lib@dv@pin@dir, |
| 1636 |
pin length/.style={node style={pin distance={#1}}}, |
| 1637 |
}% |
| 1638 |
|
| 1639 |
\let\tikz@lib@dv@pin@sign\pgfutil@empty |
| 1640 |
|
| 1641 |
\let\tikz@dv@label@attribute\pgfutil@empty |
| 1642 |
\let\tikz@dv@label@threshold\pgfutil@empty |
| 1643 |
\let\tikz@dv@label@code\pgfutil@empty |
| 1644 |
|
| 1645 |
|
| 1646 |
|
| 1647 |
|
| 1648 |
% |
| 1649 |
% Legend handling |
| 1650 |
% |
| 1651 |
|
| 1652 |
\tikzdatavisualizationset{ |
| 1653 |
new legend/.code={ |
| 1654 |
\pgfkeysifdefined{/tikz/data visualization/#1/at}{} |
| 1655 |
{\tikzdatavisualizationset{ |
| 1656 |
new object={ |
| 1657 |
class=legend, |
| 1658 |
store=/tikz/data visualization/#1/obj, |
| 1659 |
arg1 from key=/tikz/data visualization/#1/@columns or rows, |
| 1660 |
arg2 from key=/tikz/data visualization/#1/@ideal, |
| 1661 |
arg3 from key=/tikz/data visualization/#1/max entries, |
| 1662 |
arg4 from key=/tikz/data visualization/#1/@strategy, |
| 1663 |
after creation={ |
| 1664 |
\tikzdatavisualizationset{ |
| 1665 |
legend actions/.append={ |
| 1666 |
\pgfkeysgetvalue{/tikz/data visualization/#1/obj}\pgf@dv@legend% |
| 1667 |
{ |
| 1668 |
\pgf@[email protected] arrangement(\pgf@dv@temp)% |
| 1669 |
\pgfkeysgetvalue{/tikz/data visualization/#1/at}\pgf@dv@at% |
| 1670 |
\pgfkeysgetvalue{/tikz/data visualization/#1/anchor}\pgf@dv@anchor% |
| 1671 |
\let\pgfdvnextcell=\pgfmatrixnextcell% |
| 1672 |
\let\pgfdvendrow=\pgfmatrixendrow% |
| 1673 |
\def\pgf@marshal{ |
| 1674 |
\matrix[at/.expand once=\pgf@dv@at,matrix anchor/.expand |
| 1675 |
once=\pgf@dv@anchor,/tikz/data visualization/#1/matrix node styling] |
| 1676 |
} |
| 1677 |
\expandafter\pgf@marshal\expandafter{\pgf@dv@temp}; |
| 1678 |
} |
| 1679 |
} |
| 1680 |
} |
| 1681 |
} |
| 1682 |
}, |
| 1683 |
#1/@columns or rows/.initial=columns, |
| 1684 |
#1/@ideal/.initial=1, |
| 1685 |
#1/max entries/.initial=100, |
| 1686 |
#1/@strategy/.initial=down then right, |
| 1687 |
#1/anchor/.initial=west, |
| 1688 |
#1/at/.initial=(data visualization bounding box.east), |
| 1689 |
#1/matrix node styling/.style={row sep=0pt,column sep=.8em}, |
| 1690 |
% |
| 1691 |
% |
| 1692 |
% |
| 1693 |
#1/.code={ |
| 1694 |
\let\tikz@temp\tikz@dv@legend% |
| 1695 |
\def\tikz@dv@legend{/tikz/data visualization/#1}% |
| 1696 |
\expandafter\tikz@do@legend@options\expandafter{\tikz@temp}{##1}% |
| 1697 |
}, |
| 1698 |
#1={every new legend} |
| 1699 |
}}}, |
| 1700 |
new legend/.default=main legend, |
| 1701 |
legend/.style={ |
| 1702 |
new legend, |
| 1703 |
main legend={#1} |
| 1704 |
} |
| 1705 |
}% |
| 1706 |
|
| 1707 |
\def\tikz@do@legend@options#1#2{ |
| 1708 |
\pgfkeys{/tikz/data visualization/legend options/.cd,#2} |
| 1709 |
\def\tikz@dv@legend{#1} |
| 1710 |
}% |
| 1711 |
\let\tikz@dv@legend\pgfutil@empty |
| 1712 |
|
| 1713 |
|
| 1714 |
\tikzset{ |
| 1715 |
/tikz/data visualization/legend options/.cd, |
| 1716 |
% |
| 1717 |
% How to arrange the entries in the legend |
| 1718 |
% |
| 1719 |
ideal number of columns/.style={\tikz@dv@legend/@columns or rows=columns,\tikz@dv@legend/@ideal={#1}}, |
| 1720 |
ideal number of rows/.style={\tikz@dv@legend/@columns or rows=rows,\tikz@dv@legend/@ideal={#1}}, |
| 1721 |
columns/.style={ideal number of columns={#1}},% alias |
| 1722 |
rows/.style={ideal number of rows={#1}},% alias |
| 1723 |
max rows/.style={\tikz@dv@legend/@columns or rows=columns,\tikz@dv@legend/max entries={#1}}, |
| 1724 |
max columns/.style={\tikz@dv@legend/@columns or rows=rows,\tikz@dv@legend/max entries={#1}}, |
| 1725 |
down then right/.style={\tikz@dv@legend/@strategy=down then right}, |
| 1726 |
down then left/.style={\tikz@dv@legend/@strategy=down then left}, |
| 1727 |
up then right/.style={\tikz@dv@legend/@strategy=up then right}, |
| 1728 |
up then left/.style={\tikz@dv@legend/@strategy=up then left}, |
| 1729 |
right then down/.style={\tikz@dv@legend/@strategy=right then down}, |
| 1730 |
left then down/.style={\tikz@dv@legend/@strategy=left then down}, |
| 1731 |
right then up/.style={\tikz@dv@legend/@strategy=right then up}, |
| 1732 |
left then up/.style={\tikz@dv@legend/@strategy=left then up}, |
| 1733 |
% |
| 1734 |
% Where to put the legend |
| 1735 |
% |
| 1736 |
anchor/.style={\tikz@dv@legend/anchor={#1}}, |
| 1737 |
at/.style={\tikz@dv@legend/at={#1}}, |
| 1738 |
% Outer placements |
| 1739 |
right/.style={east outside}, |
| 1740 |
left/.style={west outside}, |
| 1741 |
above/.style={north outside}, |
| 1742 |
below/.style={south outside}, |
| 1743 |
east outside/.style={ |
| 1744 |
columns=1, |
| 1745 |
at={([xshift=.8em]data visualization bounding box.east)}, |
| 1746 |
anchor=west, |
| 1747 |
}, |
| 1748 |
north east outside/.style={ |
| 1749 |
columns=1, |
| 1750 |
at={([xshift=.8em]data visualization bounding box.north east|- |
| 1751 |
data bounding box.north)}, |
| 1752 |
anchor=north west, |
| 1753 |
}, |
| 1754 |
south east outside/.style={ |
| 1755 |
columns=1, |
| 1756 |
at={([xshift=.8em]data visualization bounding box.south east |- |
| 1757 |
data bounding box.south)}, |
| 1758 |
anchor=south west, |
| 1759 |
}, |
| 1760 |
west outside/.style={ |
| 1761 |
columns=1, |
| 1762 |
label style=text left, |
| 1763 |
at={([xshift=-.8em]data visualization bounding box.west)}, |
| 1764 |
anchor=east, |
| 1765 |
}, |
| 1766 |
north west outside/.style={ |
| 1767 |
columns=1, |
| 1768 |
label style=text left, |
| 1769 |
at={([xshift=-.8em]data visualization bounding box.north west |- |
| 1770 |
data bounding box.north)}, |
| 1771 |
anchor=north east, |
| 1772 |
}, |
| 1773 |
south west outside/.style={ |
| 1774 |
columns=1, |
| 1775 |
label style=text left, |
| 1776 |
at={([xshift=-.8em]data visualization bounding box.south west |- |
| 1777 |
data bounding box.south)}, |
| 1778 |
anchor=south east, |
| 1779 |
}, |
| 1780 |
south outside/.style={ |
| 1781 |
rows=1, |
| 1782 |
at={([yshift=-.5em]data visualization bounding box.south)}, |
| 1783 |
anchor=north, |
| 1784 |
}, |
| 1785 |
north outside/.style={ |
| 1786 |
rows=1, |
| 1787 |
at={([yshift=.5em]data visualization bounding box.north)}, |
| 1788 |
anchor=south, |
| 1789 |
}, |
| 1790 |
every new legend/.style={east outside,label style=text right}, |
| 1791 |
% |
| 1792 |
% Inner placements |
| 1793 |
% |
| 1794 |
% First, styling |
| 1795 |
every legend inside/.style={ |
| 1796 |
opaque=white, |
| 1797 |
label style={node style={font=\pgfutil@font@footnotesize}} |
| 1798 |
}, |
| 1799 |
opaque/.style={ |
| 1800 |
matrix node style={ |
| 1801 |
inner sep=.333ex, |
| 1802 |
outer sep=.5ex, |
| 1803 |
rounded corners=3pt, |
| 1804 |
execute at begin cell={\tikzset{sharp corners}}, % get rid of |
| 1805 |
% rounded corners in cells of the |
| 1806 |
% legend matrix |
| 1807 |
fill=#1 |
| 1808 |
}, |
| 1809 |
}, |
| 1810 |
opaque/.default=white, |
| 1811 |
transparent/.style={matrix node style={fill=none}}, |
| 1812 |
% Second, the placements |
| 1813 |
north east inside/.style={ |
| 1814 |
columns=1, |
| 1815 |
at={([xshift=-.3em]data bounding box.north east)}, |
| 1816 |
anchor=north east, |
| 1817 |
every legend inside |
| 1818 |
}, |
| 1819 |
south west inside/.style={ |
| 1820 |
columns=1, |
| 1821 |
at={([xshift=.3em]data bounding box.south west)}, |
| 1822 |
anchor=south west, |
| 1823 |
every legend inside |
| 1824 |
}, |
| 1825 |
north west inside/.style={ |
| 1826 |
columns=1, |
| 1827 |
at={([xshift=.3em]data bounding box.north west)}, |
| 1828 |
anchor=north west, |
| 1829 |
every legend inside |
| 1830 |
}, |
| 1831 |
south east inside/.style={ |
| 1832 |
columns=1, |
| 1833 |
at={([xshift=-.3em]data bounding box.south east)}, |
| 1834 |
anchor=south east, |
| 1835 |
every legend inside |
| 1836 |
}, |
| 1837 |
west inside/.style={ |
| 1838 |
columns=1, |
| 1839 |
at={([xshift=.3em]data bounding box.west)}, |
| 1840 |
anchor=west, |
| 1841 |
every legend inside |
| 1842 |
}, |
| 1843 |
east inside/.style={ |
| 1844 |
columns=1, |
| 1845 |
at={([xshift=.3em]data bounding box.east)}, |
| 1846 |
anchor=east, |
| 1847 |
every legend inside |
| 1848 |
}, |
| 1849 |
north inside/.style={ |
| 1850 |
rows=1, |
| 1851 |
at={(data bounding box.north)}, |
| 1852 |
anchor=north, |
| 1853 |
every legend inside |
| 1854 |
}, |
| 1855 |
south inside/.style={ |
| 1856 |
rows=1, |
| 1857 |
at={(data bounding box.south)}, |
| 1858 |
anchor=south, |
| 1859 |
every legend inside |
| 1860 |
}, |
| 1861 |
% Additional inner placements |
| 1862 |
at values/.style={ |
| 1863 |
at={(visualization cs:#1)}, |
| 1864 |
anchor=center, |
| 1865 |
every legend inside |
| 1866 |
}, |
| 1867 |
right of/.style={ |
| 1868 |
at={(visualization cs:#1)}, |
| 1869 |
anchor=west, |
| 1870 |
every legend inside |
| 1871 |
}, |
| 1872 |
left of/.style={ |
| 1873 |
at={(visualization cs:#1)}, |
| 1874 |
anchor=east, |
| 1875 |
every legend inside |
| 1876 |
}, |
| 1877 |
above of/.style={ |
| 1878 |
at={(visualization cs:#1)}, |
| 1879 |
anchor=south, |
| 1880 |
every legend inside |
| 1881 |
}, |
| 1882 |
below of/.style={ |
| 1883 |
at={(visualization cs:#1)}, |
| 1884 |
anchor=north, |
| 1885 |
every legend inside |
| 1886 |
}, |
| 1887 |
above right of/.style={ |
| 1888 |
at={(visualization cs:#1)}, |
| 1889 |
anchor=south west, |
| 1890 |
every legend inside |
| 1891 |
}, |
| 1892 |
above left of/.style={ |
| 1893 |
at={(visualization cs:#1)}, |
| 1894 |
anchor=south east, |
| 1895 |
every legend inside |
| 1896 |
}, |
| 1897 |
below right of/.style={ |
| 1898 |
at={(visualization cs:#1)}, |
| 1899 |
anchor=north west, |
| 1900 |
every legend inside |
| 1901 |
}, |
| 1902 |
below left of/.style={ |
| 1903 |
at={(visualization cs:#1)}, |
| 1904 |
anchor=north east, |
| 1905 |
every legend inside |
| 1906 |
}, |
| 1907 |
% |
| 1908 |
% |
| 1909 |
% |
| 1910 |
% Label text styling |
| 1911 |
% |
| 1912 |
label style/.style={ |
| 1913 |
matrix node style={/tikz/data visualization/every label in legend/.append style={#1}} |
| 1914 |
}, |
| 1915 |
% |
| 1916 |
% Styling |
| 1917 |
% |
| 1918 |
matrix node style/.style={\tikz@dv@legend/matrix node styling/.append style={#1}}, |
| 1919 |
}% |
| 1920 |
|
| 1921 |
|
| 1922 |
\tikzdatavisualizationset{ |
| 1923 |
new legend entry/.code={ |
| 1924 |
\begingroup |
| 1925 |
\pgfkeys{/tikz/data visualization/legend entry options/.cd,#1} |
| 1926 |
\pgfkeysgetvalue{/tikz/data visualization/legend entry options/legend}\tikz@dv@temp@legend |
| 1927 |
\global\let\tikz@dv@temp@legend\tikz@dv@temp@legend |
| 1928 |
\endgroup |
| 1929 |
\tikzdatavisualizationset{new legend/.expanded=\tikz@dv@temp@legend}% |
| 1930 |
\expandafter\tikz@dv@add@legend@entry\expandafter{\tikz@dv@temp@legend}{#1} |
| 1931 |
} |
| 1932 |
}% |
| 1933 |
|
| 1934 |
\def\tikz@dv@add@legend@entry#1#2{ |
| 1935 |
\tikz@[email protected] start survey({ |
| 1936 |
\pgfkeysgetvalue{/tikz/data visualization/#1/obj}\pgf@temp |
| 1937 |
\[email protected] entry(\tikz@dv@render@legend@entry{legend=#1,#2}) |
| 1938 |
}) |
| 1939 |
}% |
| 1940 |
|
| 1941 |
\def\tikz@dv@render@legend@entry#1{ |
| 1942 |
\pgfkeys{/tikz/data visualization/.cd,every data set label} |
| 1943 |
\pgfkeys{/tikz/data visualization/legend entry options/.cd, |
| 1944 |
/tikz/data visualization/every label in legend,#1}% |
| 1945 |
\pgfkeysgetvalue{/tikz/data visualization/legend entry options/text}\tikz@dv@temp@lab |
| 1946 |
\pgfkeysgetvalue{/tikz/data visualization/@node styling}\tikz@dv@temp@style |
| 1947 |
\pgfkeysgetvalue{/tikz/data visualization/legend entry options/setup}\tikz@dv@temp@setup |
| 1948 |
\pgfkeysgetvalue{/tikz/data visualization/legend entry options/visualizer in legend styling}\tikz@dv@temp@visual@styling |
| 1949 |
\scope[/utils/exec=\expandafter\pgfkeysalso\expandafter{\tikz@dv@temp@setup}, |
| 1950 |
/utils/exec=\[email protected]()] |
| 1951 |
\node[/tikz/data visualization/node styling, |
| 1952 |
/utils/exec=\expandafter\pgfkeysalso\expandafter{\tikz@dv@temp@style}] |
| 1953 |
{\tikz@dv@pre@height\tikz@dv@temp@lab\tikz@dv@post@height}; |
| 1954 |
\scope[/utils/exec=\expandafter\pgfkeysalso\expandafter{\tikz@dv@temp@visual@styling}] |
| 1955 |
\iftikz@lib@dv@text@only |
| 1956 |
\else |
| 1957 |
\pgfkeysvalueof{/tikz/data visualization/legend entry options/visualizer in legend} |
| 1958 |
\fi |
| 1959 |
\endscope |
| 1960 |
\endscope |
| 1961 |
}% |
| 1962 |
|
| 1963 |
\def\tikz@dv@pre@height{\hbox{\vrule height .75em width0pt}}% |
| 1964 |
\def\tikz@dv@post@height{\hbox{\vrule depth .25em width0pt}}% |
| 1965 |
|
| 1966 |
|
| 1967 |
|
| 1968 |
\pgfkeys{ |
| 1969 |
/tikz/data visualization/legend entry options/.cd, |
| 1970 |
% |
| 1971 |
% General options |
| 1972 |
% |
| 1973 |
text/.initial=, |
| 1974 |
node style/.style={/tikz/data visualization/node style={#1}}, |
| 1975 |
legend/.initial=main legend, |
| 1976 |
setup/.initial=, |
| 1977 |
visualizer in legend/.initial=, |
| 1978 |
visualizer in legend styling/.initial=, |
| 1979 |
visualizer in legend style/.style={visualizer in legend styling/.append={,#1}}, |
| 1980 |
% |
| 1981 |
% Legend visualizers for plots |
| 1982 |
% |
| 1983 |
text right/.style={ |
| 1984 |
node style={anchor=mid west,inner ysep=1pt,inner xsep=0pt,reset cm,xshift=.333em}, |
| 1985 |
visualizer in legend style={reset cm}, |
| 1986 |
}, |
| 1987 |
text left/.style={ |
| 1988 |
node style={anchor=mid east,inner ysep=1pt,inner xsep=0pt,reset |
| 1989 |
cm,xshift=-.333em,align=right}, |
| 1990 |
visualizer in legend style={reset cm,xscale=-1}, |
| 1991 |
}, |
| 1992 |
text only/.style={ |
| 1993 |
node style={anchor=mid west,inner ysep=1pt,inner xsep=0pt,reset cm,text=visualizer color}, |
| 1994 |
/utils/exec=\tikz@lib@dv@text@onlytrue |
| 1995 |
}, |
| 1996 |
text colored/.style=/tikz/data visualization/text colored, |
| 1997 |
}% |
| 1998 |
\let\tikz@lib@dv@pin@dir\pgfutil@empty |
| 1999 |
\newif\iftikz@lib@dv@text@only |
| 2000 |
|
| 2001 |
\pgfkeys{ |
| 2002 |
/tikz/data visualization/visualizer options/.cd, |
| 2003 |
label in legend/.code={\expandafter\tikz@dv@new@label@in@legend@for@visualizer\expandafter{\tikz@visualizer}{#1}}, |
| 2004 |
label in data/.code=\tikzdatavisualizationset{new label visualizer/.expand once=\expandafter{\tikz@visualizer}{auto,#1}}, |
| 2005 |
pin in data/.style={label in data={% |
| 2006 |
node style={% |
| 2007 |
/utils/exec={ |
| 2008 |
\ifx\tikz@lib@dv@pin@dir\pgfutil@empty |
| 2009 |
\pgf@process{\pgfpointnormalised{% |
| 2010 |
\pgfpointdiff% |
| 2011 |
{\pgfpointanchor{label visualizer coordinate}{center}}% |
| 2012 |
{\pgfpointanchor{label visualizer coordinate'}{center}}}}% |
| 2013 |
\pgf@x=-\pgf@x\relax% |
| 2014 |
\edef\tikz@lib@dv@temp@rot{\noexpand\pgfqpoint{\the\pgf@y}{\the\pgf@x}}% |
| 2015 |
\tikz@addtransform{\pgftransformshift{\pgfpointscale{\tikz@lib@dv@pin@sign\tikz@pin@distance}{\tikz@lib@dv@temp@rot}}} |
| 2016 |
\else% |
| 2017 |
\tikz@addtransform{\pgftransformshift{\pgfpointpolar{\tikz@lib@dv@pin@dir}{\tikz@lib@dv@pin@sign\tikz@pin@distance}}} |
| 2018 |
\fi% |
| 2019 |
}, |
| 2020 |
append after command={ |
| 2021 |
\bgroup |
| 2022 |
[current point is local=true] |
| 2023 |
(\tikzlastnode) edge [solid, every pin edge] (label visualizer coordinate) |
| 2024 |
\egroup% |
| 2025 |
}}, |
| 2026 |
,#1}}, |
| 2027 |
style/.style={/tikz/data visualization/visualizers/\tikz@visualizer/styling/.append style={,#1}}, |
| 2028 |
label in legend options/.style={/tikz/data visualization/visualizers/\tikz@visualizer/label in legend options/.append style={,#1}}, |
| 2029 |
ignore style sheets/.style={/tikz/data visualization/visualizers/\tikz@visualizer/signal/.code=,/utils/exec=\advance\tikzdvvisualizercounter by -1\relax}, |
| 2030 |
}% |
| 2031 |
|
| 2032 |
\def\tikz@dv@new@label@in@legend@for@visualizer#1#2{ |
| 2033 |
\tikzdatavisualizationset{ |
| 2034 |
new legend entry={ |
| 2035 |
visualizer in legend style={/tikz/data visualization/visualizers/#1/styling/.try}, |
| 2036 |
/tikz/data visualization/every label in legend/.try, |
| 2037 |
/tikz/.cd, |
| 2038 |
every label/.try, |
| 2039 |
/tikz/data visualization/legend entry options/.cd, |
| 2040 |
setup={/data point/set={#1}}, |
| 2041 |
/tikz/data visualization/visualizers/#1/label in legend options/.try, |
| 2042 |
#2, |
| 2043 |
} |
| 2044 |
} |
| 2045 |
}% |
| 2046 |
|
| 2047 |
\def\tikz@dv@legend@entry@as@example{ |
| 2048 |
\pgfkeysgetvalue{/data point/set}{\tikz@visualizer} |
| 2049 |
\pgfkeysvalueof{/data point/\tikz@visualizer/execute at begin} |
| 2050 |
\tikz@dv@plot@handler |
| 2051 |
\pgfplotstreamstart |
| 2052 |
\pgfkeysgetvalue{/tikz/data visualization/legend entry options/label in legend line coordinates}{\tikz@dv@temp} |
| 2053 |
\foreach \coordinate in \tikz@dv@temp |
| 2054 |
{ \pgfplotstreampoint{\expandafter\tikz@scan@one@point\expandafter\pgfutil@firstofone\coordinate} } |
| 2055 |
\pgfplotstreamend |
| 2056 |
\pgfkeysvalueof{/data point/\tikz@visualizer/execute at end} |
| 2057 |
\pgfkeysvalueof{/data point/\tikz@visualizer/execute at begin} |
| 2058 |
\tikz@dv@plot@mark@maker |
| 2059 |
\pgfplotstreamstart |
| 2060 |
\pgfkeysgetvalue{/tikz/data visualization/legend entry options/label in legend mark coordinates}{\tikz@dv@temp} |
| 2061 |
\foreach \coordinate in \tikz@dv@temp |
| 2062 |
{ \pgfplotstreampoint{\expandafter\tikz@scan@one@point\expandafter\pgfutil@firstofone\coordinate} } |
| 2063 |
\pgfplotstreamend |
| 2064 |
\pgfkeysvalueof{/data point/\tikz@visualizer/execute at end} |
| 2065 |
}% |
| 2066 |
|
| 2067 |
|
| 2068 |
\tikzdatavisualizationset{ |
| 2069 |
legend entry options/.cd, |
| 2070 |
label in legend line coordinates/.initial=, |
| 2071 |
label in legend rectangle coordinates/.initial={(-1ex,-.5ex),(-1ex,0.968ex),(0ex,0.968ex),(0ex,-.5ex)}, |
| 2072 |
label in legend mark coordinates/.initial=, |
| 2073 |
label in legend one mark/.style={ |
| 2074 |
label in legend line coordinates={}, |
| 2075 |
label in legend mark coordinates={(0,0)}, |
| 2076 |
}, |
| 2077 |
label in legend three marks/.style={ |
| 2078 |
label in legend line coordinates={}, |
| 2079 |
label in legend mark coordinates={(-3ex,-.3ex),(-1.5ex,.3ex),(0,0)}, |
| 2080 |
}, |
| 2081 |
straight label in legend line/.style={ |
| 2082 |
label in legend line coordinates={(-2em,0),(-1.5em,0),(-.5em,0),(0,0)}, |
| 2083 |
label in legend mark coordinates={(-1.5em,0),(-.5em,0)}, |
| 2084 |
}, |
| 2085 |
zig zag label in legend line/.style={ |
| 2086 |
label in legend line coordinates={(-2em,0),(-1.5em,.3ex),(-.5em,-.3ex),(0,0)}, |
| 2087 |
label in legend mark coordinates={(-1.5em,.3ex),(-.5em,-.3ex)}, |
| 2088 |
}, |
| 2089 |
circular label in legend line/.style={ |
| 2090 |
label in legend line coordinates={% |
| 2091 |
([xshift=-1em]0:.9em and .35ex),% |
| 2092 |
([xshift=-1em]45:.9em and .35ex),% |
| 2093 |
([xshift=-1em]90:.9em and .35ex),% |
| 2094 |
([xshift=-1em]135:.9em and .35ex),% |
| 2095 |
([xshift=-1em]180:.9em and .35ex),% |
| 2096 |
([xshift=-1em]225:.9em and .35ex),% |
| 2097 |
([xshift=-1em]270:.9em and .35ex),% |
| 2098 |
([xshift=-1em]315:.9em and .35ex)},% |
| 2099 |
label in legend mark coordinates={([xshift=-1em]120:.9em and .35ex),([xshift=-1em]-60:.9em and .35ex)}, |
| 2100 |
}, |
| 2101 |
gap circular label in legend line/.style={ |
| 2102 |
label in legend line coordinates={% |
| 2103 |
([xshift=-1em,yshift=.2ex]90:1.4ex and 0.9ex),% |
| 2104 |
([xshift=-1em,yshift=.2ex]162:1.4ex and 0.9ex),% |
| 2105 |
([xshift=-1em,yshift=.2ex]234:1.4ex and 0.9ex),% |
| 2106 |
([xshift=-1em,yshift=.2ex]306:1.4ex and 0.9ex),% |
| 2107 |
([xshift=-1em,yshift=.2ex]18:1.4ex and 0.9ex)}, |
| 2108 |
label in legend mark coordinates={ |
| 2109 |
([xshift=-1em,yshift=.2ex]90:1.4ex and 0.9ex),% |
| 2110 |
([xshift=-1em,yshift=.2ex]162:1.4ex and 0.9ex),% |
| 2111 |
([xshift=-1em,yshift=.2ex]234:1.4ex and 0.9ex),% |
| 2112 |
([xshift=-1em,yshift=.2ex]306:1.4ex and 0.9ex),% |
| 2113 |
([xshift=-1em,yshift=.2ex]18:1.4ex and 0.9ex)} |
| 2114 |
}, |
| 2115 |
default label in legend path/.style={zig zag label in legend line}, |
| 2116 |
default label in legend closed path/.style={circular label in legend line}, |
| 2117 |
default label in legend mark/.style={label in legend one mark}, |
| 2118 |
}% |
| 2119 |
|
| 2120 |
|
| 2121 |
\def\tikz@dv@legend@entry@visualizer@visualizer{ |
| 2122 |
}% |
| 2123 |
|
| 2124 |
|
| 2125 |
|
| 2126 |
% |
| 2127 |
% Basic visualizers |
| 2128 |
% |
| 2129 |
|
| 2130 |
\tikzdatavisualizationset{ |
| 2131 |
visualize as line/.style={ |
| 2132 |
new object={ |
| 2133 |
when=after survey, |
| 2134 |
store=/tikz/data visualization/visualizers/#1, |
| 2135 |
class=plot handler visualizer, |
| 2136 |
arg1=#1, |
| 2137 |
arg2={\tikz@dv@plot@handler,\tikz@dv@plot@mark@maker} |
| 2138 |
}, |
| 2139 |
new visualizer={#1}{% |
| 2140 |
every path/.style={draw}, |
| 2141 |
style={every mark/.append style={color=visualizer color}}, |
| 2142 |
mark size=2pt, |
| 2143 |
semithick, |
| 2144 |
color=visualizer color, |
| 2145 |
mark=none, |
| 2146 |
/tikz/data visualization/every visualize as line/.try, |
| 2147 |
}{visualizer in legend=\tikz@dv@legend@entry@as@example}, |
| 2148 |
#1={straight line} |
| 2149 |
}, |
| 2150 |
visualize as line/.default=line, |
| 2151 |
visualize as smooth line/.style={ |
| 2152 |
visualize as line={#1}, |
| 2153 |
#1={smooth line} |
| 2154 |
}, |
| 2155 |
visualize as smooth line/.default=line, |
| 2156 |
visualize as smooth cycle/.style={ |
| 2157 |
visualize as smooth line={#1}, |
| 2158 |
#1={smooth cycle} |
| 2159 |
}, |
| 2160 |
visualize as smooth cycle/.default=line, |
| 2161 |
visualize as scatter/.style={ |
| 2162 |
new object={ |
| 2163 |
when=after survey, |
| 2164 |
store=/tikz/data visualization/visualizers/#1, |
| 2165 |
class=plot handler visualizer, |
| 2166 |
arg1=#1, |
| 2167 |
arg2={\tikz@dv@plot@mark@maker} |
| 2168 |
}, |
| 2169 |
new visualizer={#1}{% |
| 2170 |
mark=x, |
| 2171 |
mark size=2pt, |
| 2172 |
style={every mark/.append style={color=visualizer color}}, |
| 2173 |
/tikz/data visualization/every visualize as scatter/.try, |
| 2174 |
}{visualizer in legend=\tikz@dv@legend@entry@as@example}, |
| 2175 |
#1={no lines} |
| 2176 |
}, |
| 2177 |
visualize as scatter/.default=scatter |
| 2178 |
}% |
| 2179 |
|
| 2180 |
\def\tikz@dv@plot@mark@maker{ |
| 2181 |
\let\tikz@options=\pgfutil@empty% |
| 2182 |
\let\tikz@transform=\pgfutil@empty% |
| 2183 |
\tikzset{solid,shift only,every mark}% |
| 2184 |
\tikz@options% |
| 2185 |
\ifx\tikz@plot@mark\pgfutil@empty% |
| 2186 |
\pgfplothandlerdiscard |
| 2187 |
\else |
| 2188 |
\pgfplothandlermark{\tikz@transform\pgfuseplotmark{\tikz@plot@mark}} |
| 2189 |
\fi |
| 2190 |
}% |
| 2191 |
|
| 2192 |
|
| 2193 |
|
| 2194 |
% |
| 2195 |
% Rectangle visualizers |
| 2196 |
% |
| 2197 |
|
| 2198 |
|
| 2199 |
\tikzdatavisualizationset{ |
| 2200 |
visualize as rectangles/.style={ |
| 2201 |
new object={ |
| 2202 |
when=before survey, |
| 2203 |
store=/tikz/data visualization/visualizers/#1, |
| 2204 |
class=rectangle visualizer, |
| 2205 |
arg1=#1 |
| 2206 |
}, |
| 2207 |
/data point/#1/attribute 1/.initial=x, |
| 2208 |
/data point/#1/attribute 2/.initial=y, |
| 2209 |
new visualizer={#1}{% |
| 2210 |
every path/.style={draw}, |
| 2211 |
semithick, |
| 2212 |
color=visualizer color, |
| 2213 |
/tikz/data visualization/every visualize as rectangles/.try, |
| 2214 |
}{visualizer in legend=\tikz@dv@legend@entry@as@rectangle}, |
| 2215 |
#1={} |
| 2216 |
}, |
| 2217 |
visualize as rectangles/.default=rectangles, |
| 2218 |
% |
| 2219 |
% |
| 2220 |
% |
| 2221 |
visualizer options/.cd, |
| 2222 |
attribute 1/.style={/data point/\tikz@visualizer/attribute 1={#1}}, |
| 2223 |
attribute 2/.style={/data point/\tikz@visualizer/attribute 2={#1}}, |
| 2224 |
}% |
| 2225 |
|
| 2226 |
|
| 2227 |
|
| 2228 |
\def\tikz@dv@legend@entry@as@rectangle{ |
| 2229 |
\pgfkeysgetvalue{/data point/set}{\tikz@visualizer} |
| 2230 |
\pgfkeysvalueof{/data point/\tikz@visualizer/execute at begin} |
| 2231 |
\pgfplothandlerpolygon |
| 2232 |
\pgfplotstreamstart |
| 2233 |
\pgfkeysgetvalue{/tikz/data visualization/legend entry options/label in legend rectangle coordinates}{\tikz@dv@temp} |
| 2234 |
\foreach \coordinate in \tikz@dv@temp |
| 2235 |
{ \pgfplotstreampoint{\expandafter\tikz@scan@one@point\expandafter\pgfutil@firstofone\coordinate} } |
| 2236 |
\pgfplotstreamend |
| 2237 |
\pgfkeysvalueof{/data point/\tikz@visualizer/execute at end} |
| 2238 |
}% |
| 2239 |
|
| 2240 |
|
| 2241 |
|
| 2242 |
|
| 2243 |
% |
| 2244 |
% Style sheets |
| 2245 |
% |
| 2246 |
|
| 2247 |
% Style sheet handler |
| 2248 |
|
| 2249 |
\pgfkeysdef{/handlers/.style sheet}{% |
| 2250 |
\edef\pgf@marshal{ |
| 2251 |
\noexpand \pgfoonew \noexpand\tikz@dv@temp=new style attribute(\pgfkeyscurrentpath,#1) |
| 2252 |
\noexpand \tikz@[email protected] connects() |
| 2253 |
} |
| 2254 |
\pgf@marshal |
| 2255 |
}% |
| 2256 |
|
| 2257 |
\tikzset{ |
| 2258 |
visualizer color/.code=\colorlet{visualizer color}{#1}, |
| 2259 |
visualizer color=black |
| 2260 |
}% |
| 2261 |
|
| 2262 |
% Default style sheets |
| 2263 |
|
| 2264 |
\pgfdvdeclarestylesheet{vary thickness} |
| 2265 |
{ |
| 2266 |
default style/.style={line width={0.3pt+(#1)*0.2pt}} |
| 2267 |
}% |
| 2268 |
|
| 2269 |
\pgfdvdeclarestylesheet{vary dashing} |
| 2270 |
{ |
| 2271 |
default style/.style=solid, |
| 2272 |
1/.style=solid, |
| 2273 |
2/.style={dash pattern=on 5\pgflinewidth off 2\pgflinewidth}, |
| 2274 |
3/.style={dash pattern=on 1.5\pgflinewidth off 1.5\pgflinewidth}, |
| 2275 |
4/.style={dash pattern=on 5\pgflinewidth off 1.5\pgflinewidth on 1.5\pgflinewidth off 1.5\pgflinewidth}, |
| 2276 |
5/.style={dash pattern=on 10\pgflinewidth off 3\pgflinewidth}, |
| 2277 |
6/.style={dash pattern=on 10\pgflinewidth off 2\pgflinewidth on 2\pgflinewidth off 2\pgflinewidth}, |
| 2278 |
7/.style={dash pattern=on 8\pgflinewidth off 2\pgflinewidth on |
| 2279 |
1.5\pgflinewidth off 1.5\pgflinewidth on 1.5\pgflinewidth off |
| 2280 |
1.5\pgflinewidth on 1.5\pgflinewidth off 1.5\pgflinewidth} |
| 2281 |
}% |
| 2282 |
|
| 2283 |
\pgfdvdeclarestylesheet{vary thickness and dashing} |
| 2284 |
{ |
| 2285 |
default style/.style=thin, |
| 2286 |
1/.style=thin, |
| 2287 |
2/.style=thick, |
| 2288 |
3/.style={ |
| 2289 |
dash pattern=on 5\pgflinewidth off 2\pgflinewidth, |
| 2290 |
thin |
| 2291 |
}, |
| 2292 |
4/.style={ |
| 2293 |
dash pattern=on 5\pgflinewidth off 2\pgflinewidth, |
| 2294 |
thick, |
| 2295 |
}, |
| 2296 |
5/.style={ |
| 2297 |
dash pattern=on 1.5\pgflinewidth off 1.5\pgflinewidth, |
| 2298 |
thin |
| 2299 |
}, |
| 2300 |
6/.style={ |
| 2301 |
dash pattern=on 1.5\pgflinewidth off 1.5\pgflinewidth, |
| 2302 |
thick |
| 2303 |
}, |
| 2304 |
7/.style={ |
| 2305 |
dash pattern=on 5\pgflinewidth off 1.5\pgflinewidth on |
| 2306 |
1.5\pgflinewidth off 1.5\pgflinewidth, |
| 2307 |
thin |
| 2308 |
}, |
| 2309 |
8/.style={ |
| 2310 |
dash pattern=on 5\pgflinewidth off 1.5\pgflinewidth on |
| 2311 |
1.5\pgflinewidth off 1.5\pgflinewidth, |
| 2312 |
thick |
| 2313 |
}, |
| 2314 |
9/.style={ |
| 2315 |
dash pattern=on 10\pgflinewidth off 3\pgflinewidth, |
| 2316 |
thin |
| 2317 |
}, |
| 2318 |
10/.style={ |
| 2319 |
dash pattern=on 10\pgflinewidth off 3\pgflinewidth, |
| 2320 |
thick |
| 2321 |
}, |
| 2322 |
11/.style={ |
| 2323 |
dash pattern=on 10\pgflinewidth off 2\pgflinewidth on |
| 2324 |
2\pgflinewidth off 2\pgflinewidth, |
| 2325 |
thin |
| 2326 |
}, |
| 2327 |
12/.style={ |
| 2328 |
dash pattern=on 10\pgflinewidth off 2\pgflinewidth on |
| 2329 |
2\pgflinewidth off 2\pgflinewidth, |
| 2330 |
thick |
| 2331 |
}, |
| 2332 |
13/.style={ |
| 2333 |
dash pattern=on 8\pgflinewidth off 2\pgflinewidth on |
| 2334 |
1.5\pgflinewidth off 1.5\pgflinewidth on 1.5\pgflinewidth off |
| 2335 |
1.5\pgflinewidth on 1.5\pgflinewidth off 1.5\pgflinewidth, |
| 2336 |
thin |
| 2337 |
}, |
| 2338 |
14/.style={ |
| 2339 |
dash pattern=on 8\pgflinewidth off 2\pgflinewidth on |
| 2340 |
1.5\pgflinewidth off 1.5\pgflinewidth on 1.5\pgflinewidth off |
| 2341 |
1.5\pgflinewidth on 1.5\pgflinewidth off 1.5\pgflinewidth, |
| 2342 |
thick |
| 2343 |
} |
| 2344 |
}% |
| 2345 |
|
| 2346 |
|
| 2347 |
\pgfdvdeclarestylesheet{strong colors} |
| 2348 |
{ |
| 2349 |
default style/.style={visualizer color=black}, |
| 2350 |
1/.style={visualizer color=black}, |
| 2351 |
2/.style={visualizer color=red!80!black}, |
| 2352 |
3/.style={visualizer color=blue!80!black}, |
| 2353 |
4/.style={visualizer color=green!60!black}, |
| 2354 |
5/.style={visualizer color=orange!80!black}, |
| 2355 |
6/.style={visualizer color=black!60} |
| 2356 |
}% |
| 2357 |
|
| 2358 |
|
| 2359 |
\pgfdvdeclarestylesheet{cross marks} |
| 2360 |
{ |
| 2361 |
default style/.style={mark=x,every mark/.append style=thin,mark size=2pt}, |
| 2362 |
1/.style={mark=x,every mark/.append style=thin,mark size=2pt}, |
| 2363 |
2/.style={mark=+,every mark/.append style=thin,mark size=2pt}, |
| 2364 |
3/.style={mark=Mercedes star,every mark/.append style=thin,mark size=2pt}, |
| 2365 |
4/.style={mark=Mercedes star flipped,every mark/.append style=thin,mark size=2pt}, |
| 2366 |
5/.style={mark=star,every mark/.append style=thin,mark size=2pt}, |
| 2367 |
6/.style={mark=10-pointed star,every mark/.append style={line width=.3pt,mark size=1.8pt}} |
| 2368 |
}% |
| 2369 |
|
| 2370 |
|
| 2371 |
\pgfdvdeclarestylesheet{* mark} |
| 2372 |
{ |
| 2373 |
default style/.style={mark=*,every mark/.append style=thin,mark size=1.4pt}, |
| 2374 |
}% |
| 2375 |
|
| 2376 |
\pgfdvdeclarestylesheet{dot mark} |
| 2377 |
{ |
| 2378 |
default style/.style={mark=*,every mark/.append style=thin,mark size=0.6pt}, |
| 2379 |
}% |
| 2380 |
|
| 2381 |
|
| 2382 |
\pgfdvdeclarestylesheet{o mark} |
| 2383 |
{ |
| 2384 |
default style/.style={mark=o,every mark/.append style=thin,mark size=1.4pt}, |
| 2385 |
}% |
| 2386 |
|
| 2387 |
|
| 2388 |
|
| 2389 |
% Declare a color series style sheet |
| 2390 |
% |
| 2391 |
% #1 = name of the style sheet |
| 2392 |
% #2 = color model |
| 2393 |
% #3 = initial color |
| 2394 |
% #4 = step |
| 2395 |
% |
| 2396 |
% Description: |
| 2397 |
% |
| 2398 |
% This function declares a style sheet that changes colors according |
| 2399 |
% to the value of the attribute. No test is made that the attribute is |
| 2400 |
% a number. |
| 2401 |
|
| 2402 |
\def\tikzdvdeclarestylesheetcolorseries#1#2#3#4{% |
| 2403 |
\definecolorseries{tikzdvcolorseries#1}{#2}{step}[#2]{#3}{#4}% |
| 2404 |
\resetcolorseries{tikzdvcolorseries#1}% |
| 2405 |
\pgfdvdeclarestylesheet{#1} |
| 2406 |
{ |
| 2407 |
default style/.style={ |
| 2408 |
/utils/exec=\colorlet{tikz@dv@temp}[rgb]{tikzdvcolorseries#1!![##1]}, |
| 2409 |
visualizer color=tikz@dv@temp |
| 2410 |
} |
| 2411 |
}% |
| 2412 |
}% |
| 2413 |
|
| 2414 |
\tikzdvdeclarestylesheetcolorseries{vary hue}{hsb}{.4,0.9,0.8}{.213,0,0}% |
| 2415 |
\tikzdvdeclarestylesheetcolorseries{shades of blue}{hsb}{.65,1.4,1}{0,-.4,-.0}% |
| 2416 |
\tikzdvdeclarestylesheetcolorseries{shades of red}{hsb}{0,1.4,1}{0,-.4,-.0}% |
| 2417 |
\tikzdvdeclarestylesheetcolorseries{gray scale}{hsb}{0,0,-.34}{0,0,.34}% |
| 2418 |
|
| 2419 |
|
| 2420 |
|
| 2421 |
|
| 2422 |
|
| 2423 |
% |
| 2424 |
% Basic Axes & Coordinate Systems |
| 2425 |
% |
| 2426 |
|
| 2427 |
|
| 2428 |
% |
| 2429 |
% |
| 2430 |
% Basic axis systems |
| 2431 |
% |
| 2432 |
% |
| 2433 |
|
| 2434 |
\tikzdatavisualizationset{ |
| 2435 |
xy Cartesian/.style={ |
| 2436 |
new Cartesian axis=x axis, |
| 2437 |
x axis={attribute=x,unit vector={(1pt,0cm)}}, |
| 2438 |
new Cartesian axis=y axis, |
| 2439 |
y axis={attribute=y,unit vector={(0cm,1pt)}} |
| 2440 |
}, |
| 2441 |
Xy axes/.style={x axis={#1},y axis={#1}}, |
| 2442 |
uv Cartesian/.style={ |
| 2443 |
new Cartesian axis=u axis, |
| 2444 |
u axis={attribute=u,unit vector={(1pt,0cm)}}, |
| 2445 |
new Cartesian axis=v axis, |
| 2446 |
v axis={attribute=v,unit vector={(0cm,1pt)}} |
| 2447 |
}, |
| 2448 |
uv axes/.style={u axis={#1},v axis={#1}}, |
| 2449 |
}% |
| 2450 |
|
| 2451 |
\tikzdatavisualizationset{ |
| 2452 |
xyz Cartesian cabinet/.style={ |
| 2453 |
xy Cartesian, |
| 2454 |
new Cartesian axis=z axis, |
| 2455 |
z axis={attribute=z,unit vector={(-0.353553pt,-0.353553pt)}} |
| 2456 |
}, |
| 2457 |
xyz axes/.style={x axis={#1},y axis={#1},z axis={#1}}, |
| 2458 |
uvw Cartesian cabinet/.style={ |
| 2459 |
uv Cartesian, |
| 2460 |
new Cartesian axis=w axis, |
| 2461 |
w axis={attribute=w,unit vector={(-0.353553pt,-0.353553pt)}} |
| 2462 |
} |
| 2463 |
uvw axes/.style={u axis={#1},v axis={#1},w axis={#1}}, |
| 2464 |
}% |
| 2465 |
|
| 2466 |
|
| 2467 |
|
| 2468 |
% |
| 2469 |
% Create a new axis system |
| 2470 |
% |
| 2471 |
|
| 2472 |
\tikzdatavisualizationset{ |
| 2473 |
new axis system/.style n args={4}{ |
| 2474 |
#1/.style={ |
| 2475 |
#2, |
| 2476 |
#1/.cd, |
| 2477 |
#3, |
| 2478 |
/tikz/data visualization/every #1/.try, |
| 2479 |
##1, |
| 2480 |
/tikz/data visualization/.cd, |
| 2481 |
#4, |
| 2482 |
} |
| 2483 |
} |
| 2484 |
}% |
| 2485 |
|
| 2486 |
|
| 2487 |
% The school book axes |
| 2488 |
% |
| 2489 |
% This coordinate system can be used to create plots that look like |
| 2490 |
% plots in a typical school book: There are two axes called "x axis" |
| 2491 |
% and "y axis" that meet at the origin, there are arrows at the ends |
| 2492 |
% of the axes, pointing in the directions of the positive axes. No |
| 2493 |
% scaling is done by default, rather one unit equals one 1cm. This |
| 2494 |
% ensures that the even when multiple plots are created, the same |
| 2495 |
% scaling will be used each time. |
| 2496 |
% |
| 2497 |
% To change the scaling, say "all axes={unit length=1mm}" for |
| 2498 |
% instance. |
| 2499 |
|
| 2500 |
\tikzdatavisualizationset{ |
| 2501 |
new axis system={school book axes}{% |
| 2502 |
xy Cartesian, |
| 2503 |
x axis={ |
| 2504 |
include value=0, |
| 2505 |
scaling=0 at 0 and \pgfkeysvalueof{/tikz/data visualization/school book axes/unit} at 1cm, |
| 2506 |
visualize axis={y axis={goto=0},style=->,padded}, |
| 2507 |
visualize ticks={common={y axis={goto=0},direction axis=y axis}, |
| 2508 |
major={tick text at low, |
| 2509 |
options at=0 as [{style={draw=none},no tick text}] |
| 2510 |
}}, |
| 2511 |
visualize grid={common={direction axis=y axis,padded}}, |
| 2512 |
ticks={step=\pgfkeysvalueof{/tikz/data visualization/school book axes/unit}}, |
| 2513 |
padding=0.75em |
| 2514 |
}, |
| 2515 |
y axis={ |
| 2516 |
include value=0, |
| 2517 |
scaling=0 at 0 and \pgfkeysvalueof{/tikz/data visualization/school book axes/unit} at 1cm, |
| 2518 |
visualize axis={x axis={goto=0},style=->,padded}, |
| 2519 |
visualize ticks={ |
| 2520 |
common={x axis={goto=0},direction axis=x axis}, |
| 2521 |
major={tick text at low,options at=0 as [{high=0,low=0,style={draw=none},node style={anchor=north east}}]} |
| 2522 |
}, |
| 2523 |
visualize grid={common={direction axis=x axis,padded}}, |
| 2524 |
ticks={step=\pgfkeysvalueof{/tikz/data visualization/school book axes/unit}}, |
| 2525 |
padding=0.75em |
| 2526 |
} |
| 2527 |
}{% |
| 2528 |
standard labels |
| 2529 |
}{% |
| 2530 |
@make labels |
| 2531 |
}, |
| 2532 |
school book axes/.cd, |
| 2533 |
% Possible axis positionings: |
| 2534 |
% |
| 2535 |
% Place labels at the ends of the axes |
| 2536 |
% |
| 2537 |
standard labels/.style={ |
| 2538 |
/tikz/data visualization/@make labels/.style={ |
| 2539 |
x axis={ |
| 2540 |
visualize label={ |
| 2541 |
x axis={goto=padded max, anchor at max}, |
| 2542 |
y axis={goto=0} |
| 2543 |
} |
| 2544 |
}, |
| 2545 |
y axis={ |
| 2546 |
visualize label={ |
| 2547 |
y axis={goto=padded max, anchor at max}, |
| 2548 |
x axis={goto=0} |
| 2549 |
} |
| 2550 |
} |
| 2551 |
} |
| 2552 |
}, |
| 2553 |
% |
| 2554 |
% Basic unit |
| 2555 |
% |
| 2556 |
unit/.initial=1, |
| 2557 |
}% |
| 2558 |
|
| 2559 |
|
| 2560 |
|
| 2561 |
|
| 2562 |
% The scientific axes |
| 2563 |
% |
| 2564 |
% The scientific axes is a 2d plot that has a predetermined width and |
| 2565 |
% height. The data is then scaled in such a way that it fits inside |
| 2566 |
% this given rectangle. |
| 2567 |
|
| 2568 |
\tikzdatavisualizationset{ |
| 2569 |
new axis system={scientific axes}{% |
| 2570 |
xy Cartesian, |
| 2571 |
every axis/.append style={style={draw=black!50}}, |
| 2572 |
every ticks/.append style={style={draw=black!50}}, |
| 2573 |
x axis={ |
| 2574 |
length=\pgfkeysvalueof{/tikz/data visualization/scientific axes/width}, |
| 2575 |
ticks |
| 2576 |
}, |
| 2577 |
y axis={ |
| 2578 |
length=\pgfkeysvalueof{/tikz/data visualization/scientific axes/height}, |
| 2579 |
ticks |
| 2580 |
} |
| 2581 |
}{% |
| 2582 |
standard labels, |
| 2583 |
outer ticks, |
| 2584 |
}{% |
| 2585 |
@make axes, |
| 2586 |
@make labels |
| 2587 |
}, |
| 2588 |
scientific axes/.cd, |
| 2589 |
width/.initial=5cm, |
| 2590 |
height/.initial=0.618*\pgfkeysvalueof{/tikz/data visualization/scientific axes/width},% golden ratio... |
| 2591 |
outer ticks/.style={ |
| 2592 |
/tikz/data visualization/@make axes/.style={ |
| 2593 |
x axis={ |
| 2594 |
visualize ticks={common={y axis={goto=padded min},direction axis=y axis,high=0pt},major={tick text at low}}, |
| 2595 |
visualize ticks={common={y axis={goto=padded max},direction axis=y axis,low=0pt}}, |
| 2596 |
visualize axis={y axis={goto=padded min},padded}, |
| 2597 |
visualize axis={y axis={goto=padded max},padded}, |
| 2598 |
visualize grid={common={direction axis=y axis,padded}}, |
| 2599 |
}, |
| 2600 |
y axis={ |
| 2601 |
visualize ticks={common={x axis={goto=padded min},direction axis=x axis,high=0pt},major={tick text at low}}, |
| 2602 |
visualize ticks={common={x axis={goto=padded max},direction axis=x axis,low=0pt}}, |
| 2603 |
visualize axis={x axis={goto=padded min},padded}, |
| 2604 |
visualize axis={x axis={goto=padded max},padded}, |
| 2605 |
visualize grid={common={direction axis=x axis,padded}}, |
| 2606 |
} |
| 2607 |
} |
| 2608 |
}, |
| 2609 |
inner ticks/.style={ |
| 2610 |
/tikz/data visualization/@make axes/.style={ |
| 2611 |
x axis={ |
| 2612 |
visualize ticks={common={y axis={goto=padded min},direction axis=y axis,low=0pt},major={tick text at low}}, |
| 2613 |
visualize ticks={common={y axis={goto=padded max},direction axis=y axis,high=0pt}}, |
| 2614 |
visualize axis={y axis={goto=padded min},padded}, |
| 2615 |
visualize axis={y axis={goto=padded max},padded}, |
| 2616 |
visualize grid={common={direction axis=y axis,padded}}, |
| 2617 |
}, |
| 2618 |
y axis={ |
| 2619 |
visualize ticks={common={x axis={goto=padded min},direction axis=x axis,low=0pt},major={tick text at low}}, |
| 2620 |
visualize ticks={common={x axis={goto=padded max},direction axis=x axis,high=0pt}}, |
| 2621 |
visualize axis={x axis={goto=padded min},padded}, |
| 2622 |
visualize axis={x axis={goto=padded max},padded}, |
| 2623 |
visualize grid={common={direction axis=x axis,padded}}, |
| 2624 |
} |
| 2625 |
} |
| 2626 |
}, |
| 2627 |
clean/.style={ |
| 2628 |
/tikz/data visualization/@make axes/.style={ |
| 2629 |
x axis={ |
| 2630 |
visualize ticks={common={y axis={goto=padded min},direction axis=y axis,high=0pt},major={tick text at low}}, |
| 2631 |
visualize axis={y axis={goto=padded min}}, |
| 2632 |
visualize axis={y axis={goto=min}, style={black!25, line cap=rect}}, |
| 2633 |
visualize axis={y axis={goto=max}, style={black!25, line cap=rect}}, |
| 2634 |
visualize grid={common={direction axis=y axis}}, |
| 2635 |
padding=.5em, |
| 2636 |
}, |
| 2637 |
y axis={ |
| 2638 |
visualize ticks={common={x axis={goto=padded min},direction axis=x axis,high=0pt},major={tick text at low}}, |
| 2639 |
visualize axis={x axis={goto=padded min}}, |
| 2640 |
visualize axis={x axis={goto=min}, style={black!25, line cap=rect}}, |
| 2641 |
visualize axis={x axis={goto=max}, style={black!25, line cap=rect}}, |
| 2642 |
visualize grid={common={direction axis=x axis}}, |
| 2643 |
padding=.5em |
| 2644 |
}, |
| 2645 |
} |
| 2646 |
}, |
| 2647 |
% Possible axis positionings: |
| 2648 |
% |
| 2649 |
% Place axes labels below and left, where left label is rotated |
| 2650 |
% |
| 2651 |
standard labels/.style={ |
| 2652 |
/tikz/data visualization/@make labels/.style={ |
| 2653 |
x axis={ |
| 2654 |
visualize label={ |
| 2655 |
x axis={goto pos=.5}, |
| 2656 |
% Vertical position comes from bounding box: |
| 2657 |
node style={ |
| 2658 |
at={(0,0 |- data visualization bounding box.south)}, |
| 2659 |
below |
| 2660 |
} |
| 2661 |
} |
| 2662 |
}, |
| 2663 |
y axis={ |
| 2664 |
visualize label={ |
| 2665 |
y axis={goto pos=.5}, |
| 2666 |
% Horizontal position comes from bounding box: |
| 2667 |
node style={ |
| 2668 |
at={(0,0 -| data visualization bounding box.west)}, |
| 2669 |
rotate=90, |
| 2670 |
above} |
| 2671 |
} |
| 2672 |
} |
| 2673 |
} |
| 2674 |
}, |
| 2675 |
% |
| 2676 |
% Place axes labels below and left, no rotation |
| 2677 |
% |
| 2678 |
upright labels/.style={ |
| 2679 |
/tikz/data visualization/@make labels/.style={ |
| 2680 |
x axis={ |
| 2681 |
visualize label={ |
| 2682 |
x axis={goto pos=.5}, |
| 2683 |
% Vertical position comes from bounding box: |
| 2684 |
node style={ |
| 2685 |
at={(0,0 |- data visualization bounding box.south)}, |
| 2686 |
below |
| 2687 |
} |
| 2688 |
} |
| 2689 |
}, |
| 2690 |
y axis={ |
| 2691 |
visualize label={ |
| 2692 |
y axis={goto pos=.5}, |
| 2693 |
% Horizontal position comes from bounding box: |
| 2694 |
node style={ |
| 2695 |
at={(0,0 -| data visualization bounding box.west)}, |
| 2696 |
left |
| 2697 |
} |
| 2698 |
} |
| 2699 |
} |
| 2700 |
} |
| 2701 |
}, |
| 2702 |
% |
| 2703 |
% Place axes at the ends of the axes |
| 2704 |
% |
| 2705 |
end labels/.style={ |
| 2706 |
/tikz/data visualization/@make labels/.style={ |
| 2707 |
x axis={ |
| 2708 |
visualize label={ |
| 2709 |
y axis={goto=padded min}, |
| 2710 |
% Vertical position comes from bounding box: |
| 2711 |
node style={ |
| 2712 |
at={(0,0 -| data visualization bounding box.east)}, |
| 2713 |
right |
| 2714 |
} |
| 2715 |
} |
| 2716 |
}, |
| 2717 |
y axis={ |
| 2718 |
visualize label={ |
| 2719 |
x axis={goto=padded min}, |
| 2720 |
% Horizontal position comes from bounding box: |
| 2721 |
node style={ |
| 2722 |
at={(0,0 |- data visualization bounding box.north)}, |
| 2723 |
above |
| 2724 |
} |
| 2725 |
} |
| 2726 |
} |
| 2727 |
} |
| 2728 |
} |
| 2729 |
}% |
| 2730 |
|
| 2731 |
|
| 2732 |
|
| 2733 |
\endinput |