| 1 |
%-------------------------------------------- |
| 2 |
% |
| 3 |
% Package pgfplots |
| 4 |
% |
| 5 |
% Provides a user-friendly interface to create function plots (normal |
| 6 |
% plots, semi-logplots and double-logplots). |
| 7 |
% |
| 8 |
% It is based on Till Tantau's PGF package. |
| 9 |
% |
| 10 |
% Copyright 2007-2013 by Christian Feuersänger. |
| 11 |
% |
| 12 |
% This program is free software: you can redistribute it and/or modify |
| 13 |
% it under the terms of the GNU General Public License as published by |
| 14 |
% the Free Software Foundation, either version 3 of the License, or |
| 15 |
% (at your option) any later version. |
| 16 |
% |
| 17 |
% This program is distributed in the hope that it will be useful, |
| 18 |
% but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 |
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 |
% GNU General Public License for more details. |
| 21 |
% |
| 22 |
% You should have received a copy of the GNU General Public License |
| 23 |
% along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 24 |
% |
| 25 |
%-------------------------------------------- |
| 26 |
|
| 27 |
\def\pgfplots@markers@visphase@name@none{none}% |
| 28 |
\def\pgfplots@markers@visphase@name@afterpath@clipped{afterpath@clipped}% |
| 29 |
\def\pgfplots@markers@visphase@name@afterpath@unclipped{afterpath@unclipped}% |
| 30 |
\def\pgfplots@markers@visphase@name@endaxis@unclipped{endaxis@unclipped}% |
| 31 |
|
| 32 |
% defines \pgfplotsretval to contain the visualization phase used by |
| 33 |
% the current plot. |
| 34 |
\def\pgfplots@markers@survey@set@visphasename{% |
| 35 |
\begingroup |
| 36 |
% |
| 37 |
% this validates+normalizes \tikz@plot@mark: |
| 38 |
\pgfplots@markers@check@for@default@plot@mark |
| 39 |
\ifx\tikz@plot@mark\pgfutil@empty |
| 40 |
\ifpgfplots@scatterplotenabled |
| 41 |
\def\b@pgfplots@has@plot@mark{1}% |
| 42 |
\else |
| 43 |
\def\b@pgfplots@has@plot@mark{0}% |
| 44 |
\fi |
| 45 |
\else |
| 46 |
\def\b@pgfplots@has@plot@mark{1}% |
| 47 |
\fi |
| 48 |
% |
| 49 |
% this sets \ifpgfplots@clip@marker@paths: |
| 50 |
\pgfplots@markers@prepare@layered@graphics@marks |
| 51 |
% |
| 52 |
\if0\b@pgfplots@has@plot@mark |
| 53 |
% no markers. Ok, we do not need a visualization phase for |
| 54 |
% markers. |
| 55 |
\let\pgfplotsretval=\pgfplots@markers@visphase@name@none |
| 56 |
\else |
| 57 |
\ifpgfplots@clip@marker@paths |
| 58 |
\let\pgfplotsretval=\pgfplots@markers@visphase@name@afterpath@clipped |
| 59 |
\else |
| 60 |
\if2\pgfplots@clipmode |
| 61 |
% clip mode=individual: |
| 62 |
\let\pgfplotsretval=\pgfplots@markers@visphase@name@afterpath@unclipped |
| 63 |
\else |
| 64 |
% clip mode=global |
| 65 |
\let\pgfplotsretval=\pgfplots@markers@visphase@name@endaxis@unclipped |
| 66 |
\fi |
| 67 |
\fi |
| 68 |
\fi |
| 69 |
% |
| 70 |
\pgfmath@smuggleone\pgfplotsretval |
| 71 |
\endgroup |
| 72 |
}% |
| 73 |
|
| 74 |
\def\pgfplots@markers@visphase@after@axis@prepare{% |
| 75 |
\global\pgfplotslistnewempty\pgfplots@stored@markerlist |
| 76 |
} |
| 77 |
|
| 78 |
% Draw any markers for which drawing has been postponed. |
| 79 |
% |
| 80 |
% The motivation here is that markers should be drawn on top of |
| 81 |
% their plots, and AFTER the clip path. |
| 82 |
% |
| 83 |
\def\pgfplots@markers@visphase@after@axis{% |
| 84 |
\begingroup |
| 85 |
\pgfplotslistforeach\pgfplots@stored@plotlist\as\pgfplots@loc@TMPa{% |
| 86 |
\expandafter\pgfplots@stored@plotlist@EXTRACTENTRY\pgfplots@loc@TMPa |
| 87 |
%\message{^^JProcessing stored plot with precommand '\meaning\pgfplots@stored@current@precmd';^^J pgfplots@plotcmd '\meaning\pgfplots@stored@current@cmd'^^J postcommand '\meaning\pgfplots@stored@current@postcmd'^^J}% |
| 88 |
%\message{DATA: '\meaning\pgfplots@stored@current@data';^^J}% |
| 89 |
% The precmd sets all required variables needed to |
| 90 |
% finalize a plot. |
| 91 |
% @see the stream preparation routines. |
| 92 |
\pgfplots@stored@current@precmd |
| 93 |
\ifx\pgfplots@markers@visphase@name\pgfplots@markers@visphase@name@endaxis@unclipped |
| 94 |
\ifx\pgfplots@stored@current@cmd\pgfutil@empty |
| 95 |
% Ah: some \pgfplotsextra command like \draw,\path, |
| 96 |
% \node or even \scope or \endscope. |
| 97 |
% Has been done earlier. |
| 98 |
\else |
| 99 |
\begingroup |
| 100 |
% reconfigure... |
| 101 |
\pgfkeyssetvalue{/pgfplots/on layer}{\pgfkeysvalueof{/pgfplots/mark layer}}% |
| 102 |
% |
| 103 |
% choose the one that is necessary for us here: |
| 104 |
\let\pgfplots@markers@visphase@name=\pgfplots@markers@visphase@name@afterpath@unclipped |
| 105 |
% |
| 106 |
% provide an empty list of phase names here in order |
| 107 |
% to turn off standard visualization phases: they |
| 108 |
% have been applied already. |
| 109 |
\pgfplots@stored@plotlist@visualize@selected@phases{}% |
| 110 |
\endgroup |
| 111 |
\fi |
| 112 |
\pgfplots@stored@current@postcmd |
| 113 |
\fi |
| 114 |
}% |
| 115 |
\endgroup |
| 116 |
} |
| 117 |
|
| 118 |
\def\pgfplots@execute@at@begin@plot@visualization@internal{% |
| 119 |
\global\let\pgfplots@stored@markerlist@last=\relax |
| 120 |
}% |
| 121 |
|
| 122 |
\def\pgfplots@markers@install@plotmark@handler{% |
| 123 |
% note: I can't check on tikz@transform because it can be '\relax'. |
| 124 |
\pgfplots@gettikzinternal@keyval{mark indices}{tikz@mark@list}{}% |
| 125 |
\pgfplots@gettikzinternal@keyval{mark}{tikz@plot@mark}{}% |
| 126 |
% |
| 127 |
% |
| 128 |
% do not reset \tikz@options: draw color may be acquired |
| 129 |
% from 'current plot style' |
| 130 |
%\let\tikz@options=\pgfutil@empty% |
| 131 |
\let\tikz@transform=\pgfutil@empty% |
| 132 |
\tikzset{every plot/.try,every mark}% |
| 133 |
% |
| 134 |
% This sets colors: |
| 135 |
\tikz@options |
| 136 |
% |
| 137 |
% This sets the \iftikz@mode@draw etc: |
| 138 |
%\tikz@mode |
| 139 |
% FIXME: using 'color=blue' will NOT activate filltrue! |
| 140 |
% So: if 'tikz@mode' *contains* 'fillfalse', I know what to do... |
| 141 |
% but all other cases are not clear |
| 142 |
%-------------------------------------------------- |
| 143 |
% \iftikz@mode@draw |
| 144 |
% \else |
| 145 |
% % Override the marker codes: force 'draw=none' |
| 146 |
% % even if the markers likes to be stroked: |
| 147 |
% \let\pgfusepathqfillstroke=\pgfusepathqfill |
| 148 |
% \fi |
| 149 |
% \iftikz@mode@fill |
| 150 |
% \else |
| 151 |
% % Override the marker codes: force 'fill=none' |
| 152 |
% % even if the markers likes to be filled: |
| 153 |
% \let\pgfusepathqfillstroke=\pgfusepathqstroke |
| 154 |
% \fi |
| 155 |
%-------------------------------------------------- |
| 156 |
% |
| 157 |
% this here is the MAIN marker code. |
| 158 |
% It may be modified if scatter plot is enabled, see below. |
| 159 |
\def\pgfplots@loc@TMPa{% |
| 160 |
% the transformation has been reset before processing plot |
| 161 |
% marks. |
| 162 |
% Consequently, it applies only transformation options in "every mark". |
| 163 |
\tikz@transform |
| 164 |
\pgfuseplotmark{\tikz@plot@mark}% |
| 165 |
}% |
| 166 |
\ifpgfplots@scatterplotenabled |
| 167 |
% Scatter plots work like this: |
| 168 |
% |
| 169 |
% <compute per-point meta info> |
| 170 |
% /pgfplots/scatter/@pre marker code |
| 171 |
% <marker code, lowlevel> |
| 172 |
% /pgfplots/scatter/@post marker code |
| 173 |
% |
| 174 |
% -> that's all. The Rest is configurable with style which |
| 175 |
% (re)define '@pre marker code' and '@post marker code' (see |
| 176 |
% the docs for details). |
| 177 |
% |
| 178 |
% Prepare arguments for '@pre/@post' macros: |
| 179 |
\t@pgfplots@toka={% |
| 180 |
\begingroup |
| 181 |
% prepare programmatic access to '/data point/x' etc: |
| 182 |
\pgfplotspointgetcoordinates |
| 183 |
\pgfplotsaxisvisphasetransformpointmeta |
| 184 |
\pgfkeysvalueof{/pgfplots/scatter/@pre marker code/.@cmd}\pgfeov |
| 185 |
}% |
| 186 |
\t@pgfplots@tokb=\expandafter{\pgfplots@loc@TMPa}% |
| 187 |
\t@pgfplots@tokc={% |
| 188 |
\pgfkeysvalueof{/pgfplots/scatter/@post marker code/.@cmd}\pgfeov |
| 189 |
\endgroup |
| 190 |
}% |
| 191 |
\edef\pgfplots@loc@TMPa{% |
| 192 |
\the\t@pgfplots@toka |
| 193 |
\the\t@pgfplots@tokb |
| 194 |
\the\t@pgfplots@tokc |
| 195 |
}% |
| 196 |
\if r\pgfplots@scatter@position |
| 197 |
% scatter/position=relative |
| 198 |
% |
| 199 |
% tikz transforms the coordinate system such that "(0,0)" |
| 200 |
% is the point where the mark should be placed. |
| 201 |
\else |
| 202 |
% scatter/position=absolute |
| 203 |
% |
| 204 |
% ah - we do not want tikz's transformation. |
| 205 |
% |
| 206 |
% Disable it by means of \aftergroup hackery: |
| 207 |
\t@pgfplots@tokc=\expandafter{\pgfplots@loc@TMPa}% |
| 208 |
\xdef\pgfplots@scatter@plot@mark{% |
| 209 |
\noexpand\begingroup |
| 210 |
\the\t@pgfplots@tokc |
| 211 |
\noexpand\endgroup |
| 212 |
}% |
| 213 |
\def\pgfplots@loc@TMPa{\aftergroup\pgfplots@scatter@plot@mark}% |
| 214 |
\fi |
| 215 |
\fi |
| 216 |
\def\pgfplots@loc@TMPb##1{% |
| 217 |
\ifx\tikz@mark@list\pgfutil@empty% |
| 218 |
\pgfplothandlermark{##1}% |
| 219 |
\else |
| 220 |
\pgfplothandlermarklisted{##1}{\tikz@mark@list}% |
| 221 |
\fi |
| 222 |
}% |
| 223 |
\t@pgfplots@tokc=\expandafter\expandafter\expandafter{\expandafter\pgfplots@loc@TMPb\expandafter{\pgfplots@loc@TMPa}}% |
| 224 |
\edef\pgfplots@basiclevel@plothandler{\the\t@pgfplots@tokc}% |
| 225 |
\expandafter\def\expandafter\pgfplots@basiclevel@plothandler\expandafter{% |
| 226 |
\pgfplots@basiclevel@plothandler |
| 227 |
\global\let\pgfplots@markers@plotstreamstart=\pgf@plotstreamstart |
| 228 |
\def\pgf@plotstreamstart{% |
| 229 |
\pgfplots@markers@plotstreamstart |
| 230 |
\global\let\pgfplots@markers@mark@handler@@=\pgf@plotstreampoint |
| 231 |
\global\let\pgf@plotstreampoint=\pgfplots@markers@mark@handler |
| 232 |
}% |
| 233 |
}% |
| 234 |
\let\tikz@plot@handler=\pgfplots@basiclevel@plothandler |
| 235 |
% |
| 236 |
\pgfplots@basiclevel@plothandler |
| 237 |
% |
| 238 |
}% |
| 239 |
|
| 240 |
\def\pgfplots@markers@mark@handler#1{% |
| 241 |
\ifpgfplots@clip |
| 242 |
% check for clip marker paths: |
| 243 |
\pgfplotsaxisifcontainspoint{\pgfplots@markers@mark@handler@@{#1}}{}% |
| 244 |
\else |
| 245 |
\pgfplots@markers@mark@handler@@{#1}% |
| 246 |
\fi |
| 247 |
}% |
| 248 |
|
| 249 |
\def\pgfplots@if@has@plot@marks#1#2{% |
| 250 |
% make sure there is a mark set! |
| 251 |
\pgfplots@gettikzinternal@keyval{mark}{tikz@plot@mark}{}% |
| 252 |
\def\pgfplots@loc@TMPa{none}% |
| 253 |
\ifx\tikz@plot@mark\pgfplots@loc@TMPa |
| 254 |
% this here happens only in older versions of pgf. |
| 255 |
\let\tikz@plot@mark\pgfutil@empty |
| 256 |
\fi |
| 257 |
\ifx\tikz@plot@mark\pgfutil@empty |
| 258 |
#2\relax |
| 259 |
\else |
| 260 |
#1\relax |
| 261 |
\fi |
| 262 |
}% |
| 263 |
|
| 264 |
\def\pgfplots@markers@check@for@default@plot@mark{% |
| 265 |
\pgfplots@if@has@plot@marks{}{% |
| 266 |
\pgfplots@getcurrent@plothandler\pgfplots@basiclevel@plothandler |
| 267 |
\ifx\pgfplots@basiclevel@plothandler\pgfplothandlerdiscard |
| 268 |
% oh, the "only marks" plot handler-- and no plot mark!? |
| 269 |
% what's that!? |
| 270 |
\ifpgfplots@scatterplotenabled |
| 271 |
% scatter handles this in /pgfplots/scatter/true |
| 272 |
% automatically. |
| 273 |
\else |
| 274 |
% that appears to be nonsense... |
| 275 |
\def\tikz@plot@mark{*}% |
| 276 |
\fi |
| 277 |
\fi |
| 278 |
}% |
| 279 |
}% |
| 280 |
|
| 281 |
|
| 282 |
% Used inside of /pgfplots/scatter/classes : |
| 283 |
\def\pgfplots@scatter@classes@pre@marker@code{% |
| 284 |
\pgfutil@ifundefined{pgfp@scatter@class@\pgfplotspointmeta}{% |
| 285 |
\let\pgfplots@loc@TMPa=\pgfplotspointmeta |
| 286 |
% |
| 287 |
% ups - no styles available? Maybe something went |
| 288 |
% wrong with the 'scatter src' key. Check whether it |
| 289 |
% was accidentally a numerical style: |
| 290 |
\if1\csname pgfpmeta@\pgfplotspointmetainputhandler @issymbolic\endcsname |
| 291 |
\else |
| 292 |
% ok, be fault tolerant and round to an integer: |
| 293 |
\pgfplotscoordmath{meta}{tofixed}{\pgfplotspointmeta}% |
| 294 |
\begingroup |
| 295 |
\pgfkeys{/pgf/number format/precision=0}% |
| 296 |
\expandafter\pgfmathroundto\expandafter{\pgfmathresult}% |
| 297 |
\pgfmath@smuggleone\pgfmathresult |
| 298 |
\endgroup |
| 299 |
\let\pgfplotspointmeta=\pgfmathresult |
| 300 |
\fi |
| 301 |
% now, check again: |
| 302 |
\pgfutil@ifundefined{pgfp@scatter@class@\pgfplotspointmeta}{% |
| 303 |
% still not possible? Then, try truncating the |
| 304 |
% number to an integer. |
| 305 |
\expandafter\pgfutil@in@\expandafter.\expandafter{\pgfplotspointmeta}% |
| 306 |
\ifpgfutil@in@ |
| 307 |
\def\pgfplots@loc@TMPb##1.##2\relax{\def\pgfplotspointmeta{##1}}% |
| 308 |
\expandafter\pgfplots@loc@TMPb\pgfplots@loc@TMPa\relax |
| 309 |
\fi |
| 310 |
% now, check again: |
| 311 |
\pgfutil@ifundefined{pgfp@scatter@class@\pgfplotspointmeta}{% |
| 312 |
\pgfutil@ifundefined{pgfp@scatter@WARNING@\pgfplotspointmeta}{% |
| 313 |
\pgfplotswarning{scatter classes no such class}\pgfplotspointmeta\pgfeov% |
| 314 |
\expandafter\gdef\csname pgfp@scatter@WARNING@\pgfplotspointmeta\endcsname{ALREADY CHECKED}% |
| 315 |
}{}% |
| 316 |
\def\pgfplots@loc@TMPa{}% |
| 317 |
}{% |
| 318 |
\expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfp@scatter@class@\pgfplotspointmeta\endcsname |
| 319 |
}% |
| 320 |
}{% |
| 321 |
\expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfp@scatter@class@\pgfplotspointmeta\endcsname |
| 322 |
}% |
| 323 |
}{% |
| 324 |
\expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfp@scatter@class@\pgfplotspointmeta\endcsname |
| 325 |
}% |
| 326 |
\expandafter\pgfplots@scope@with@coord@styles\expandafter[\pgfplots@loc@TMPa]% |
| 327 |
}% |
| 328 |
|
| 329 |
% validates 'mark layer' such that it can be queried afterwards. |
| 330 |
\def\pgfplots@markers@prepare@layered@graphics@marks{% |
| 331 |
\ifpgfplots@layered@graphics |
| 332 |
\pgfkeysgetvalue{/pgfplots/mark layer}\pgfplots@loc@TMPa |
| 333 |
\edef\pgfplots@loc@TMPa{\pgfplots@loc@TMPa}% |
| 334 |
\ifx\pgfplots@loc@TMPa\pgfutil@empty |
| 335 |
\def\pgfplots@loc@TMPa{auto}% |
| 336 |
\fi |
| 337 |
\def\pgfplots@loc@TMPb{auto}% |
| 338 |
\ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb |
| 339 |
% COMBINATION: 'activate layers,mark layer=auto' --> keep |
| 340 |
% backwards compatibility with 'clip marker paths' |
| 341 |
% -> nothing to do. |
| 342 |
\pgfkeyslet{/pgfplots/mark layer}\pgfutil@empty% |
| 343 |
\else |
| 344 |
% mark layer=like plot |
| 345 |
\def\pgfplots@loc@TMPb{like plot}% |
| 346 |
\ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb |
| 347 |
% draw markers together with their plot (no matter |
| 348 |
% on which layer): |
| 349 |
\pgfplots@clip@marker@pathstrue |
| 350 |
\pgfkeyslet{/pgfplots/mark layer}\pgfutil@empty% |
| 351 |
\else |
| 352 |
\edef\pgfplots@loc@TMPb{\pgfkeysvalueof{/pgfplots/on layer}}% |
| 353 |
\ifx\pgfplots@loc@TMPa\pgfplots@loc@TMPb |
| 354 |
% nothing to do; they are on the same layer |
| 355 |
% anyway: (this is the same as 'like plot' |
| 356 |
\pgfplots@clip@marker@pathstrue |
| 357 |
\pgfkeyslet{/pgfplots/mark layer}\pgfutil@empty% |
| 358 |
\else |
| 359 |
% OK, marks will be plotted on their own layer. |
| 360 |
\fi |
| 361 |
\fi |
| 362 |
\fi |
| 363 |
\else |
| 364 |
% reset its value: |
| 365 |
\pgfkeyslet{/pgfplots/mark layer}\pgfutil@empty% |
| 366 |
\fi |
| 367 |
}% |