| 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 2010 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 |
% 1. OVERVIEW |
| 28 |
% |
| 29 |
% Plot handlers are extended versions of the plot handlers of PGF with |
| 30 |
% backwards compatibility. |
| 31 |
% |
| 32 |
% To remind ourselves: PGF plot handlers work like this |
| 33 |
% \pgfplotstreamstart |
| 34 |
% \pgfplotstreampoint{...} |
| 35 |
% \pgfplotstreampoint{...} |
| 36 |
% \pgfplotstreampoint{...} |
| 37 |
% \pgfplotstreampoint{...} |
| 38 |
% \pgfplotstreamend |
| 39 |
% |
| 40 |
% and that's it. |
| 41 |
% |
| 42 |
% PGFPlots plot handlers also contain these three macros. The tasks |
| 43 |
% are (of course) the same. In addition, they support a set of further |
| 44 |
% macros for every plot handler: |
| 45 |
% |
| 46 |
% \pgfplotsplothandlersurveystart |
| 47 |
% \pgfplotsplothandlersurveypoint |
| 48 |
% \pgfplotsplothandlersurveyend |
| 49 |
% |
| 50 |
% and serialization methods |
| 51 |
% \pgfplotsplothandlerserializepointto |
| 52 |
% \pgfplotsplothandlerdeserializepointfrom |
| 53 |
% \pgfplotsplothandlerserializestateto |
| 54 |
% \pgfplotsplothandlerdeserializepointfrom |
| 55 |
% |
| 56 |
% in addition, there are utility macros |
| 57 |
% \pgfplotsplothandlersurveydifflen#1#2 |
| 58 |
% \pgfplotsplothandlersurveypointattime#1#2#3 |
| 59 |
% |
| 60 |
% The idea is as follows: |
| 61 |
% During \addplot, PGFPLots performs a survey phase. Survey means: |
| 62 |
% nothing will be drawn, only stats will be collected. In this phase, |
| 63 |
% the \pgfplotsplothandlersurvey* methods will be invoked; followed by |
| 64 |
% a serialization. |
| 65 |
% |
| 66 |
% Then, when every plot has been surveyed, PGFPlots calls |
| 67 |
% \pgfplotsplothandlerdeserializestatefrom{<serialized state>} |
| 68 |
% \pgfplotstreamstart |
| 69 |
% foreach <serizalized point> { |
| 70 |
% \pgfplotsplothandlerdeserializepointfrom{<serialized point>} |
| 71 |
% apply data transformations |
| 72 |
% handle plot marks |
| 73 |
% \pgfplotstreampoint{\pgfplotsqpointxy{<x>}{<y}} |
| 74 |
% } |
| 75 |
% \pgfplotstreamend |
| 76 |
% |
| 77 |
% See below for details about the survey phase and the visualization |
| 78 |
% phase and the API of an axis. |
| 79 |
% |
| 80 |
% Thus, the PGF basic level streams can (but don't need to) make use |
| 81 |
% of the macros assigned by the |
| 82 |
% \pgfplotsplothandlerdeserializepointfrom and |
| 83 |
% \pgfplotsplothandlerdeserializestatefrom. |
| 84 |
% |
| 85 |
% Furthermore, a plot handler *can* redefine any of the survey and/or |
| 86 |
% serialization methods to add further functionality. But it doesn't |
| 87 |
% need to, it's ok if it only relies on x,y as standard pgf plot |
| 88 |
% handlers do. |
| 89 |
% |
| 90 |
% If it overwrites something, it should do so in its main method, the |
| 91 |
% one in which it also defines the \pgf@plotstreamstart etc. methods |
| 92 |
% (see pgfmoduleplot.code.tex for example). BUT: do NOT overwrite |
| 93 |
% these methods globally! |
| 94 |
% |
| 95 |
% 2. A Description of the two phases: |
| 96 |
% |
| 97 |
% THE SURVEY PHASE: |
| 98 |
% The survey phase works as follows. |
| 99 |
% PRECONDITION: |
| 100 |
% - we are `inside' of an axis. |
| 101 |
% - \addplot starts the survey phase. |
| 102 |
% |
| 103 |
% The following happens: |
| 104 |
% - the plot handler is determined and activated such that its |
| 105 |
% methods are usable ("class is instantiated") |
| 106 |
% - \pgfplots@PREPARE@COORD@STREAM is the internal, low level |
| 107 |
% entry point where pgfplots controls the survey phase. |
| 108 |
% - the coordinate input routine is initialised. It issues a |
| 109 |
% series of commands (all within the *same* TeX scope): |
| 110 |
% \pgfplots@coord@stream@start |
| 111 |
% \pgfplots@coord@stream@coord |
| 112 |
% \pgfplots@coord@stream@coord |
| 113 |
% \pgfplots@coord@stream@coord |
| 114 |
% \pgfplots@coord@stream@coord |
| 115 |
% \pgfplots@coord@stream@coord |
| 116 |
% \pgfplots@coord@stream@coord |
| 117 |
% ... |
| 118 |
% \pgfplots@coord@stream@end |
| 119 |
% - \pgfplotsplothandlersurveystart is called in |
| 120 |
% \pgfplots@coord@stream@start. |
| 121 |
% - \pgfplots@coord@stream@coord calls |
| 122 |
% \pgfplotsplothandlersurveypoint |
| 123 |
% - \pgfplots@coord@stream@end calls |
| 124 |
% \pgfplotsplothandlersurveyend |
| 125 |
% \pgfplotsplothandlerserializestateto<\macro> |
| 126 |
% Furthermore, it remembers the <\macro> such that it can be |
| 127 |
% deserialized later. |
| 128 |
% Then, the survey phase ends. The main point of interest is the |
| 129 |
% \pgfplotsplothandlersurveypoint routine, especially its |
| 130 |
% communication with the axis. It is described below. |
| 131 |
% |
| 132 |
% POSTCONDITION: |
| 133 |
% - the state of the axis is now aware of the new plot (limits, |
| 134 |
% stacking, ...). |
| 135 |
% - The plot's survey state is stored using its serialized |
| 136 |
% representation. |
| 137 |
% |
| 138 |
% THE VISUALIZATION PHASE: |
| 139 |
% FIXME |
| 140 |
% |
| 141 |
% 2.1 The API of an axis |
| 142 |
% |
| 143 |
% As described above, the coordinate input routine fires a lot of |
| 144 |
% \pgfplots@coord@stream@coord commands, which, in turn, invoke |
| 145 |
% \pgfplotsplothandlersurveypoint. Somehow this should update the |
| 146 |
% axis' state to reflect each point. But the 'data point' is a rather |
| 147 |
% abstract thing. Usually, it will contain at least (x,y) (or maybe z) |
| 148 |
% coordinates. But it may be more complex. |
| 149 |
% |
| 150 |
% So, the coordinate input routine provides whatever the user has |
| 151 |
% chosen. Let's assume, we are using \addplot table. Then, we can |
| 152 |
% access every cell in the current row (using \thisrow{<colname>} for |
| 153 |
% example). The plot handler knows how to extract its information from |
| 154 |
% this state. In general, the following steps are taken: |
| 155 |
% - the plot handler assembles coordinates. |
| 156 |
% - every assembled coordinate should be reported to the axis by |
| 157 |
% defining \pgfplots@current@point@[xyz] to its coordinates and |
| 158 |
% calling |
| 159 |
% \pgfplotsaxisparsecoordinate{} |
| 160 |
% This will apply coordinate filters, parse the single coordinates |
| 161 |
% and apply high level transformations and any logarithms. |
| 162 |
% It is some sort of advanced coordinate parser which works only for |
| 163 |
% (x,y) or for (x,y,z). |
| 164 |
% It yields (x,y,z). But the axis might need to change its |
| 165 |
% components! Thus, you also need to call |
| 166 |
% \pgfplotsaxispreparecoordinate{}. |
| 167 |
% This will, for example, apply the "stack plots" feature or the |
| 168 |
% 'data cs' feature. |
| 169 |
% |
| 170 |
% If necessary, the plot handler calls |
| 171 |
% \pgfplotsaxisparsecoordinate{} and |
| 172 |
% \pgfplotsaxispreparecoordinate{} multiple times, once for each |
| 173 |
% encountered coordinate. |
| 174 |
% |
| 175 |
% It might occasionally be too much to call |
| 176 |
% \pgfplotsaxispreparecoordinate. |
| 177 |
% |
| 178 |
% It might happen that a coordinate filter discards a coordinate. |
| 179 |
% This is returned in the \ifpgfplotsaxisparsecoordinateok boolean |
| 180 |
% and has to be checked by the plot handler. |
| 181 |
% |
| 182 |
% - the plot handler knows which of the coordinates contribute to the |
| 183 |
% final plot. It invokes |
| 184 |
% \ifpgfplotsaxisparsecoordinateok |
| 185 |
% \pgfplotsaxisupdatelimitsforcoordinate{<x>}{<y>}{<z>} |
| 186 |
% \fi |
| 187 |
% for each of these coordinates. This has to be done for final |
| 188 |
% coordinates only, i.e. after \pgfplotsaxispreparecoordinate. |
| 189 |
% |
| 190 |
% - eventually, the plot handler is satisfied and considers a data |
| 191 |
% point as "readily surveyed". It is allowed if this does *not* |
| 192 |
% happen inside of \pgfplotsplothandlersurveypoint, but it must |
| 193 |
% happen before \pgfplotsplothandlersurveyend is finished. |
| 194 |
% |
| 195 |
% The plot handler invokes \pgfplotsaxisdatapointsurveyed. |
| 196 |
% This tells the axis that it can perform its own surveying tasks |
| 197 |
% (see below) and furthermore, that it can serialize the data point. |
| 198 |
% Consequently, it will invoke |
| 199 |
% \pgfplotsplothandlerserializepointto{<\macro>} |
| 200 |
% and it will remember that \macro internally. This serialization is |
| 201 |
% employed to place plot marks and to apply z buffering techniques |
| 202 |
% (that's why it is done by the axis and not by the plot handler on |
| 203 |
% its own). |
| 204 |
% |
| 205 |
% The axis does its own surveying task, initiated by |
| 206 |
% \pgfplotsaxisdatapointsurveyed (which is, turn, invoked by the |
| 207 |
% plot handler). This command handles the |point meta| feature, that |
| 208 |
% is: it queries the |point meta| input source and updates the meta |
| 209 |
% limits. Furthermore, the error bar feature is processed at this |
| 210 |
% point (using the final data point's (x,y,z) coordinates as basis). |
| 211 |
% The |xtick=data| feature is also prepared at this stage. |
| 212 |
% |
| 213 |
% - Later, the coordinate input routine invokes |
| 214 |
% \pgfplots@coord@stream@end indicating the end-of-input. This will |
| 215 |
% finalize the survey phase. |
| 216 |
% |
| 217 |
% A simple example looks like this: |
| 218 |
% \pgfplotsplothandlersurveystart: does nothing in the simple example. |
| 219 |
% \pgfplotsplothandlersurveypoint: |
| 220 |
% parses the input format somehow to get (x,y,z) in raw, symbolic format |
| 221 |
% calls \pgfplotsaxisparsecoordinate |
| 222 |
% calls \pgfplotsaxispreparecoordinate |
| 223 |
% calls \ifpgfplotsaxisparsecoordinateok \pgfplotsaxisupdatelimitsforcoordinate{<x>}{<y>}{<z} \fi |
| 224 |
% calls \pgfplotsaxisdatapointsurveyed |
| 225 |
% \pgfplotsplothandlersurveyend: does nothing in the simple example. |
| 226 |
% |
| 227 |
% In fact, this is more or less the initial configuration used for |
| 228 |
% lineto or similar plot handlers. |
| 229 |
% |
| 230 |
% 2.2 Further Survey Phase API functions |
| 231 |
% \pgfplotssurveyphaseinputclass |
| 232 |
% expands to the actual name of the input method (like |
| 233 |
% 'coordinates', 'expression' or 'table') |
| 234 |
% |
| 235 |
% \pgfplotsplothandlernotifyscanlinecomplete |
| 236 |
% Called whenever an end-of-scanline marker has been processed, i.e. |
| 237 |
% whenever the 'empty line' key has been triggered. The default is to |
| 238 |
% do nothing. |
| 239 |
% |
| 240 |
% \pgfplotsaxissurveysetpointmeta |
| 241 |
% processes the 'point meta' key, i.e. it assigns |
| 242 |
% \pgfplots@current@point@meta. This macro can only be called once for |
| 243 |
% each coordinate (it will be deactivated afterwards). PGFPlots calls |
| 244 |
% it in \pgfplotsaxisdatapointsurveyed . |
| 245 |
% |
| 246 |
% \pgfplotsplothandlersurveyaddoptions{<options>} |
| 247 |
% which allows to change the current plot style from within API |
| 248 |
% functions. It sets <options> and remembers them for the |
| 249 |
% visualization phase. |
| 250 |
% |
| 251 |
% \pgfplotsaxisupdatelimitsforpointmeta{<meta>}, |
| 252 |
% provided there is a point meta input handler (which is numeric). |
| 253 |
% Otherwise, the command is equal to \relax. |
| 254 |
% |
| 255 |
% |
| 256 |
% 3. Details about the VISUALIZATION phase |
| 257 |
% |
| 258 |
% The visualization phase consists of |
| 259 |
% <installation of the plot handler> |
| 260 |
% \pgfplotstreamstart |
| 261 |
% foreach serialized coordinate { |
| 262 |
% pgfplots calls \pgfplotsplothandlerdeserializestatefrom{<serialized repr>} |
| 263 |
% if coordinate is empty ("unbounded") |
| 264 |
% pgfplots call \pgfplotsplothandlervisualizejump |
| 265 |
% else |
| 266 |
% pgfplots calls \pgfplotsaxisvisphasetransformcoordinate |
| 267 |
% pgfplots calls \pgfplotsaxisvisphasepreparedatapoint |
| 268 |
% pgfplots calls either \pgfplotsqpointxyz or \pgfplotsqpointxy |
| 269 |
% fi |
| 270 |
% \pgfplotstreampoint |
| 271 |
% } |
| 272 |
% \pgfplotstreamend |
| 273 |
% |
| 274 |
% User defined plot handlers might need to invoke |
| 275 |
% \pgfplotsaxisvisphasetransformcoordinate on their own. |
| 276 |
% |
| 277 |
% During the visualization phase, the following macros can be used: |
| 278 |
% |
| 279 |
% - \pgfplotsaxisvisphasetransformpointmeta to set up point meta. |
| 280 |
% Use this only if there *is* point meta, see |
| 281 |
% \pgfplotsaxisifhaspointmeta{<true code>}{<false code>}. |
| 282 |
% |
| 283 |
% - \pgfplotsaxisvisphasegetpoint |
| 284 |
% does not take arguments. It takes the current point as input and |
| 285 |
% sets \pgf@x, \pgf@y to the final result. |
| 286 |
% |
| 287 |
% 4. API Functions of pgfplots to work with the visualization phases |
| 288 |
% |
| 289 |
% \pgfplotsifissurveyphase{<true code>}{<false code>} |
| 290 |
% \pgfplotsifisvisualizationphase{<true code>}{<false code>} |
| 291 |
% |
| 292 |
% \pgfplotsaxisfilteredcoordsaway |
| 293 |
% This macro expands to '1' if all points have been surveyed |
| 294 |
% successfully. It expands to '0' if at least one point has been |
| 295 |
% filtered away (for whatever reasons). This does not apply to |
| 296 |
% jumps. |
| 297 |
% \pgfplotsaxisplothasjumps |
| 298 |
% This macro expands to '1' if the current plot has jumps and '0' |
| 299 |
% if not.During the visualization phase, a jump is usually indicated |
| 300 |
% by an empty coordinate. |
| 301 |
% \pgfplotsaxisplothasunboundedpointmeta |
| 302 |
% This macro expands to '1' if the current plot has a point with |
| 303 |
% unbounded point meta and '0' |
| 304 |
% if not. Currently used by some plot handlers as synonym for |
| 305 |
% "visualize a jump" |
| 306 |
|
| 307 |
\def\pgfplotssurveyphaseinputclass{direct} |
| 308 |
|
| 309 |
\def\pgfplotsplothandlers@tikz@with@snap@to@nearest{% |
| 310 |
\pgfplothandlerdiscard,% |
| 311 |
\pgfplothandlermark,% |
| 312 |
\pgfplothandlermarklisted,% |
| 313 |
\pgfplothandlerxbar,% |
| 314 |
\pgfplothandlerybar,% |
| 315 |
\pgfplothandlerxbarinterval,% |
| 316 |
\pgfplothandlerybarinterval% |
| 317 |
}% |
| 318 |
|
| 319 |
\def\pgfplotsplothandlers@tikz@std{% |
| 320 |
\pgfplothandlerdiscard,% |
| 321 |
\pgfplothandlermark,% |
| 322 |
\pgfplothandlermarklisted,% |
| 323 |
\pgfplothandlerxbar,% |
| 324 |
\pgfplothandlerybar,% |
| 325 |
\pgfplothandlerxbarinterval,% |
| 326 |
\pgfplothandlerybarinterval,% |
| 327 |
\pgfplothandlerlineto,% |
| 328 |
\pgfplothandlercurveto,% |
| 329 |
\pgfplothandlerconstantlineto,% |
| 330 |
\pgfplothandlerconstantlinetomarkright,% |
| 331 |
\pgfplothandlerconstantlinetomarkmid,% |
| 332 |
\pgfplothandlerpolarcomb,% |
| 333 |
\pgfplothandlerjumpmarkmid,% |
| 334 |
\pgfplothandlerjumpmarkleft,% |
| 335 |
\pgfplothandlerjumpmarkright% |
| 336 |
}% |
| 337 |
|
| 338 |
% Defines \pgfplotsretval to be the csname for the BACKUP of plot |
| 339 |
% handler #1. |
| 340 |
% |
| 341 |
% For example: |
| 342 |
% \pgfplotsplothandlers@get@tikz@backup@name{\pgfplothandlerlineto} |
| 343 |
% will return \pgfplotsretval={\\pgfplothandlerlineto@tikz} |
| 344 |
% (up to \escapechar) |
| 345 |
\def\pgfplotsplothandlers@get@tikz@backup@name#1{% |
| 346 |
\begingroup |
| 347 |
%\escapechar=-1 % drop the leading backslash |
| 348 |
\expandafter\gdef\expandafter\pgfplotsretval\expandafter{\csname \string#1@tikz\endcsname}% |
| 349 |
\pgfmath@smuggleone\pgfplotsretval |
| 350 |
\endgroup |
| 351 |
}% |
| 352 |
|
| 353 |
% Takes the CURRENT \tikz@plot@handler and checks if it is an UNPATCHED tikz plot |
| 354 |
% handler. If so, it replaced it with the correct patched version. |
| 355 |
% |
| 356 |
% The motivation is that uf \tikz@plot@handler has been set outside of |
| 357 |
% an axis, it will not reflect the most recent changes (which are only |
| 358 |
% applied within an axis). |
| 359 |
\def\pgfplotsplothandlers@init@map@to@patched@versions{% |
| 360 |
% iterate through all tikz plot handlers... |
| 361 |
\expandafter\pgfplotsutilforeachcommasep\expandafter{\pgfplotsplothandlers@tikz@std}% |
| 362 |
\as\pgfplots@loc@TMPa{% |
| 363 |
% ... get the name of the backup (see \pgfplotsplothandlers@init) |
| 364 |
\expandafter\pgfplotsplothandlers@get@tikz@backup@name\pgfplots@loc@TMPa |
| 365 |
\expandafter\ifx\pgfplotsretval\tikz@plot@handler |
| 366 |
% AH! \tikz@plot@handler is the same as some backup name! |
| 367 |
% Replace it: |
| 368 |
\expandafter\let\expandafter\tikz@plot@handler\pgfplots@loc@TMPa |
| 369 |
\fi |
| 370 |
}% |
| 371 |
}% |
| 372 |
|
| 373 |
\def\pgfplotsplothandlers@init{% |
| 374 |
\def\pgfplotsplothandlers@init@##1{% |
| 375 |
\pgfplotsutil@add@to@macro##1{% |
| 376 |
\let\pgfplotsplothandlersurveydifflen=\pgfplotsplothandlersurveydifflen@snaptonearest |
| 377 |
\let\pgfplotsplothandlersurveypointattime=\pgfplotsplothandlersurveypointattime@snaptonearest |
| 378 |
}% |
| 379 |
}% |
| 380 |
\def\pgfplotsplothandlers@init@@##1{% |
| 381 |
% create backup: |
| 382 |
% |
| 383 |
% if ##1 = \pgfplothandlerlineto, this defines |
| 384 |
% \pgfplothandlerlineto@tikz as backup. |
| 385 |
\pgfplotsplothandlers@get@tikz@backup@name{##1}% |
| 386 |
\expandafter\let\pgfplotsretval=##1% |
| 387 |
% |
| 388 |
% |
| 389 |
% assign more suitable names: |
| 390 |
\pgfplotsutil@add@to@macro##1{% |
| 391 |
\begingroup |
| 392 |
\escapechar=-1 % drop the leading backslash |
| 393 |
\edef\pgfplotsplothandlername{\string##1}% |
| 394 |
\pgfmath@smuggleone\pgfplotsplothandlername |
| 395 |
\endgroup |
| 396 |
% |
| 397 |
\def\pgfplotsplothandlerLUAfactory{function(axis, pointmetainputhandler) return pgfplots.GenericPlothandler.new("\pgfplotsplothandlername", axis,pointmetainputhandler) end}% |
| 398 |
\def\pgfplotsplothandlerLUAvisualizerfactory{pgfplots.defaultPlotVisualizerFactory}% |
| 399 |
}% |
| 400 |
}% |
| 401 |
% Patch all TikZ plot handlers: |
| 402 |
% this here also creates backups |
| 403 |
\expandafter\pgfplotsutilforeachcommasep\expandafter{\pgfplotsplothandlers@tikz@std}% |
| 404 |
\as\pgfplots@loc@TMPa{% |
| 405 |
\expandafter\pgfplotsplothandlers@init@@\expandafter{\pgfplots@loc@TMPa}% |
| 406 |
}% |
| 407 |
% |
| 408 |
% Patch only selected ones: |
| 409 |
\expandafter\pgfplotsutilforeachcommasep\expandafter{\pgfplotsplothandlers@tikz@with@snap@to@nearest}% |
| 410 |
\as\pgfplots@loc@TMPa{% |
| 411 |
\expandafter\pgfplotsplothandlers@init@\expandafter{\pgfplots@loc@TMPa}% |
| 412 |
}% |
| 413 |
% |
| 414 |
\if1\b@pgfplots@compat@bar@width@units |
| 415 |
\else |
| 416 |
\def\pgfplotbarwidth{\pgfplots@bar@width@not@in@context}% |
| 417 |
\def\pgfplotbarshift{\pgfplots@bar@shift@not@in@context}% |
| 418 |
\pgfplotsutil@add@to@macro\pgfplothandlerxbar{% |
| 419 |
\def\pgfplotbarwidth{\pgfplots@xbar@width}% |
| 420 |
\def\pgfplotbarshift{\pgfplots@xbar@shift}% |
| 421 |
}% |
| 422 |
\pgfplotsutil@add@to@macro\pgfplothandlerybar{% |
| 423 |
\def\pgfplotbarwidth{\pgfplots@ybar@width}% |
| 424 |
\def\pgfplotbarshift{\pgfplots@ybar@shift}% |
| 425 |
}% |
| 426 |
\fi |
| 427 |
% |
| 428 |
\pgfplotsplothandlers@init@map@to@patched@versions |
| 429 |
% |
| 430 |
% |
| 431 |
% \pgfkeys{% |
| 432 |
% /pgf/at begin bar/.add={}{% |
| 433 |
% \if1\b@has@pgfplots@colordinate@style |
| 434 |
% \expandafter\pgfplots@bar@extra |
| 435 |
% \fi |
| 436 |
% },% |
| 437 |
% }% |
| 438 |
% |
| 439 |
}% |
| 440 |
|
| 441 |
\def\pgfplots@bar@extra#1\pgfkeysvalueof#2{% |
| 442 |
\expandafter\tikz\expandafter[\pgfplots@current@point@coordinatestyle] \pgfextra{#1};% |
| 443 |
}% |
| 444 |
|
| 445 |
\def\pgfplots@xbar@width{pgfplotsxbarwidth} |
| 446 |
\def\pgfplots@ybar@width{pgfplotsybarwidth} |
| 447 |
\def\pgfplots@xbar@shift{pgfplotsxbarshift} |
| 448 |
\def\pgfplots@ybar@shift{pgfplotsybarshift} |
| 449 |
\def\pgfplots@bar@width@not@in@context{pgfplotsbarwidthgeneric} |
| 450 |
\def\pgfplots@bar@shift@not@in@context{pgfplotsbarshiftgeneric} |
| 451 |
|
| 452 |
\pgfplotsmathdeclarepseudoconstant{pgfplotsxbarwidth}{\pgfplots@bar@mathparse@{y}{bar width}}% |
| 453 |
\pgfplotsmathdeclarepseudoconstant{pgfplotsybarwidth}{\pgfplots@bar@mathparse@{x}{bar width}}% |
| 454 |
\pgfplotsmathdeclarepseudoconstant{pgfplotsxbarshift}{\pgfplots@bar@mathparse@{y}{bar shift}}% |
| 455 |
\pgfplotsmathdeclarepseudoconstant{pgfplotsybarshift}{\pgfplots@bar@mathparse@{x}{bar shift}}% |
| 456 |
\pgfplotsmathdeclarepseudoconstant{pgfplotsbarwidthgeneric}{\pgfplots@bar@mathparse@{N}{bar width}}% |
| 457 |
\pgfplotsmathdeclarepseudoconstant{pgfplotsbarshiftgeneric}{\pgfplots@bar@mathparse@{N}{bar shift}}% |
| 458 |
|
| 459 |
\def\pgfplots@bar@mathparse@#1#2{% |
| 460 |
\pgfmathparse{\pgfkeysvalueof{/pgf/#2}}% |
| 461 |
\ifpgfmathunitsdeclared |
| 462 |
\else |
| 463 |
\edef\pgfplots@bar@direction@choice@{#1}% |
| 464 |
\if N\pgfplots@bar@direction@choice@% |
| 465 |
\if a\pgfplots@bar@direction@choice |
| 466 |
\else |
| 467 |
\if x\pgfplots@bar@direction@choice |
| 468 |
\def\pgfplots@bar@direction@choice@{y}% |
| 469 |
\else |
| 470 |
\if y\pgfplots@bar@direction@choice |
| 471 |
\def\pgfplots@bar@direction@choice@{x}% |
| 472 |
\else |
| 473 |
\pgfplotsthrow{invalid argument}{\pgfplots@bar@direction@choice@}{Sorry, the value of 'bar direction' is invalid}\pgfeov% |
| 474 |
\fi |
| 475 |
\fi |
| 476 |
\fi |
| 477 |
\fi |
| 478 |
\if N\pgfplots@bar@direction@choice@% |
| 479 |
\pgfplots@bar@mathparse@error{#1}{#2}% |
| 480 |
\else |
| 481 |
\let\pgfplots@loc@TMPa=\pgfmathresult |
| 482 |
\csname pgfplotstransformdirection\pgfplots@bar@direction@choice@\endcsname{\pgfplots@loc@TMPa}% |
| 483 |
\let\pgfplots@loc@TMPa=\pgfmathresult |
| 484 |
\if\pgfplots@bar@direction@choice@ x% |
| 485 |
\pgfqpointxy@orig{\pgfplots@loc@TMPa}{0}% |
| 486 |
\edef\pgfmathresult{\pgf@sys@tonumber\pgf@x}% |
| 487 |
\else |
| 488 |
\pgfqpointxy@orig{0}{\pgfplots@loc@TMPa}% |
| 489 |
\edef\pgfmathresult{\pgf@sys@tonumber\pgf@y}% |
| 490 |
\fi |
| 491 |
%\edef\pgfplots@loc@TMPa{{\pgf@sys@tonumber\pgf@x}{\pgf@sys@tonumber\pgf@y}}% |
| 492 |
%\expandafter\pgfmathveclen@\pgfplots@loc@TMPa |
| 493 |
\fi |
| 494 |
\fi |
| 495 |
}% |
| 496 |
|
| 497 |
\def\pgfplots@bar@mathparse@error#1#2{% |
| 498 |
\pgfplotsthrow{invalid argument}{\pgfplots@bar@direction@choice@}{Sorry, the value '#2=\pgfkeysvalueof{/pgf/#2}' is given in terms of a unit -- but I do not know which axis! Next steps: either (a) set one of 'xbar' or 'ybar' before evaluating the value of '#2' or (b) define 'bar direction=x or y'}\pgfeov% |
| 499 |
}% |
| 500 |
|
| 501 |
% Resets the plot handler routines. |
| 502 |
% |
| 503 |
% This is necessary before installing a new plot handler! |
| 504 |
\def\pgfplotsresetplothandler{% |
| 505 |
\let\pgfplotsplothandlersurveystart=\pgfplotsplothandlersurveystart@default |
| 506 |
\let\pgfplotsplothandlerLUAfactory=\pgfplotsplothandlerLUAfactory@default |
| 507 |
\let\pgfplotsplothandlerLUAvisualizerfactory=\pgfplotsplothandlerLUAvisualizerfactory@default |
| 508 |
\let\pgfplotsplothandlername=\pgfplotsplothandlername@default |
| 509 |
\let\pgfplotsplothandlersurveyend=\pgfplotsplothandlersurveyend@default |
| 510 |
\let\pgfplotsplothandlersurveypoint=\pgfplotsplothandlersurveypoint@default |
| 511 |
\let\pgfplotsplothandlerpointtokeys=\pgfplotsplothandlerpointtokeys@default |
| 512 |
\let\pgfplotsplothandlerserializepointto=\pgfplotsplothandlerserializepointto@default |
| 513 |
\let\pgfplotsplothandlerdeserializepointfrom=\pgfplotsplothandlerdeserializepointfrom@default |
| 514 |
\let\pgfplotsplothandlerserializestateto=\pgfplotsplothandlerserializestateto@default |
| 515 |
\let\pgfplotsplothandlerdeserializestatefrom=\pgfplotsplothandlerdeserializestatefrom@default |
| 516 |
\let\pgfplotsplothandlervisualizejump=\pgfplotsplothandlervisualizejump@default |
| 517 |
\let\pgfplotsplothandlernotifyscanlinecomplete=\relax |
| 518 |
\let\pgfplotsplothandlersurveydifflen=\pgfplotsplothandlersurveydifflen@default |
| 519 |
\let\pgfplotsplothandlersurveypointattime=\pgfplotsplothandlersurveypointattime@default |
| 520 |
\let\pgfplotsplothandlertransformslopedattime=\pgfplotsplothandlertransformslopedattime@default |
| 521 |
\let\pgfplotsplothandlerifcurrentpointcanbefirstlast=\pgfplotsplothandlerifcurrentpointcanbefirstlast@default |
| 522 |
% |
| 523 |
\let\pgfplotsplothandlersurveybeforesetpointmeta=\pgfplotsplothandlersurveybeforesetpointmeta@default |
| 524 |
\let\pgfplotsplothandlersurveyaftersetpointmeta=\pgfplotsplothandlersurveyaftersetpointmeta@default |
| 525 |
}% |
| 526 |
|
| 527 |
\def\pgfplotsplothandlersurveybeforesetpointmeta@default{} |
| 528 |
\def\pgfplotsplothandlersurveyaftersetpointmeta@default{} |
| 529 |
|
| 530 |
% \pgfplotsplothandlersurveystart |
| 531 |
\def\pgfplotsplothandlersurveystart@default{}% |
| 532 |
|
| 533 |
% \pgfplotsplothandlername |
| 534 |
\def\pgfplotsplothandlername@default{% |
| 535 |
[tikz@plot@handler: \meaning\pgf@plotstreamstart]% |
| 536 |
}% |
| 537 |
|
| 538 |
% This should expand to a LUA function which takes the axis and the point |
| 539 |
% meta handler. |
| 540 |
% Use empty if there is none. |
| 541 |
\def\pgfplotsplothandlerLUAfactory@default{}% |
| 542 |
|
| 543 |
% This should expand to a LUA function which takes an instance of |
| 544 |
% Plothandler and which should return a PlotVisualizer. |
| 545 |
% Use empty if there is none. |
| 546 |
% |
| 547 |
% @see LUA: pgfplots.PlotVisualizer |
| 548 |
\def\pgfplotsplothandlerLUAvisualizerfactory@default{}% |
| 549 |
|
| 550 |
% \pgfplotsplothandlerifcurrentpointcanbefirstlast : can be used to |
| 551 |
% check if the current point of a plot handler can be the global first |
| 552 |
% or last segment. |
| 553 |
% It will execute #1 if that is the case and #2 if not. |
| 554 |
\def\pgfplotsplothandlerifcurrentpointcanbefirstlast@default#1#2{#1}% |
| 555 |
|
| 556 |
|
| 557 |
% \pgfplotsplothandlersurveyend |
| 558 |
% Called at the end of each survey phase. |
| 559 |
\def\pgfplotsplothandlersurveyend@default{} |
| 560 |
|
| 561 |
% A callback which will be called as soon as a scanline is complete. |
| 562 |
% |
| 563 |
% The callback can differ from plot handler to plot handler; its |
| 564 |
% purpose is to update data structures. |
| 565 |
% |
| 566 |
% Implementational note for those who _call_ the callback: the |
| 567 |
% The callback will be triggered by the 'empty line' handling, see |
| 568 |
% \pgfplotsscanlinelengthinitzero. However, a coordinate generator can |
| 569 |
% safely invoke it directly. It must not be invoked twice for the same |
| 570 |
% scanline. |
| 571 |
% |
| 572 |
% FIXME: only 'empty line=scanline' currently calls this callback! |
| 573 |
\let\pgfplotsplothandlernotifyscanlinecomplete=\relax% |
| 574 |
|
| 575 |
% \pgfplotsplothandlersurveypoint is called for each encountered data |
| 576 |
% point. |
| 577 |
% |
| 578 |
% The data point as such is available using the current state of any |
| 579 |
% macros which are assigned during the survey phase (during \addplot). |
| 580 |
% This includes any table macros etc. |
| 581 |
% PGFPlots stores the x,y and z coordinates into \pgfplots@current@point@[xyz]. |
| 582 |
% The point meta coordinate is in \pgfplots@current@point@meta. |
| 583 |
% |
| 584 |
% Note that since any currently assigned macro can be used here, the |
| 585 |
% new DV engine of PGF is also valid (and will be supported |
| 586 |
% eventually). This DV engine stores data point entries in keys, |
| 587 |
% namely those in the key path /data point. See the pgf manual. |
| 588 |
\def\pgfplotsplothandlersurveypoint@default{% |
| 589 |
\ifpgfplots@LUA@backend@supported |
| 590 |
\pgfplots@LUA@survey@point |
| 591 |
\else |
| 592 |
\pgfplotsplothandlersurveypoint@default@ |
| 593 |
\fi |
| 594 |
}% |
| 595 |
\def\pgfplotsplothandlersurveypoint@default@{% |
| 596 |
% reset it. NOTE: this might be done multiple times. But better one |
| 597 |
% too much than one too few... |
| 598 |
\def\pgfplots@set@perpointmeta@done{0}% |
| 599 |
% |
| 600 |
\pgfplotsplothandlersurveypoint@default@noreset@of@pointmeta |
| 601 |
}% |
| 602 |
\def\pgfplotsplothandlersurveypoint@default@noreset@of@pointmeta{% |
| 603 |
\pgfplotsaxisparsecoordinate |
| 604 |
\pgfplotsaxispreparecoordinate |
| 605 |
\ifpgfplotsaxisparsecoordinateok |
| 606 |
\pgfplotsaxisupdatelimitsforcoordinate\pgfplots@current@point@x\pgfplots@current@point@y\pgfplots@current@point@z |
| 607 |
\fi |
| 608 |
\pgfplotsaxisdatapointsurveyed |
| 609 |
}% |
| 610 |
|
| 611 |
% \pgfplotsplothandlerserializepointto{<\macro>} |
| 612 |
% should save a complete data point to <\macro> such that it can be |
| 613 |
% de-serialized later. |
| 614 |
% |
| 615 |
% #1: a macro name. Will be filled with (expandable) data. |
| 616 |
% The format can be arbitrary, but you should be able to extra it. |
| 617 |
% |
| 618 |
% @PRECONDITION |
| 619 |
% this macro will be invoked in a context where the current data |
| 620 |
% point has been processed completely, including any preparations. |
| 621 |
% The required data which should be saved depends on the plot |
| 622 |
% handler. Usually, all plot handlers require |
| 623 |
% \pgfplots@current@point@[xyz] and \pgfplots@current@point@meta. |
| 624 |
% This macro should only assign keys which have been defined or |
| 625 |
% validated by any of the plot handler relevant methods (including |
| 626 |
% the de-serialization or survey methods). |
| 627 |
\def\pgfplotsplothandlerserializepointto@default#1{% |
| 628 |
% Store normalized point for list: |
| 629 |
% We need |
| 630 |
% xi,yi,zi; |
| 631 |
% where zi may be empty. |
| 632 |
% |
| 633 |
% Note that per-point meta information is stored in |
| 634 |
% \pgfplotsaxisserializedatapoint . |
| 635 |
\edef#1{\pgfplots@current@point@x,\pgfplots@current@point@y,\pgfplots@current@point@z}% |
| 636 |
}% |
| 637 |
|
| 638 |
% \pgfplotsplothandlerdeserializepointfrom{<\macro>} |
| 639 |
% the counterpart for \pgfplotsplothandlerserializepointto. |
| 640 |
% It restores the state as it was before the serialization. |
| 641 |
% |
| 642 |
% #1: the serialized information. |
| 643 |
\def\pgfplotsplothandlerdeserializepointfrom@default#1{% |
| 644 |
\expandafter\pgfplotsplothandlerdeserializepointfrom@default@#1\relax |
| 645 |
}% |
| 646 |
|
| 647 |
% \pgfplotsplothandlerpointtokeys{<key prefix>} |
| 648 |
% |
| 649 |
% Takes the current point and copies its values to a set of keys. |
| 650 |
% |
| 651 |
% For example, if the current point has the three coordinates x=1, |
| 652 |
% y=2, z=3, |
| 653 |
% \pgfplotsplothandlerpointtokeys{/data point/first/} |
| 654 |
% will define the keys |
| 655 |
% /data point/first/x/.initial=1 |
| 656 |
% /data point/first/y/.initial=2 |
| 657 |
% /data point/first/z/.initial=3 |
| 658 |
% |
| 659 |
\def\pgfplotsplothandlerpointtokeys@default#1{% |
| 660 |
\pgfkeyslet{#1/x}\pgfplots@current@point@x |
| 661 |
\pgfkeyslet{#1/y}\pgfplots@current@point@y |
| 662 |
\pgfkeyslet{#1/z}\pgfplots@current@point@z |
| 663 |
}% |
| 664 |
|
| 665 |
\def\pgfplotsplothandlerdeserializepointfrom@default@#1,#2,#3\relax{% |
| 666 |
\def\pgfplots@current@point@x{#1}% |
| 667 |
\def\pgfplots@current@point@y{#2}% |
| 668 |
\def\pgfplots@current@point@z{#3}% |
| 669 |
}% |
| 670 |
% \pgfplotsplothandlerserializestateto{<\macro>} |
| 671 |
% should save the state of the current plot handler such that it can |
| 672 |
% be de-serialized later. |
| 673 |
% |
| 674 |
% The state does usually NOT contain a coordinate stream, this is |
| 675 |
% accomplished by \pgfplotsplothandlerserializepointto. |
| 676 |
% |
| 677 |
% #1: a macro name. Can be filled with anything, including |
| 678 |
% non-expandable macro invocations. |
| 679 |
\def\pgfplotsplothandlerserializestateto@default#1{% |
| 680 |
\def#1{}% |
| 681 |
}% |
| 682 |
|
| 683 |
% |
| 684 |
\def\pgfplotsplothandlerdeserializestatefrom@default#1{% |
| 685 |
#1% |
| 686 |
}% |
| 687 |
|
| 688 |
\def\pgfplotsplothandlervisualizejump@default{% |
| 689 |
\pgfplotstreamend |
| 690 |
\pgfplotstreamstart |
| 691 |
}% |
| 692 |
|
| 693 |
% \pgfplotsplothandlersurveypointattime#1#2#3 |
| 694 |
% |
| 695 |
% sets the current environment to a point which is between points #2 |
| 696 |
% and #3, using the fraction #1. |
| 697 |
% |
| 698 |
% #1 a fraction (a number between 0 and 1) in the format of |
| 699 |
% \pgfplotscoordmath{default} |
| 700 |
% #2 a serialized point denoting the start |
| 701 |
% #3 a serialized point denoting the end |
| 702 |
% |
| 703 |
% In other words: #1 = 0.0 should result in #2 and #1 = 1.0 should |
| 704 |
% result in #3. |
| 705 |
% |
| 706 |
% POSTCONDITION: the current point will be set to the point |
| 707 |
% in-between. The current point is set in terms of logical coordinates |
| 708 |
% (i.e. \pgfplots@current@point@x and its variants) |
| 709 |
\def\pgfplotsplothandlersurveypointattime@default#1#2#3{% |
| 710 |
\begingroup |
| 711 |
\pgfplotsplothandlerdeserializepointfrom{#2}% |
| 712 |
\let\pgfplots@last@x=\pgfplots@current@point@x |
| 713 |
\let\pgfplots@last@y=\pgfplots@current@point@y |
| 714 |
\let\pgfplots@last@z=\pgfplots@current@point@z |
| 715 |
\pgfplotsplothandlerdeserializepointfrom{#3}% |
| 716 |
% |
| 717 |
\def\pgfplots@loc@TMPa##1{% |
| 718 |
\pgfplotscoordmath{##1}{op}{subtract}{{\csname pgfplots@current@point@##1\endcsname}{\csname pgfplots@last@##1\endcsname}}% |
| 719 |
\let\pgfplots@diff=\pgfmathresult |
| 720 |
\pgfplotscoordmath{##1}{parsenumber}{#1}% |
| 721 |
\pgfplotscoordmath{##1}{op}{multiply}{{\pgfmathresult}{\pgfplots@diff}}% |
| 722 |
\pgfplotscoordmath{##1}{op}{add}{{\csname pgfplots@last@##1\endcsname}{\pgfmathresult}}% |
| 723 |
\expandafter\let\csname pgfplots@current@point@##1\endcsname=\pgfmathresult |
| 724 |
}% |
| 725 |
\pgfplots@loc@TMPa x% |
| 726 |
\pgfplots@loc@TMPa y% |
| 727 |
\ifpgfplots@curplot@threedim |
| 728 |
\pgfplots@loc@TMPa z% |
| 729 |
\fi |
| 730 |
\xdef\pgfplots@glob@TMPb{% |
| 731 |
\noexpand\def\noexpand\pgfplots@current@point@x{\pgfplots@current@point@x}% |
| 732 |
\noexpand\def\noexpand\pgfplots@current@point@y{\pgfplots@current@point@y}% |
| 733 |
\noexpand\def\noexpand\pgfplots@current@point@z{\pgfplots@current@point@z}% |
| 734 |
}% |
| 735 |
\endgroup |
| 736 |
\pgfplots@glob@TMPb |
| 737 |
}% |
| 738 |
|
| 739 |
% \pgfplotsplothandlersurveydifflen#1#2 |
| 740 |
% |
| 741 |
% computes the length between two points which are given in logical |
| 742 |
% coordinates. |
| 743 |
% #1 a serialized point |
| 744 |
% #2 a serialized point |
| 745 |
% |
| 746 |
% The return value is assigned to \pgfmathresult in |
| 747 |
% \pgfplotscoordmath{default} format. |
| 748 |
\def\pgfplotsplothandlersurveydifflen@default#1#2{% |
| 749 |
\begingroup |
| 750 |
\pgfplotsplothandlerdeserializepointfrom{#1}% |
| 751 |
\let\pgfplots@last@x=\pgfplots@current@point@x |
| 752 |
\let\pgfplots@last@y=\pgfplots@current@point@y |
| 753 |
\let\pgfplots@last@z=\pgfplots@current@point@z |
| 754 |
\pgfplotsplothandlerdeserializepointfrom{#2}% |
| 755 |
\pgfplotscoordmathparsemacro{default}\pgfplots@last@x |
| 756 |
\pgfplotscoordmathparsemacro{default}\pgfplots@last@y |
| 757 |
\pgfplotscoordmathparsemacro{default}\pgfplots@current@point@x |
| 758 |
\pgfplotscoordmathparsemacro{default}\pgfplots@current@point@y |
| 759 |
\ifpgfplots@curplot@threedim |
| 760 |
\pgfplotscoordmathparsemacro{default}\pgfplots@last@z |
| 761 |
\pgfplotscoordmathparsemacro{default}\pgfplots@current@point@z |
| 762 |
\fi |
| 763 |
\pgfplotscoordmath{default}{op}{subtract}{{\pgfplots@current@point@x}{\pgfplots@last@x}}% |
| 764 |
\pgfplotscoordmath{default}{op}{multiply}{{\pgfmathresult}{\pgfmathresult}}% |
| 765 |
\let\pgfplots@diff@x=\pgfmathresult |
| 766 |
\pgfplotscoordmath{default}{op}{subtract}{{\pgfplots@current@point@y}{\pgfplots@last@y}}% |
| 767 |
\pgfplotscoordmath{default}{op}{multiply}{{\pgfmathresult}{\pgfmathresult}}% |
| 768 |
\let\pgfplots@diff@y=\pgfmathresult |
| 769 |
\pgfplotscoordmath{default}{op}{add}{{\pgfplots@diff@x}{\pgfplots@diff@y}}% |
| 770 |
\let\pgfplots@len=\pgfmathresult |
| 771 |
\ifpgfplots@curplot@threedim |
| 772 |
\pgfplotscoordmath{default}{op}{subtract}{{\pgfplots@current@point@z}{\pgfplots@last@z}}% |
| 773 |
\pgfplotscoordmath{default}{op}{multiply}{{\pgfmathresult}{\pgfmathresult}}% |
| 774 |
\let\pgfplots@diff@z=\pgfmathresult |
| 775 |
\pgfplotscoordmath{default}{op}{add}{{\pgfplots@len}{\pgfplots@diff@z}}% |
| 776 |
\let\pgfplots@len=\pgfmathresult |
| 777 |
\fi |
| 778 |
\pgfplotscoordmath{default}{op}{sqrt}{{\pgfplots@len}}% |
| 779 |
\pgfmath@smuggleone\pgfmathresult |
| 780 |
\endgroup |
| 781 |
}% |
| 782 |
|
| 783 |
% \pgfplotsplothandlertransformslopedattime{<time fraction>}{<start>}{<end>} |
| 784 |
% |
| 785 |
% Installs a PGF rotation matrix such that it fits the gradient of the |
| 786 |
% current plot segment between <start> and <end>. |
| 787 |
% |
| 788 |
% #1: a fraction such that 0.0 is <start> and 1.0 is <end> |
| 789 |
% #2: the <start> point (a macro containing the result of \pgfplotsplothandlerserializepointto) |
| 790 |
% #3: the <end> point (a macro containing the result of \pgfplotsplothandlerserializepointto) |
| 791 |
% |
| 792 |
\def\pgfplotsplothandlertransformslopedattime@default#1#2#3{% |
| 793 |
\pgf@process{% |
| 794 |
\pgfplotsplothandlerdeserializepointfrom{#2}% |
| 795 |
\pgfplotsaxisvisphasegetpoint |
| 796 |
}% |
| 797 |
\pgf@xa=\pgf@x% xb/yb = start point |
| 798 |
\pgf@ya=\pgf@y% |
| 799 |
\pgf@process{% |
| 800 |
\pgfplotsplothandlerdeserializepointfrom{#3}% |
| 801 |
\pgfplotsaxisvisphasegetpoint |
| 802 |
}% |
| 803 |
\advance\pgf@x by-\pgf@xa% |
| 804 |
\advance\pgf@y by-\pgf@ya% |
| 805 |
\ifpgfallowupsidedownattime% |
| 806 |
\else% |
| 807 |
\ifdim\pgf@x<0pt% |
| 808 |
\pgf@x=-\pgf@x% |
| 809 |
\pgf@y=-\pgf@y% |
| 810 |
\fi% |
| 811 |
\fi% |
| 812 |
\pgfpointnormalised{}% x/y = normalised vector |
| 813 |
\pgf@ya=-\pgf@y% |
| 814 |
\pgftransformcm% |
| 815 |
{\pgf@sys@tonumber{\pgf@x}}{\pgf@sys@tonumber{\pgf@y}}% |
| 816 |
{\pgf@sys@tonumber{\pgf@ya}}{\pgf@sys@tonumber{\pgf@x}}{\pgfpointorigin}% |
| 817 |
}% |
| 818 |
|
| 819 |
|
| 820 |
|
| 821 |
\pgfplotsresetplothandler |
| 822 |
|
| 823 |
% The following two methods constitutes implementations for |
| 824 |
% 'node[pos=<faction>]' which do not interpolate. They only snap to |
| 825 |
% the nearest coordinate. |
| 826 |
% |
| 827 |
% For example, \addplot[scatter] ... node[pos=0.5] {} should use a |
| 828 |
% unit distance and should not interpolate between scatter points. |
| 829 |
\def\pgfplotsplothandlersurveydifflen@snaptonearest#1#2{% |
| 830 |
% FIXME : this implies that #1 and #2 are "adjacent" in the |
| 831 |
% coordinate stream! |
| 832 |
\pgfplotscoordmath{default}{one}% |
| 833 |
}% |
| 834 |
\def\pgfplotsplothandlersurveypointattime@snaptonearest#1#2#3{% |
| 835 |
\pgfplotscoordmath{default}{parsenumber}{0.5}% |
| 836 |
\let\pgfplots@loc@TMPa=\pgfmathresult |
| 837 |
\pgfplotscoordmath{default}{parsenumber}{#1}% |
| 838 |
\pgfplotscoordmath{default}{if less than}{\pgfmathresult}{\pgfplots@loc@TMPa}{% |
| 839 |
\pgfplotsplothandlerdeserializepointfrom{#2}% |
| 840 |
}{% |
| 841 |
\pgfplotsplothandlerdeserializepointfrom{#3}% |
| 842 |
}% |
| 843 |
}% |
| 844 |
% ================================== |
| 845 |
|
| 846 |
% Defines |
| 847 |
% - a generic update limits routine, |
| 848 |
% \pgfplotsaxisupdatelimitsforcoordinate#1#2#3 |
| 849 |
% if #3 is empty, it will assume a 2d point, otherwise a 3d point |
| 850 |
% and the axis will be three dimensional as well. |
| 851 |
% During \addplot, this auto-detection will be disabled in favor of |
| 852 |
% the '\addplot3' versus' \addplot' syntax. |
| 853 |
% |
| 854 |
\def\pgfplots@prepare@axis@API{% |
| 855 |
\pgfplots@curplot@threedimtrue |
| 856 |
\pgfplots@prepare@axis@API@ |
| 857 |
\let\pgfplotsaxisupdatelimitsforcoordinatethreedim=\pgfplotsaxisupdatelimitsforcoordinate@ |
| 858 |
\let\pgfplotsaxisparsecoordinatethreedim=\pgfplotsaxisparsecoordinate@ |
| 859 |
% |
| 860 |
\pgfplots@curplot@threedimfalse |
| 861 |
\pgfplots@prepare@axis@API@ |
| 862 |
\let\pgfplotsaxisupdatelimitsforcoordinatetwodim=\pgfplotsaxisupdatelimitsforcoordinate@ |
| 863 |
\let\pgfplotsaxisparsecoordinatetwodim=\pgfplotsaxisparsecoordinate@ |
| 864 |
% |
| 865 |
\def\pgfplotsaxisupdatelimitsforcoordinate##1##2##3{% |
| 866 |
\pgfplots@ifempty{##3}{% |
| 867 |
\pgfplotsaxisupdatelimitsforcoordinatetwodim{##1}{##2}{}% |
| 868 |
}{% |
| 869 |
\global\pgfplots@threedimtrue |
| 870 |
\pgfplotsaxisupdatelimitsforcoordinatethreedim{##1}{##2}{##3}% |
| 871 |
}% |
| 872 |
}% |
| 873 |
\def\pgfplotsaxisparsecoordinate{% |
| 874 |
\ifx\pgfplots@current@point@z\pgfutil@empty |
| 875 |
\pgfplotsaxisparsecoordinatetwodim |
| 876 |
\else |
| 877 |
\global\pgfplots@threedimtrue |
| 878 |
\pgfplotsaxisparsecoordinatethreedim% |
| 879 |
\fi |
| 880 |
}% |
| 881 |
}% |
| 882 |
\def\pgfplots@prepare@axis@API@{% |
| 883 |
\begingroup |
| 884 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 885 |
\let\E=\noexpand |
| 886 |
% Setup Just-In-Time-Macro Compilation: |
| 887 |
% I compile a set of macros which is highly optimized for this |
| 888 |
% particular axis configuration. |
| 889 |
% |
| 890 |
% \pgfplotsaxisupdatelimitsforcoordinate |
| 891 |
% Updates the current x and y limits for point (#1,#2). |
| 892 |
% |
| 893 |
% To eliminate all those case distinctions, it is created with |
| 894 |
% 'edef' and a lot of '\noexpand' calls here: |
| 895 |
% |
| 896 |
% |
| 897 |
% The point coordinates are given in floating point format (FIXME) |
| 898 |
% |
| 899 |
% Please note that if user specified limits are given, automatic |
| 900 |
% limits are only applied to points which fall into the user specified |
| 901 |
% clipping region. |
| 902 |
% |
| 903 |
% PRECONDITIONS: |
| 904 |
% - the input coordinates have been parsed correctly (floating point |
| 905 |
% format for linear axis, log applied for logarithmic ones) |
| 906 |
% |
| 907 |
% Arguments: |
| 908 |
% #1,#2,#3 the x,y and z coordinate. z is ignored for 2d plots. |
| 909 |
\xdef\pgfplotsaxisupdatelimitsforcoordinate@##1##2##3{% |
| 910 |
%\E\tracingmacros=2\E\tracingcommands=2 |
| 911 |
%\E\pgfplots@message{Updating limits for (##1,##2) ...}% |
| 912 |
% |
| 913 |
% VIM SEARCH PATTERN: |
| 914 |
% [^E]\zs\\\ze[^E] |
| 915 |
% -> this finds '\' which is neither '\E' nor is it prefixed |
| 916 |
% by 'E'. |
| 917 |
% |
| 918 |
% |
| 919 |
% |
| 920 |
\E\pgfplots@update@limits@for@one@point@ISCLIPPEDfalse |
| 921 |
% check whether we need to clip limits: |
| 922 |
\ifpgfplots@clip@limits@x |
| 923 |
\ifpgfplots@autocompute@xmin |
| 924 |
\else |
| 925 |
\ifpgfplots@xislinear |
| 926 |
\E\pgfmathfloatlessthan@{##1}{\E\pgfplots@xmin}% |
| 927 |
\E\ifpgfmathfloatcomparison |
| 928 |
\E\pgfplots@update@limits@for@one@point@ISCLIPPEDtrue |
| 929 |
\E\fi |
| 930 |
\else |
| 931 |
\E\pgfplotsmathlessthan{##1}{\E\pgfplots@xmin}% |
| 932 |
\E\ifpgfmathfloatcomparison |
| 933 |
\E\pgfplots@update@limits@for@one@point@ISCLIPPEDtrue |
| 934 |
\E\fi |
| 935 |
\fi |
| 936 |
\fi |
| 937 |
\ifpgfplots@autocompute@xmax |
| 938 |
\else |
| 939 |
\ifpgfplots@xislinear |
| 940 |
\E\pgfmathfloatlessthan@{\E\pgfplots@xmax}{##1}% |
| 941 |
\E\ifpgfmathfloatcomparison |
| 942 |
\E\pgfplots@update@limits@for@one@point@ISCLIPPEDtrue |
| 943 |
\E\fi |
| 944 |
\else |
| 945 |
\E\pgfplotsmathlessthan{\E\pgfplots@xmax}{##1}% |
| 946 |
\E\ifpgfmathfloatcomparison |
| 947 |
\E\pgfplots@update@limits@for@one@point@ISCLIPPEDtrue |
| 948 |
\E\fi |
| 949 |
\fi |
| 950 |
\fi |
| 951 |
\fi |
| 952 |
\ifpgfplots@clip@limits@y |
| 953 |
\ifpgfplots@autocompute@ymin |
| 954 |
\else |
| 955 |
\ifpgfplots@yislinear |
| 956 |
\E\pgfmathfloatlessthan@{##2}{\E\pgfplots@ymin}% |
| 957 |
\E\ifpgfmathfloatcomparison |
| 958 |
\E\pgfplots@update@limits@for@one@point@ISCLIPPEDtrue |
| 959 |
\E\fi |
| 960 |
\else |
| 961 |
\E\pgfplotsmathlessthan{##2}{\E\pgfplots@ymin}% |
| 962 |
\E\ifpgfmathfloatcomparison |
| 963 |
\E\pgfplots@update@limits@for@one@point@ISCLIPPEDtrue |
| 964 |
\E\fi |
| 965 |
\fi |
| 966 |
\fi |
| 967 |
\ifpgfplots@autocompute@ymax |
| 968 |
\else |
| 969 |
\ifpgfplots@yislinear |
| 970 |
\E\pgfmathfloatlessthan@{\E\pgfplots@ymax}{##2}% |
| 971 |
\E\ifpgfmathfloatcomparison |
| 972 |
\E\pgfplots@update@limits@for@one@point@ISCLIPPEDtrue |
| 973 |
\E\fi |
| 974 |
\else |
| 975 |
\E\pgfplotsmathlessthan{\E\pgfplots@ymax}{##2}% |
| 976 |
\E\ifpgfmathfloatcomparison |
| 977 |
\E\pgfplots@update@limits@for@one@point@ISCLIPPEDtrue |
| 978 |
\E\fi |
| 979 |
\fi |
| 980 |
\fi |
| 981 |
\fi |
| 982 |
\ifpgfplots@clip@limits@z |
| 983 |
\ifpgfplots@curplot@threedim |
| 984 |
\ifpgfplots@autocompute@zmin |
| 985 |
\else |
| 986 |
\ifpgfplots@zislinear |
| 987 |
\E\pgfmathfloatlessthan@{##3}{\E\pgfplots@zmin}% |
| 988 |
\E\ifpgfmathfloatcomparison |
| 989 |
\E\pgfplots@update@limits@for@one@point@ISCLIPPEDtrue |
| 990 |
\E\fi |
| 991 |
\else |
| 992 |
\E\pgfplotsmathlessthan{##3}{\E\pgfplots@zmin}% |
| 993 |
\E\ifpgfmathfloatcomparison |
| 994 |
\E\pgfplots@update@limits@for@one@point@ISCLIPPEDtrue |
| 995 |
\E\fi |
| 996 |
\fi |
| 997 |
\fi |
| 998 |
\ifpgfplots@autocompute@zmax |
| 999 |
\else |
| 1000 |
\ifpgfplots@zislinear |
| 1001 |
\E\pgfmathfloatlessthan@{\E\pgfplots@zmax}{##3}% |
| 1002 |
\E\ifpgfmathfloatcomparison |
| 1003 |
\E\pgfplots@update@limits@for@one@point@ISCLIPPEDtrue |
| 1004 |
\E\fi |
| 1005 |
\else |
| 1006 |
\E\pgfplotsmathlessthan{\E\pgfplots@zmax}{##3}% |
| 1007 |
\E\ifpgfmathfloatcomparison |
| 1008 |
\E\pgfplots@update@limits@for@one@point@ISCLIPPEDtrue |
| 1009 |
\E\fi |
| 1010 |
\fi |
| 1011 |
\fi |
| 1012 |
\fi |
| 1013 |
\fi |
| 1014 |
% |
| 1015 |
% |
| 1016 |
% |
| 1017 |
% Update limits: |
| 1018 |
\E\ifpgfplots@update@limits@for@one@point@ISCLIPPED |
| 1019 |
\E\else |
| 1020 |
\ifpgfplots@autocompute@xmin |
| 1021 |
\ifpgfplots@xislinear |
| 1022 |
\E\pgfplotsmathfloatmin{\E\pgfplots@xmin}{##1}% |
| 1023 |
\E\global\E\let\E\pgfplots@xmin=\E\pgfmathresult |
| 1024 |
\else |
| 1025 |
\E\pgfplotsmathmin{\E\pgfplots@xmin}{##1}% |
| 1026 |
\E\global\E\let\E\pgfplots@xmin=\E\pgfmathresult |
| 1027 |
\fi |
| 1028 |
\fi |
| 1029 |
\ifpgfplots@autocompute@xmax |
| 1030 |
\ifpgfplots@xislinear |
| 1031 |
\E\pgfplotsmathfloatmax{\E\pgfplots@xmax}{##1}% |
| 1032 |
\E\global\E\let\E\pgfplots@xmax=\E\pgfmathresult |
| 1033 |
\else |
| 1034 |
\E\pgfplotsmathmax{\E\pgfplots@xmax}{##1}% |
| 1035 |
\E\global\E\let\E\pgfplots@xmax=\E\pgfmathresult |
| 1036 |
\fi |
| 1037 |
\fi |
| 1038 |
\ifpgfplots@autocompute@ymin |
| 1039 |
\ifpgfplots@yislinear |
| 1040 |
\E\pgfplotsmathfloatmin{\E\pgfplots@ymin}{##2}% |
| 1041 |
\E\global\E\let\E\pgfplots@ymin=\E\pgfmathresult |
| 1042 |
\else |
| 1043 |
\E\pgfplotsmathmin{\E\pgfplots@ymin}{##2}% |
| 1044 |
\E\global\E\let\E\pgfplots@ymin=\E\pgfmathresult |
| 1045 |
\fi |
| 1046 |
\fi |
| 1047 |
\ifpgfplots@autocompute@ymax |
| 1048 |
\ifpgfplots@yislinear |
| 1049 |
\E\pgfplotsmathfloatmax{\E\pgfplots@ymax}{##2}% |
| 1050 |
\E\global\E\let\E\pgfplots@ymax=\E\pgfmathresult |
| 1051 |
\else |
| 1052 |
\E\pgfplotsmathmax{\E\pgfplots@ymax}{##2}% |
| 1053 |
\E\global\E\let\E\pgfplots@ymax=\E\pgfmathresult |
| 1054 |
\fi |
| 1055 |
\fi |
| 1056 |
\ifpgfplots@curplot@threedim |
| 1057 |
\ifpgfplots@autocompute@zmin |
| 1058 |
\ifpgfplots@zislinear |
| 1059 |
\E\pgfplotsmathfloatmin{\E\pgfplots@zmin}{##3}% |
| 1060 |
\E\global\E\let\E\pgfplots@zmin=\E\pgfmathresult |
| 1061 |
\else |
| 1062 |
\E\pgfplotsmathmin{\E\pgfplots@zmin}{##3}% |
| 1063 |
\E\global\E\let\E\pgfplots@zmin=\E\pgfmathresult |
| 1064 |
\fi |
| 1065 |
\fi |
| 1066 |
\ifpgfplots@autocompute@zmax |
| 1067 |
\ifpgfplots@zislinear |
| 1068 |
\E\pgfplotsmathfloatmax{\E\pgfplots@zmax}{##3}% |
| 1069 |
\E\global\E\let\E\pgfplots@zmax=\E\pgfmathresult |
| 1070 |
\else |
| 1071 |
\E\pgfplotsmathmax{\E\pgfplots@zmax}{##3}% |
| 1072 |
\E\global\E\let\E\pgfplots@zmax=\E\pgfmathresult |
| 1073 |
\fi |
| 1074 |
\fi |
| 1075 |
\fi |
| 1076 |
\E\fi |
| 1077 |
% |
| 1078 |
% Compute data range: |
| 1079 |
\ifpgfplots@autocompute@all@limits |
| 1080 |
% the data range will be acquired simply from the axis |
| 1081 |
% range, see below! |
| 1082 |
\else |
| 1083 |
% Attention: it is only done for linear axis! |
| 1084 |
\ifpgfplots@xislinear |
| 1085 |
\E\pgfplotsmathfloatmin{\E\pgfplots@data@xmin}{##1}% |
| 1086 |
\E\global\E\let\E\pgfplots@data@xmin=\E\pgfmathresult |
| 1087 |
\E\pgfplotsmathfloatmax{\E\pgfplots@data@xmax}{##1}% |
| 1088 |
\E\global\E\let\E\pgfplots@data@xmax=\E\pgfmathresult |
| 1089 |
\fi |
| 1090 |
\ifpgfplots@yislinear |
| 1091 |
\E\pgfplotsmathfloatmin{\E\pgfplots@data@ymin}{##2}% |
| 1092 |
\E\global\E\let\E\pgfplots@data@ymin=\E\pgfmathresult |
| 1093 |
\E\pgfplotsmathfloatmax{\E\pgfplots@data@ymax}{##2}% |
| 1094 |
\E\global\E\let\E\pgfplots@data@ymax=\E\pgfmathresult |
| 1095 |
\fi |
| 1096 |
\ifpgfplots@curplot@threedim |
| 1097 |
\ifpgfplots@zislinear |
| 1098 |
\E\pgfplotsmathfloatmin{\E\pgfplots@data@zmin}{##3}% |
| 1099 |
\E\global\E\let\E\pgfplots@data@zmin=\E\pgfmathresult |
| 1100 |
\E\pgfplotsmathfloatmax{\E\pgfplots@data@zmax}{##3}% |
| 1101 |
\E\global\E\let\E\pgfplots@data@zmax=\E\pgfmathresult |
| 1102 |
\fi |
| 1103 |
\fi |
| 1104 |
\fi |
| 1105 |
%\E\pgfplots@message{Updated limits: (\E\pgfplots@xmin,\E\pgfplots@ymin) rectangle (\E\pgfplots@xmax,\E\pgfplots@ymax).}% |
| 1106 |
% |
| 1107 |
%\E\tracingmacros=0\E\tracingcommands=0 |
| 1108 |
}% |
| 1109 |
% |
| 1110 |
% A routine which parses a coordinate. |
| 1111 |
% Here, 'coordinate' means (x,y) for a two dimensional plot and |
| 1112 |
% '(x,y,z)' for a three dimensional one. |
| 1113 |
% |
| 1114 |
% The preparation consists of |
| 1115 |
% - filtering. |
| 1116 |
% - coordinate parsing and high level transformations. |
| 1117 |
% - logs. |
| 1118 |
% |
| 1119 |
% It might happen that \pgfplotsaxisparsecoordinate is called |
| 1120 |
% multiple times for a single data "point" (for example, a quiver |
| 1121 |
% point might call it for the point where the vector starts and |
| 1122 |
% where the vector ends). |
| 1123 |
% |
| 1124 |
% @PRECONDITION |
| 1125 |
% - the plot's survey phase is running (has already been started) |
| 1126 |
% - \pgfplots@current@point@[xyz] contains the coordinates of the |
| 1127 |
% point. I assume they are unparsed. |
| 1128 |
% |
| 1129 |
% |
| 1130 |
% @POSTCONDITION |
| 1131 |
% - the axis' state will be updated. |
| 1132 |
% - the \pgfplots@current@point@[xyz] macros will contain parsed data. |
| 1133 |
% - \ifpgfplotsaxisparsecoordinateok will be true if and only |
| 1134 |
% if the data point has not been filtered away. If it has been |
| 1135 |
% filtered away, \pgfplots@current@point@[xyz] will be empty. |
| 1136 |
% - \pgfplots@current@point@[xyz]@unfiltered contain unparsed |
| 1137 |
% data. |
| 1138 |
% |
| 1139 |
% @see \pgfplotsaxispreparecoordinate |
| 1140 |
% @see \pgfplotsaxisdatapointsurveyed |
| 1141 |
\xdef\pgfplotsaxisparsecoordinate@{% |
| 1142 |
% These things are necessary for error bars and are available |
| 1143 |
% as public results in math parser invocations (for meta and |
| 1144 |
% filters) |
| 1145 |
\E\let\E\pgfplots@current@point@x@unfiltered=\E\pgfplots@current@point@x |
| 1146 |
\E\let\E\pgfplots@current@point@y@unfiltered=\E\pgfplots@current@point@y |
| 1147 |
\E\let\E\pgfplots@current@point@z@unfiltered=\E\pgfplots@current@point@z |
| 1148 |
\E\def\E\pgfplots@unbounded@dir{}% |
| 1149 |
% |
| 1150 |
\E\pgfplots@invoke@prefilter |
| 1151 |
% |
| 1152 |
\E\expandafter\E\pgfplots@prepare@xcoord\E\expandafter{\E\pgfplots@current@point@x}% |
| 1153 |
\E\expandafter\E\pgfplots@invoke@filter\E\expandafter{\E\pgfmathresult}{x}% |
| 1154 |
\E\let\E\pgfplots@current@point@x=\E\pgfmathresult |
| 1155 |
% |
| 1156 |
\E\expandafter\E\pgfplots@prepare@ycoord\E\expandafter{\E\pgfplots@current@point@y}% |
| 1157 |
\E\expandafter\E\pgfplots@invoke@filter\E\expandafter{\E\pgfplots@current@point@y}{y}% |
| 1158 |
\E\let\E\pgfplots@current@point@y=\E\pgfmathresult |
| 1159 |
% |
| 1160 |
\ifpgfplots@curplot@threedim |
| 1161 |
\E\expandafter\E\pgfplots@prepare@zcoord\E\expandafter{\E\pgfplots@current@point@z}% |
| 1162 |
\E\expandafter\E\pgfplots@invoke@filter\E\expandafter{\E\pgfplots@current@point@z}{z}% |
| 1163 |
\E\let\E\pgfplots@current@point@z=\E\pgfmathresult |
| 1164 |
\fi |
| 1165 |
% |
| 1166 |
\E\pgfplots@invoke@filter@xyz |
| 1167 |
% |
| 1168 |
\E\ifx\E\pgfplots@current@point@x\E\pgfutil@empty |
| 1169 |
\E\else |
| 1170 |
% parse for numbers. Note that this might cause |
| 1171 |
% unnecessary overhead of logs (which are already |
| 1172 |
% normalized unless someone provided filters). But do it |
| 1173 |
% anyway to ensure that filters produce valid output. |
| 1174 |
\E\pgfplotscoordmath{x}{parsenumber}{\E\pgfplots@current@point@x}% |
| 1175 |
\E\let\E\pgfplots@current@point@x=\E\pgfmathresult |
| 1176 |
\E\pgfplotscoordmath{x}{if is bounded}{\E\pgfplots@current@point@x}% |
| 1177 |
{}% |
| 1178 |
{% this clears nan, inf and -inf points. |
| 1179 |
\E\let\E\pgfplots@current@point@x=\E\pgfutil@empty |
| 1180 |
\E\def\E\pgfplots@unbounded@dir{x}% |
| 1181 |
}% |
| 1182 |
\E\fi |
| 1183 |
% |
| 1184 |
\E\ifx\E\pgfplots@current@point@y\E\pgfutil@empty |
| 1185 |
\E\else |
| 1186 |
\E\pgfplotscoordmath{y}{parsenumber}{\E\pgfplots@current@point@y}% |
| 1187 |
\E\let\E\pgfplots@current@point@y=\E\pgfmathresult |
| 1188 |
\E\pgfplotscoordmath{y}{if is bounded}{\E\pgfplots@current@point@y}% |
| 1189 |
{}% |
| 1190 |
{% this clears nan, inf and -inf points. |
| 1191 |
\E\let\E\pgfplots@current@point@y=\E\pgfutil@empty |
| 1192 |
\E\def\E\pgfplots@unbounded@dir{y}% |
| 1193 |
}% |
| 1194 |
\E\fi |
| 1195 |
% |
| 1196 |
\ifpgfplots@curplot@threedim |
| 1197 |
% |
| 1198 |
\E\ifx\E\pgfplots@current@point@z\E\pgfutil@empty |
| 1199 |
\E\else |
| 1200 |
\E\pgfplotscoordmath{z}{parsenumber}{\E\pgfplots@current@point@z}% |
| 1201 |
\E\let\E\pgfplots@current@point@z=\E\pgfmathresult |
| 1202 |
\E\pgfplotscoordmath{z}{if is bounded}{\E\pgfplots@current@point@z}% |
| 1203 |
{}% |
| 1204 |
{% this clears nan, inf and -inf points. |
| 1205 |
\E\let\E\pgfplots@current@point@z=\E\pgfutil@empty |
| 1206 |
\E\def\E\pgfplots@unbounded@dir{z}% |
| 1207 |
}% |
| 1208 |
\E\fi |
| 1209 |
\fi |
| 1210 |
% |
| 1211 |
% check if coordinates are bounded: |
| 1212 |
\E\pgfplotsaxisparsecoordinateoktrue |
| 1213 |
\E\ifx\E\pgfplots@current@point@x\E\pgfutil@empty |
| 1214 |
\E\pgfplotsaxisparsecoordinateokfalse |
| 1215 |
\E\else |
| 1216 |
\E\ifx\E\pgfplots@current@point@y\E\pgfutil@empty |
| 1217 |
\E\pgfplotsaxisparsecoordinateokfalse |
| 1218 |
\E\else |
| 1219 |
\ifpgfplots@curplot@threedim |
| 1220 |
\E\ifx\E\pgfplots@current@point@z\E\pgfutil@empty |
| 1221 |
\E\pgfplotsaxisparsecoordinateokfalse |
| 1222 |
\E\fi |
| 1223 |
\fi |
| 1224 |
\E\fi |
| 1225 |
\E\fi |
| 1226 |
% |
| 1227 |
}% |
| 1228 |
% |
| 1229 |
\endgroup |
| 1230 |
}% |
| 1231 |
|
| 1232 |
% ================================== |
| 1233 |
% The quiver plot handler. |
| 1234 |
% It draws a lot of arrows. |
| 1235 |
% Its input is (x_i,y_i); (u_i,v_i) for data point i and it draws a |
| 1236 |
% vector in direction (u_i,v_i) starting from (x_i,y_i) . |
| 1237 |
% It also supports 3D arrows (involving z_i and w_i). |
| 1238 |
|
| 1239 |
\newif\ifpgfplots@quiver@usetikz |
| 1240 |
\newif\ifpgfplots@quiver@updatelimits |
| 1241 |
|
| 1242 |
\pgfplotsset{ |
| 1243 |
% The 'quiver' plot handler for two- and three dimensional plots. |
| 1244 |
% |
| 1245 |
% User Interface: |
| 1246 |
% use /pgfplots/quiver to enable the plot handler. |
| 1247 |
% Then, provide `quiver/u value' or `quiver/u' to |
| 1248 |
% tell where to find the 'x' coordinates of the vectors, and similarly |
| 1249 |
% for 'v' and 'w' instead of 'u'. |
| 1250 |
quiver/.code={% |
| 1251 |
\let\tikz@plot@handler=\pgfplotsplothandlerquiver |
| 1252 |
\pgfqkeys{/pgfplots/quiver}{quiver legend,#1}% |
| 1253 |
},% |
| 1254 |
quiver/u value*/.initial=0, |
| 1255 |
quiver/v value*/.initial=0, |
| 1256 |
quiver/w value*/.initial=0, |
| 1257 |
quiver/u value is expr/.initial=0, |
| 1258 |
quiver/v value is expr/.initial=0, |
| 1259 |
quiver/w value is expr/.initial=0, |
| 1260 |
quiver/quiver legend/.style={ |
| 1261 |
/pgfplots/legend image code/.code={% |
| 1262 |
\draw[x=0.6cm,y=0cm,z=0pt,##1, |
| 1263 |
/pgfplots/quiver/before arrow/.add code={}{ |
| 1264 |
% quiver is a pgfplots-specific plot-handler. We need to |
| 1265 |
% fix the additional input data somehow. |
| 1266 |
% |
| 1267 |
% this is an *absolute* coordinate, interpreted |
| 1268 |
% relative to 'x', 'y', 'z' |
| 1269 |
\def\pgfplots@quiver@u{1}% |
| 1270 |
\def\pgfplots@quiver@v{1}% |
| 1271 |
\def\pgfplots@quiver@w{1}% |
| 1272 |
},% |
| 1273 |
] |
| 1274 |
plot coordinates { |
| 1275 |
(0cm,0cm) |
| 1276 |
};% |
| 1277 |
}% |
| 1278 |
}, |
| 1279 |
quiver/u filter/.code=, |
| 1280 |
quiver/v filter/.code=, |
| 1281 |
quiver/w filter/.code=, |
| 1282 |
quiver/u filter/.expression/.code=\pgfplots@install@filter@expression{quiver/u filter}{#1}, |
| 1283 |
quiver/v filter/.expression/.code=\pgfplots@install@filter@expression{quiver/v filter}{#1}, |
| 1284 |
quiver/w filter/.expression/.code=\pgfplots@install@filter@expression{quiver/w filter}{#1}, |
| 1285 |
quiver/u value/.code =\pgfplots@set@source@for{quiver/u}{#1}{0},% |
| 1286 |
quiver/u/.code =\pgfplots@set@source@for{quiver/u}{#1}{1},% |
| 1287 |
quiver/v value/.code =\pgfplots@set@source@for{quiver/v}{#1}{0},% |
| 1288 |
quiver/v/.code =\pgfplots@set@source@for{quiver/v}{#1}{1},% |
| 1289 |
quiver/w value/.code =\pgfplots@set@source@for{quiver/w}{#1}{0},% |
| 1290 |
quiver/w/.code =\pgfplots@set@source@for{quiver/w}{#1}{1},% |
| 1291 |
quiver/before arrow/.code=, |
| 1292 |
quiver/after arrow/.code=, |
| 1293 |
quiver/every arrow/.style={}, |
| 1294 |
quiver/arrow color/.initial=, |
| 1295 |
quiver/scale arrows/.initial=1, |
| 1296 |
quiver/update limits/.is if=pgfplots@quiver@updatelimits, |
| 1297 |
quiver/update limits=true, |
| 1298 |
quiver/colored/.code={% |
| 1299 |
\def\pgfplots@loc@TMPa{#1}% |
| 1300 |
\ifx\pgfplots@loc@TMPa\pgfutil@empty |
| 1301 |
\else |
| 1302 |
\pgfkeyslet{/pgfplots/quiver/arrow color}\pgfplots@loc@TMPa |
| 1303 |
\pgfkeysalso{/pgfplots/set point meta if empty=f(x)}% |
| 1304 |
\fi |
| 1305 |
},% |
| 1306 |
quiver/colored/.default=mapped color, |
| 1307 |
}% |
| 1308 |
|
| 1309 |
\def\pgfplots@set@source@for#1#2#3{% |
| 1310 |
\pgfkeyssetvalue{/pgfplots/#1 value*}{#2}% |
| 1311 |
\pgfkeyssetvalue{/pgfplots/#1 is expr}{#3}% |
| 1312 |
}% |
| 1313 |
% To be used to create a simple parser for keys initialised by |
| 1314 |
% \pgfplots@set@source@for: |
| 1315 |
% |
| 1316 |
% #1: the key path (relative to /pgfplots/) of the data. |
| 1317 |
% Can be empty in which case /pgfplots/#2 is used to access data. |
| 1318 |
% #2: the key name of the data |
| 1319 |
% #3: a macro name which be will defined to be a parser for the data. |
| 1320 |
% |
| 1321 |
% The parser will check whether the '#2 is expr' key is set. |
| 1322 |
% Furthermore, it defines /data point/#2 to be the result. |
| 1323 |
% |
| 1324 |
% Example: |
| 1325 |
% \pgfplots@set@source@for{hist/data}{...} |
| 1326 |
% |
| 1327 |
% -> |
| 1328 |
% \pgfplots@prepare@source@parser@for{hist/}{data}\parser |
| 1329 |
% |
| 1330 |
% then, invoking \parser |
| 1331 |
% will define \pgfmathresult to be the argument provided to |
| 1332 |
% \pgfplots@set@source@for. |
| 1333 |
\def\pgfplots@prepare@source@parser@for#1#2#3{% |
| 1334 |
\pgfkeyslet{/data point/#1#2}\pgfutil@empty% |
| 1335 |
% |
| 1336 |
\pgfkeysgetvalue{/pgfplots/#1#2 value*}\pgfplots@loc@TMPa |
| 1337 |
\ifx\pgfplots@loc@TMPa\pgfutil@empty |
| 1338 |
% assume the '/data point/#1#2' is set by some input |
| 1339 |
% routine. |
| 1340 |
% Invoke math parser in this case. |
| 1341 |
\pgfkeyssetvalue{/pgfplots/#1#2 is expr}{1}% |
| 1342 |
\else |
| 1343 |
\pgfkeyslet{/data point/#1#2}\pgfplots@loc@TMPa |
| 1344 |
\fi |
| 1345 |
\def#3{% |
| 1346 |
\edef\pgfmathresult{\pgfkeysvalueof{/data point/#1#2}}% |
| 1347 |
%\message{parse coordinate #1#2 (\pgfmathresult) ...^^J}% |
| 1348 |
}% |
| 1349 |
% |
| 1350 |
% |
| 1351 |
\pgfkeysifdefined{/pgfplots/#1#2 coord trafo/.@cmd}{% |
| 1352 |
\pgfkeysgetvalue{/pgfplots/#1#2 coord trafo/.@cmd}\pgfplots@loc@TMPa |
| 1353 |
\ifx\pgfplots@loc@TMPa\pgfplots@empty@command@key |
| 1354 |
\else |
| 1355 |
\t@pgfplots@toka=\expandafter{#3}% |
| 1356 |
\t@pgfplots@tokb={% |
| 1357 |
\def\pgfplots@loc@TMPa{\pgfkeysvalueof{/pgfplots/#1#2 coord trafo/.@cmd}}% |
| 1358 |
\expandafter\pgfplots@loc@TMPa\expandafter{\pgfmathresult}\pgfeov% |
| 1359 |
}% |
| 1360 |
\t@pgfplots@tokc={% |
| 1361 |
\ifx\pgfmathresult\pgfutil@empty |
| 1362 |
\else |
| 1363 |
\pgfmathfloatparsenumber{\pgfmathresult}% |
| 1364 |
\fi |
| 1365 |
}% |
| 1366 |
\edef#3{% |
| 1367 |
\the\t@pgfplots@toka |
| 1368 |
\the\t@pgfplots@tokb |
| 1369 |
\the\t@pgfplots@tokc |
| 1370 |
}% |
| 1371 |
\fi |
| 1372 |
}{}% |
| 1373 |
% |
| 1374 |
\t@pgfplots@toka=\expandafter{#3}% |
| 1375 |
\if1\pgfkeysvalueof{/pgfplots/#1#2 is expr}% |
| 1376 |
\t@pgfplots@tokc={% |
| 1377 |
\ifx\pgfmathresult\pgfutil@empty |
| 1378 |
\else |
| 1379 |
\pgfmathparse{\pgfmathresult}% |
| 1380 |
\fi |
| 1381 |
}% |
| 1382 |
\else |
| 1383 |
\t@pgfplots@tokc={% |
| 1384 |
\ifx\pgfmathresult\pgfutil@empty |
| 1385 |
\else |
| 1386 |
\pgfmathfloatparsenumber{\pgfmathresult}% |
| 1387 |
\fi |
| 1388 |
}% |
| 1389 |
\fi |
| 1390 |
\edef#3{% |
| 1391 |
\the\t@pgfplots@toka |
| 1392 |
\the\t@pgfplots@tokc |
| 1393 |
}% |
| 1394 |
% |
| 1395 |
\pgfkeysgetvalue{/pgfplots/#1#2 filter/.@cmd}\pgfplots@loc@TMPa |
| 1396 |
\ifx\pgfplots@loc@TMPa\pgfplots@empty@command@key |
| 1397 |
\else |
| 1398 |
\t@pgfplots@toka=\expandafter{#3}% |
| 1399 |
\t@pgfplots@tokb={% |
| 1400 |
\def\pgfplots@loc@TMPa{\pgfkeysvalueof{/pgfplots/#1#2 filter/.@cmd}}% |
| 1401 |
\expandafter\pgfplots@loc@TMPa\expandafter{\pgfmathresult}\pgfeov% |
| 1402 |
}% |
| 1403 |
\t@pgfplots@tokc={% |
| 1404 |
\ifx\pgfmathresult\pgfutil@empty |
| 1405 |
\else |
| 1406 |
\pgfmathfloatparsenumber{\pgfmathresult}% |
| 1407 |
\fi |
| 1408 |
}% |
| 1409 |
\edef#3{% |
| 1410 |
\the\t@pgfplots@toka |
| 1411 |
\the\t@pgfplots@tokb |
| 1412 |
\the\t@pgfplots@tokc |
| 1413 |
}% |
| 1414 |
\fi |
| 1415 |
% |
| 1416 |
\iftrue |
| 1417 |
\t@pgfplots@toka=\expandafter{#3}% |
| 1418 |
\t@pgfplots@tokc={% |
| 1419 |
%\message{parse coordinate (#1#2) = \pgfmathresult.^^J}% |
| 1420 |
}% |
| 1421 |
\edef#3{% |
| 1422 |
\the\t@pgfplots@toka |
| 1423 |
\the\t@pgfplots@tokc |
| 1424 |
}% |
| 1425 |
\fi |
| 1426 |
}% |
| 1427 |
|
| 1428 |
% Invokes /pgfplots/#1 coord inv trafo on \pgfmathresult if that key |
| 1429 |
% exists. |
| 1430 |
% #1 the argument is in float (will become the 'default' coordmath |
| 1431 |
% eventually). |
| 1432 |
% |
| 1433 |
% On output, it should either '#1' if there was no coord inv trafo or |
| 1434 |
% the result of the trafo. |
| 1435 |
\def\pgfplots@coord@trafo@inv@for#1{% |
| 1436 |
\def\pgfplots@loc@TMPb{/pgfplots/#1 coord inv trafo/.@cmd}% |
| 1437 |
\pgfkeysifdefined{\pgfplots@loc@TMPb}{% |
| 1438 |
\pgfkeysgetvalue{\pgfplots@loc@TMPb}\pgfplots@loc@TMPa |
| 1439 |
\ifx\pgfplots@loc@TMPa\pgfplots@empty@command@key |
| 1440 |
\else |
| 1441 |
\pgfmathfloattofixed{\pgfmathresult}% |
| 1442 |
\expandafter\pgfplots@loc@TMPa\expandafter{\pgfmathresult}\pgfeov |
| 1443 |
\fi |
| 1444 |
}{}% |
| 1445 |
} |
| 1446 |
% Like \pgfplots@coord@trafo@inv@for, but for the normal trafo |
| 1447 |
% direction |
| 1448 |
\def\pgfplots@coord@trafo@for#1{% |
| 1449 |
\def\pgfplots@loc@TMPb{/pgfplots/#1 coord trafo/.@cmd}% |
| 1450 |
\pgfkeysifdefined{\pgfplots@loc@TMPb}{% |
| 1451 |
\pgfkeysgetvalue{\pgfplots@loc@TMPb}\pgfplots@loc@TMPa |
| 1452 |
\ifx\pgfplots@loc@TMPa\pgfplots@empty@command@key |
| 1453 |
\else |
| 1454 |
\expandafter\pgfplots@loc@TMPa\expandafter{\pgfmathresult}\pgfeov |
| 1455 |
\fi |
| 1456 |
}{}% |
| 1457 |
} |
| 1458 |
\def\pgfplotsplothandlerquiver{% |
| 1459 |
\pgfplotsresetplothandler |
| 1460 |
\let\pgf@plotstreamstart=\pgfplotsplothandlervisbegin@quiver |
| 1461 |
\let\pgfplotsplothandlersurveystart=\pgfplotsplothandlersurveystart@quiver |
| 1462 |
\let\pgfplotsplothandlersurveypoint=\pgfplotsplothandlersurveypoint@quiver |
| 1463 |
\let\pgfplotsplothandlerserializepointto=\pgfplotsplothandlerserializepointto@quiver |
| 1464 |
\let\pgfplotsplothandlerdeserializepointfrom=\pgfplotsplothandlerdeserializepointfrom@quiver |
| 1465 |
\let\pgfplotsplothandlerpointtokeys=\pgfplotsplothandlerpointtokeys@quiver |
| 1466 |
\let\pgfplotsplothandlerquiver@vis@hook=\pgfutil@empty |
| 1467 |
\def\pgfplotsplothandlername{quiver}% |
| 1468 |
% |
| 1469 |
\ifpgfplots@xislinear \else \pgfplotsplothandlerquivererror \fi |
| 1470 |
\ifpgfplots@yislinear \else \pgfplotsplothandlerquivererror\fi |
| 1471 |
\pgfplotsifcurplotthreedim{% |
| 1472 |
\ifpgfplots@zislinear \else \pgfplotsplothandlerquivererror \fi |
| 1473 |
}{}% |
| 1474 |
}% |
| 1475 |
\def\pgfplotsplothandlerquivererror{\pgfplots@error{Sorry, quiver plots for logarithmic axes are not yet implemented. In fact, the implementation does something -- but it will probably change in future releases. Contact the mailing list if you have questions}}% |
| 1476 |
|
| 1477 |
\def\pgfplotsplothandlersurveystart@quiver{% |
| 1478 |
\pgfkeysgetvalue{/pgfplots/quiver/scale arrows}\pgfplots@quiver@scale |
| 1479 |
\ifx\pgfplots@quiver@scale\pgfutil@empty |
| 1480 |
\else |
| 1481 |
\def\pgfplots@loc@TMPa{1}% |
| 1482 |
\ifx\pgfplots@loc@TMPa\pgfplots@quiver@scale |
| 1483 |
\let\pgfplots@quiver@scale=\pgfutil@empty |
| 1484 |
\else |
| 1485 |
\pgfmathparse{\pgfplots@quiver@scale}% |
| 1486 |
\pgfmathfloatparsenumber\pgfplots@quiver@scale |
| 1487 |
\let\pgfplots@quiver@scale=\pgfmathresult |
| 1488 |
\fi |
| 1489 |
\fi |
| 1490 |
% |
| 1491 |
\pgfplots@prepare@source@parser@for@quiver u\pgfplots@quiver@prepare@u% |
| 1492 |
\pgfplots@prepare@source@parser@for@quiver v\pgfplots@quiver@prepare@v% |
| 1493 |
\pgfplots@prepare@source@parser@for@quiver w\pgfplots@quiver@prepare@w% |
| 1494 |
}% |
| 1495 |
|
| 1496 |
\def\pgfplots@prepare@source@parser@for@quiver#1#2{% |
| 1497 |
\pgfplots@prepare@source@parser@for{quiver/}{#1}{#2}% |
| 1498 |
\t@pgfplots@toka=\expandafter{#2}% |
| 1499 |
\t@pgfplots@tokb=\expandafter{\csname pgfplots@quiver@#1\endcsname}% |
| 1500 |
\edef#2{% |
| 1501 |
\the\t@pgfplots@toka |
| 1502 |
\noexpand\let\the\t@pgfplots@tokb=\noexpand\pgfmathresult |
| 1503 |
\ifx\pgfplots@quiver@scale\pgfutil@empty |
| 1504 |
\else |
| 1505 |
\noexpand\pgfmathfloatmultiply@{\pgfplots@quiver@scale}{\the\t@pgfplots@tokb}% |
| 1506 |
\noexpand\let\the\t@pgfplots@tokb=\noexpand\pgfmathresult |
| 1507 |
\fi |
| 1508 |
}% |
| 1509 |
}% |
| 1510 |
|
| 1511 |
\def\pgfplotsplothandlersurveypoint@quiver{% |
| 1512 |
\pgfplots@quiver@prepare@u |
| 1513 |
\pgfplots@quiver@prepare@v |
| 1514 |
\pgfplotsifcurplotthreedim{% |
| 1515 |
\pgfplots@quiver@prepare@w |
| 1516 |
}{% |
| 1517 |
\let\pgfplots@quiver@w=\pgfutil@empty |
| 1518 |
}% |
| 1519 |
\pgfplotsaxisparsecoordinate |
| 1520 |
\pgfplotsaxispreparecoordinate |
| 1521 |
\ifpgfplotsaxisparsecoordinateok |
| 1522 |
\pgfplotsaxisupdatelimitsforcoordinate\pgfplots@current@point@x\pgfplots@current@point@y\pgfplots@current@point@z |
| 1523 |
% |
| 1524 |
\pgfmathadd@{\pgfplots@quiver@u}{\pgfplots@current@point@x}% |
| 1525 |
\let\pgfplots@quiver@u=\pgfmathresult |
| 1526 |
\pgfmathadd@{\pgfplots@quiver@v}{\pgfplots@current@point@y}% |
| 1527 |
\let\pgfplots@quiver@v=\pgfmathresult |
| 1528 |
\pgfplotsifcurplotthreedim{% |
| 1529 |
\pgfmathadd@{\pgfplots@quiver@w}{\pgfplots@current@point@z}% |
| 1530 |
\let\pgfplots@quiver@w=\pgfmathresult |
| 1531 |
}{}% |
| 1532 |
\ifpgfplots@quiver@updatelimits |
| 1533 |
\pgfplotsaxisupdatelimitsforcoordinate\pgfplots@quiver@u\pgfplots@quiver@v\pgfplots@quiver@w |
| 1534 |
\fi |
| 1535 |
\fi |
| 1536 |
\pgfplotsaxisdatapointsurveyed |
| 1537 |
}% |
| 1538 |
\def\pgfplotsplothandlerserializepointto@quiver#1{% |
| 1539 |
\edef#1{\pgfplots@current@point@x,\pgfplots@current@point@y,\pgfplots@current@point@z>\pgfplots@quiver@u,\pgfplots@quiver@v,\pgfplots@quiver@w}% |
| 1540 |
}% |
| 1541 |
\def\pgfplotsplothandlerdeserializepointfrom@quiver#1{% |
| 1542 |
\expandafter\pgfplotsplothandlerdeserializepointfrom@quiver@#1\relax |
| 1543 |
}% |
| 1544 |
\def\pgfplotsplothandlerdeserializepointfrom@quiver@#1,#2,#3>#4,#5,#6\relax{% |
| 1545 |
\def\pgfplots@current@point@x{#1}% |
| 1546 |
\def\pgfplots@current@point@y{#2}% |
| 1547 |
\def\pgfplots@current@point@z{#3}% |
| 1548 |
\def\pgfplots@quiver@u{#4}% |
| 1549 |
\def\pgfplots@quiver@v{#5}% |
| 1550 |
\def\pgfplots@quiver@w{#6}% |
| 1551 |
}% |
| 1552 |
\def\pgfplotsplothandlerpointtokeys@quiver#1{% |
| 1553 |
\pgfplotsplothandlerpointtokeys@default |
| 1554 |
\pgfkeyslet{#1/u}\pgfplots@quiver@u |
| 1555 |
\pgfkeyslet{#1/v}\pgfplots@quiver@v |
| 1556 |
\pgfkeyslet{#1/w}\pgfplots@quiver@w |
| 1557 |
}% |
| 1558 |
\def\pgfplotsplothandlervisbegin@quiver{% |
| 1559 |
\def\pgfplots@quiver@has@handled@point@meta{0}% |
| 1560 |
\pgfkeysgetvalue{/pgfplots/quiver/arrow color}\pgfplots@quiver@color |
| 1561 |
\ifx\pgfplots@quiver@color\pgfutil@empty |
| 1562 |
\else |
| 1563 |
% prepare the color data and define 'mapped color': |
| 1564 |
\def\pgfplots@quiver@has@handled@point@meta{1}% |
| 1565 |
\expandafter\def\expandafter\pgfplotsplothandlerquiver@vis@hook\expandafter{% |
| 1566 |
\pgfplotsplothandlerquiver@vis@hook |
| 1567 |
\pgfplotsaxisvisphasetransformpointmeta |
| 1568 |
\pgfplotscolormapdefinemappedcolor{\pgfplotspointmetatransformed}% |
| 1569 |
}% |
| 1570 |
% SEE BELOW AS WELL FOR HOW TO ENABLE THE COLOR. |
| 1571 |
\fi |
| 1572 |
% |
| 1573 |
% |
| 1574 |
\pgfkeysgetvalue{/pgfplots/quiver/every arrow/.@cmd}\pgfplots@quiver@everyarrow |
| 1575 |
\ifx\pgfplots@quiver@everyarrow\pgfplots@empty@style@key |
| 1576 |
% use PGF basic level methods to set the 'arrow color': |
| 1577 |
\ifx\pgfplots@quiver@color\pgfutil@empty |
| 1578 |
\else |
| 1579 |
\expandafter\def\expandafter\pgfplotsplothandlerquiver@vis@hook\expandafter{% |
| 1580 |
\pgfplotsplothandlerquiver@vis@hook |
| 1581 |
\pgfsetstrokecolor{\pgfkeysvalueof{/pgfplots/quiver/arrow color}}% |
| 1582 |
% for arrow heads: |
| 1583 |
\pgfsetfillcolor{\pgfkeysvalueof{/pgfplots/quiver/arrow color}}% |
| 1584 |
}% |
| 1585 |
\fi |
| 1586 |
\else |
| 1587 |
% 'every arrow' should provide a high level user interface. |
| 1588 |
% Use tikz instead of pgf. This is slower, but more powerful. |
| 1589 |
\pgfplots@quiver@usetikztrue |
| 1590 |
\pgfplotsaxisifhaspointmeta{% |
| 1591 |
% ASSERT(mapped color is available) |
| 1592 |
\if0\pgfplots@quiver@has@handled@point@meta% |
| 1593 |
% -> define mapped color |
| 1594 |
\expandafter\def\expandafter\pgfplotsplothandlerquiver@vis@hook\expandafter{% |
| 1595 |
\pgfplotsplothandlerquiver@vis@hook |
| 1596 |
\pgfplotsaxisvisphasetransformpointmeta |
| 1597 |
\pgfplotscolormapdefinemappedcolor{\pgfplotspointmetatransformed}% |
| 1598 |
}% |
| 1599 |
\def\pgfplots@quiver@has@handled@point@meta{1}% |
| 1600 |
\fi |
| 1601 |
}{}% |
| 1602 |
% use tikz methods to set the 'arrow color': |
| 1603 |
\ifx\pgfplots@quiver@color\pgfutil@empty |
| 1604 |
\else |
| 1605 |
\t@pgfplots@toka=\expandafter{\pgfplots@quiver@color}% |
| 1606 |
\edef\pgfplots@loc@TMPa{\noexpand\pgfkeysalso{/pgfplots/quiver/every arrow/.prefix style={\the\t@pgfplots@toka}}}% |
| 1607 |
\pgfplots@loc@TMPa |
| 1608 |
\fi |
| 1609 |
\fi |
| 1610 |
% |
| 1611 |
\global\let\pgf@plotstreampoint=\pgfplotsplothandlerquiver@vis% |
| 1612 |
\global\let\pgf@plotstreamspecial=\pgfutil@gobble% |
| 1613 |
\global\let\pgf@plotstreamend=\relax |
| 1614 |
}% |
| 1615 |
|
| 1616 |
\def\pgfplotsplothandlerquiver@vis#1{% |
| 1617 |
\pgfkeysvalueof{/pgfplots/quiver/before arrow/.@cmd}\pgfeov |
| 1618 |
\pgfplotsplothandlerquiver@vis@hook |
| 1619 |
\ifpgfplots@quiver@usetikz |
| 1620 |
\edef\pgfplotsplothandler@quiver@point{\global\pgf@x=\the\pgf@x\space\global\pgf@y=\the\pgf@y\space}% |
| 1621 |
\draw[/pgfplots/quiver/every arrow] \pgfextra{\pgfplotsplothandlerquiver@vis@path{\pgfplotsplothandler@quiver@point}}; |
| 1622 |
\else |
| 1623 |
\pgfplotsplothandlerquiver@vis@path{#1}% |
| 1624 |
\pgfusepath{stroke}% |
| 1625 |
\fi |
| 1626 |
\pgfkeysvalueof{/pgfplots/quiver/after arrow/.@cmd}\pgfeov |
| 1627 |
}% |
| 1628 |
\def\pgfplotsplothandlerquiver@vis@path#1{% |
| 1629 |
\pgfpathmoveto{#1}% |
| 1630 |
\pgfplotsaxisvisphasetransformcoordinate\pgfplots@quiver@u\pgfplots@quiver@v\pgfplots@quiver@w |
| 1631 |
\pgfpathlineto{% |
| 1632 |
\pgfplotsifcurplotthreedim{% |
| 1633 |
\pgfplotsqpointxyz\pgfplots@quiver@u\pgfplots@quiver@v\pgfplots@quiver@w |
| 1634 |
}{% |
| 1635 |
\pgfplotsqpointxy\pgfplots@quiver@u\pgfplots@quiver@v |
| 1636 |
}% |
| 1637 |
}% |
| 1638 |
}% |
| 1639 |
|
| 1640 |
\newif\ifpgfplotsplothandlerhistogram@intervals |
| 1641 |
\newif\ifpgfplotsplothandlerhistogram@cumulative |
| 1642 |
\newif\ifpgfplotsplothandlerhistogram@density |
| 1643 |
\pgfplotsset{ |
| 1644 |
hist/.code={% |
| 1645 |
\let\tikz@plot@handler=\pgfplotsplothandlerhistogram |
| 1646 |
\pgfqkeys{/pgfplots/hist}{#1}% |
| 1647 |
}, |
| 1648 |
hist/data value/.code =\pgfplots@set@source@for{hist/data}{#1}{0},% |
| 1649 |
hist/data/.code =\pgfplots@set@source@for{hist/data}{#1}{1},% |
| 1650 |
hist/data filter/.code=, |
| 1651 |
hist/data filter/.expression/.code=\pgfplots@install@filter@expression{hist/data filter}{#1}, |
| 1652 |
hist/data value=\pgfkeysvalueof{/data point/y}, |
| 1653 |
% hist/data=y, |
| 1654 |
hist/data min/.initial=\pgfkeysvalueof{/pgfplots/xmin}, |
| 1655 |
hist/data max/.initial=\pgfkeysvalueof{/pgfplots/xmax}, |
| 1656 |
hist/bins/.initial=10, |
| 1657 |
hist/intervals/.is if=pgfplotsplothandlerhistogram@intervals, |
| 1658 |
hist/intervals/.default=true, |
| 1659 |
hist/intervals=true, |
| 1660 |
hist/cumulative/.is if=pgfplotsplothandlerhistogram@cumulative, |
| 1661 |
hist/cumulative/.default=true, |
| 1662 |
hist/density/.is if=pgfplotsplothandlerhistogram@density, |
| 1663 |
hist/density/.default=true, |
| 1664 |
hist/density=false, |
| 1665 |
hist/handler/.style={/tikz/ybar interval}, |
| 1666 |
hist/symbolic coords/.style={% |
| 1667 |
/pgfplots/symbolic coords={hist/data}{#1}, |
| 1668 |
/pgfplots/symbolic coords={x}{#1}, |
| 1669 |
},% |
| 1670 |
}% |
| 1671 |
\def\pgfplotsplothandlerhistogram{% |
| 1672 |
\pgfplotsresetplothandler |
| 1673 |
\def\pgf@plotstreamstart{% |
| 1674 |
\pgfplotsset{/pgfplots/hist/handler}% |
| 1675 |
\pgfplotsresetplothandler |
| 1676 |
\tikz@plot@handler |
| 1677 |
\pgf@plotstreamstart |
| 1678 |
}% |
| 1679 |
% |
| 1680 |
% let \pgfplotsplothandlername to the one of the handler. |
| 1681 |
% Note that \pgfplotsplothandlername is the *visualization* layer |
| 1682 |
\begingroup |
| 1683 |
\pgfplotsset{/pgfplots/hist/handler}% |
| 1684 |
\pgfplotsresetplothandler |
| 1685 |
\tikz@plot@handler |
| 1686 |
\xdef\pgfplots@glob@TMPa{\pgfplotsplothandlername}% |
| 1687 |
\endgroup |
| 1688 |
\let\pgfplotsplothandlername=\pgfplots@glob@TMPa% |
| 1689 |
% |
| 1690 |
\let\pgfplotsplothandlersurveypoint=\pgfplotsplothandlersurveypoint@hist |
| 1691 |
\let\pgfplotsplothandlersurveystart=\pgfplotsplothandlersurveystart@hist |
| 1692 |
\let\pgfplotsplothandlersurveyend=\pgfplotsplothandlersurveyend@hist |
| 1693 |
}% |
| 1694 |
\def\pgfplotsplothandlersurveystart@hist{% |
| 1695 |
\pgfplots@prepare@source@parser@for{hist/}{data}{\pgfplotsplothandlerhistogram@parse}% |
| 1696 |
% |
| 1697 |
\pgfkeysgetvalue{/pgfplots/hist/data min}\pgfmathresult |
| 1698 |
\edef\pgfmathresult{\pgfmathresult}% |
| 1699 |
\ifx\pgfmathresult\pgfutil@empty\else |
| 1700 |
\pgfplots@coord@trafo@for{hist/data}% |
| 1701 |
\fi |
| 1702 |
\edef\pgfplotsplothandlerhistogram@datamin{\pgfmathresult}% |
| 1703 |
% |
| 1704 |
\pgfkeysgetvalue{/pgfplots/hist/data max}\pgfmathresult |
| 1705 |
\edef\pgfmathresult{\pgfmathresult}% |
| 1706 |
\ifx\pgfmathresult\pgfutil@empty\else |
| 1707 |
\pgfplots@coord@trafo@for{hist/data}% |
| 1708 |
\fi |
| 1709 |
\edef\pgfplotsplothandlerhistogram@datamax{\pgfmathresult}% |
| 1710 |
% |
| 1711 |
\ifx\pgfplotsplothandlerhistogram@datamin\pgfutil@empty |
| 1712 |
\pgfmathfloatcreate{1}{1.0}{2147483645}% |
| 1713 |
\let\pgfplotsplothandlerhistogram@datamin=\pgfmathresult |
| 1714 |
\def\pgfplotsplothandlerhistogram@datamin@autocompute{1}% |
| 1715 |
\else |
| 1716 |
\pgfmathfloatparsenumber{\pgfplotsplothandlerhistogram@datamin}% |
| 1717 |
\let\pgfplotsplothandlerhistogram@datamin=\pgfmathresult |
| 1718 |
\def\pgfplotsplothandlerhistogram@datamin@autocompute{0}% |
| 1719 |
\fi |
| 1720 |
\ifx\pgfplotsplothandlerhistogram@datamax\pgfutil@empty |
| 1721 |
\pgfmathfloatcreate{2}{1.0}{2147483645}% |
| 1722 |
\let\pgfplotsplothandlerhistogram@datamax=\pgfmathresult |
| 1723 |
\def\pgfplotsplothandlerhistogram@datamax@autocompute{1}% |
| 1724 |
\else |
| 1725 |
\pgfmathfloatparsenumber{\pgfplotsplothandlerhistogram@datamax}% |
| 1726 |
\let\pgfplotsplothandlerhistogram@datamax=\pgfmathresult |
| 1727 |
\def\pgfplotsplothandlerhistogram@datamax@autocompute{0}% |
| 1728 |
\fi |
| 1729 |
% |
| 1730 |
\edef\pgfplotsplothandlerhistogram@Nfixed{\pgfkeysvalueof{/pgfplots/hist/bins}}% |
| 1731 |
\c@pgf@counta=\pgfplotsplothandlerhistogram@Nfixed\relax |
| 1732 |
\advance\c@pgf@counta by-1 |
| 1733 |
\edef\pgfplotsplothandlerhistogram@Nmax{\the\c@pgf@counta}% |
| 1734 |
% |
| 1735 |
\pgfmathfloatparsenumber{\pgfplotsplothandlerhistogram@Nfixed}% |
| 1736 |
\let\pgfplotsplothandlerhistogram@N=\pgfmathresult |
| 1737 |
% |
| 1738 |
\pgfplotsapplistXnewempty\pgfp@hist@@ |
| 1739 |
\def\c@pgfplotsplothandlerhistogram@num{0}% |
| 1740 |
\c@pgfplots@coordindex=0 |
| 1741 |
}% |
| 1742 |
|
| 1743 |
\def\pgfplotsplothandlersurveypoint@hist@limits{% |
| 1744 |
\if1\pgfplotsplothandlerhistogram@datamin@autocompute |
| 1745 |
\pgfplotsmathfloatmin{\pgfplots@current@point@data}{\pgfplotsplothandlerhistogram@datamin}% |
| 1746 |
\let\pgfplotsplothandlerhistogram@datamin=\pgfmathresult |
| 1747 |
\fi |
| 1748 |
% |
| 1749 |
\if1\pgfplotsplothandlerhistogram@datamax@autocompute |
| 1750 |
\pgfplotsmathfloatmax{\pgfplots@current@point@data}{\pgfplotsplothandlerhistogram@datamax}% |
| 1751 |
\let\pgfplotsplothandlerhistogram@datamax=\pgfmathresult |
| 1752 |
\fi |
| 1753 |
}% |
| 1754 |
\def\pgfplotsplothandlersurveypoint@hist{% |
| 1755 |
% Note that at this point, the coordinate filtering does NOT |
| 1756 |
% apply. Perhaps it should... |
| 1757 |
\pgfplotsplothandlerhistogram@parse |
| 1758 |
\let\pgfplots@current@point@data=\pgfmathresult |
| 1759 |
% |
| 1760 |
\ifx\pgfplots@current@point@data\pgfutil@empty |
| 1761 |
\else |
| 1762 |
\pgfmathfloatiffinite\pgfplots@current@point@data{% |
| 1763 |
\pgfplotsplothandlersurveypoint@hist@limits |
| 1764 |
% |
| 1765 |
\pgfplotsutil@advancestringcounter\c@pgfplotsplothandlerhistogram@num |
| 1766 |
% |
| 1767 |
% store parsed result. |
| 1768 |
\edef\pgfmathresult{{\pgfplots@current@point@data}}% |
| 1769 |
\expandafter\pgfplotsapplistXpushback\expandafter{\pgfmathresult}\to\pgfp@hist@@ |
| 1770 |
}{% |
| 1771 |
}% |
| 1772 |
\fi |
| 1773 |
\advance\c@pgfplots@coordindex by1 |
| 1774 |
}% |
| 1775 |
\def\pgfplotsplothandlersurveyend@hist{% |
| 1776 |
\ifnum\c@pgfplotsplothandlerhistogram@num>0 |
| 1777 |
\expandafter\pgfplotsplothandlersurveyend@hist@ |
| 1778 |
\fi |
| 1779 |
}% |
| 1780 |
\def\pgfplotsplothandlersurveyend@hist@{% |
| 1781 |
\pgfmathfloatsubtract@{\pgfplotsplothandlerhistogram@datamax}{\pgfplotsplothandlerhistogram@datamin}% |
| 1782 |
\let\pgfplotsplothandlerhistogram@range=\pgfmathresult |
| 1783 |
\pgfmathfloatdivide@{\pgfplotsplothandlerhistogram@range}{\pgfplotsplothandlerhistogram@N}% |
| 1784 |
\let\pgfplotsplothandlerhistogram@h=\pgfmathresult |
| 1785 |
\pgfmathfloatreciprocal@{\pgfplotsplothandlerhistogram@h}% |
| 1786 |
\let\pgfplotsplothandlerhistogram@invh=\pgfmathresult |
| 1787 |
% |
| 1788 |
\pgfplotsarraynewempty{pgfp@hist}% |
| 1789 |
\pgfplotsarrayresize{pgfp@hist}{\pgfplotsplothandlerhistogram@Nfixed}% |
| 1790 |
\pgfplotsarrayforeachungrouped{pgfp@hist}\as\pgfplots@hist@count{% |
| 1791 |
\pgfplotsarrayset{\pgfplotsarrayforeachindex}\of{pgfp@hist}\to{0}% |
| 1792 |
}% |
| 1793 |
% |
| 1794 |
\pgfplotsapplistXlet\pgfplots@hist@data=\pgfp@hist@@ |
| 1795 |
\pgfplotsapplistXnewempty\pgfp@hist@@ |
| 1796 |
\expandafter\pgfplotsplothandlersurveyend@hist@loop\pgfplots@hist@data\pgfplots@EOI |
| 1797 |
\let\pgfplots@hist@data=\relax |
| 1798 |
% |
| 1799 |
|
| 1800 |
% Calculate total count |
| 1801 |
\c@pgf@counta=0 |
| 1802 |
\pgfplotsarrayforeachungrouped{pgfp@hist}\as\pgfplots@hist@count{% |
| 1803 |
\advance\c@pgf@counta by\pgfplots@hist@count\relax |
| 1804 |
\def\pgfplots@loc@TMPa{\pgfplotsarrayset{\pgfplotsarrayforeachindex}\of{pgfp@hist}\to}% |
| 1805 |
}% |
| 1806 |
\pgfmathfloatparsenumber{\the\c@pgf@counta}% |
| 1807 |
\let\pgfp@hist@totalcount=\pgfmathresult |
| 1808 |
\pgfmathfloatreciprocal@{\pgfp@hist@totalcount}% |
| 1809 |
\let\pgfp@hist@totalcount@inv=\pgfmathresult |
| 1810 |
% |
| 1811 |
\ifpgfplotsplothandlerhistogram@cumulative |
| 1812 |
\c@pgf@counta=0 |
| 1813 |
\pgfplotsarrayforeachungrouped{pgfp@hist}\as\pgfplots@hist@count{% |
| 1814 |
\advance\c@pgf@counta by\pgfplots@hist@count\relax |
| 1815 |
\def\pgfplots@loc@TMPa{\pgfplotsarrayset{\pgfplotsarrayforeachindex}\of{pgfp@hist}\to}% |
| 1816 |
\ifpgfplotsplothandlerhistogram@density |
| 1817 |
\pgfmathfloatparsenumber{\the\c@pgf@counta}% |
| 1818 |
\pgfmathfloatmultiply@{\pgfmathresult}{\pgfp@hist@totalcount@inv}% |
| 1819 |
\pgfmathfloattosci@{\pgfmathresult}% |
| 1820 |
\expandafter\pgfplots@loc@TMPa\expandafter{\pgfmathresult}% |
| 1821 |
\else |
| 1822 |
\expandafter\pgfplots@loc@TMPa\expandafter{\the\c@pgf@counta}% |
| 1823 |
\fi |
| 1824 |
}% |
| 1825 |
\fi% |
| 1826 |
% |
| 1827 |
%% Density histogram |
| 1828 |
% Divide count in each bin by (totalcount*range/bins) |
| 1829 |
\ifpgfplotsplothandlerhistogram@density |
| 1830 |
\ifpgfplotsplothandlerhistogram@cumulative |
| 1831 |
\else |
| 1832 |
\pgfmathfloatmultiply@{\pgfp@hist@totalcount@inv}{\pgfplotsplothandlerhistogram@invh}% |
| 1833 |
\let\pgfp@hist@totalcount@times@h@inv=\pgfmathresult |
| 1834 |
% FIXME : this here is a patch suggestion for |
| 1835 |
% https://sourceforge.net/tracker/?func=detail&atid=1060656&aid=3609245&group_id=224188 |
| 1836 |
% |
| 1837 |
% FIXME : this line would actually compute relative frequencies... |
| 1838 |
% might not be too bad at all, but is no density |
| 1839 |
%\let\pgfp@hist@totalcount@times@h@inv=\pgfp@hist@totalcount@inv |
| 1840 |
\pgfplotsarrayforeachungrouped{pgfp@hist}\as\pgfplots@hist@count{% |
| 1841 |
\pgfmathfloatparsenumber{\pgfplots@hist@count}% |
| 1842 |
\pgfmathfloatmultiply@{\pgfmathresult}{\pgfp@hist@totalcount@times@h@inv}% |
| 1843 |
\pgfmathfloattosci@{\pgfmathresult}% |
| 1844 |
\def\pgfplots@loc@TMPa{\pgfplotsarrayset{\pgfplotsarrayforeachindex}\of{pgfp@hist}\to}% |
| 1845 |
\expandafter\pgfplots@loc@TMPa\expandafter{\pgfmathresult}% |
| 1846 |
}% |
| 1847 |
\fi |
| 1848 |
\fi |
| 1849 |
% |
| 1850 |
%% End density histogram |
| 1851 |
\pgfplots@curplot@threedimfalse |
| 1852 |
% |
| 1853 |
\pgfplotsset{/pgfplots/hist/handler}% |
| 1854 |
\pgfplotsresetplothandler |
| 1855 |
\tikz@plot@handler |
| 1856 |
% |
| 1857 |
\pgfplotsplothandlersurveystart |
| 1858 |
% |
| 1859 |
\let\pgfplots@current@point@z=\pgfutil@empty |
| 1860 |
\pgfplotsarrayforeachungrouped{pgfp@hist}\as\pgfplots@hist@count{% |
| 1861 |
\pgfplotsplothandlerhistgetintervalstartfor\pgfplotsarrayforeachindex |
| 1862 |
\pgfplotsplothandlerhist@invtrafo |
| 1863 |
\let\pgfplots@current@point@x\pgfmathresult% |
| 1864 |
\let\pgfplots@current@point@y\pgfplots@hist@count% |
| 1865 |
%\message{Survey point (\pgfplots@current@point@x,\pgfplots@current@point@y)^^J}% |
| 1866 |
\pgfplotsplothandlersurveypoint |
| 1867 |
}% |
| 1868 |
\ifpgfplotsplothandlerhistogram@intervals |
| 1869 |
% replicate last count. |
| 1870 |
\let\pgfmathresult\pgfplotsplothandlerhistogram@datamax% |
| 1871 |
\pgfplotsplothandlerhist@invtrafo |
| 1872 |
\let\pgfplots@current@point@x\pgfmathresult% |
| 1873 |
\let\pgfplots@current@point@y\pgfplots@hist@count% |
| 1874 |
%\message{Survey point (\pgfplots@current@point@x,\pgfplots@current@point@y)^^J}% |
| 1875 |
\pgfplotsplothandlersurveypoint |
| 1876 |
\fi |
| 1877 |
% |
| 1878 |
\pgfplotsplothandlersurveyend |
| 1879 |
} |
| 1880 |
\def\pgfplotsplothandlerhist@invtrafo{% |
| 1881 |
% This here might be inefficient, because |
| 1882 |
% there needs to be a compatible "x coord trafo" as well -- and |
| 1883 |
% that transformation will (most likely) do the very same thing as |
| 1884 |
% the hist/data coord trafo. |
| 1885 |
% |
| 1886 |
% But I did not find a way to combine the transformations |
| 1887 |
% automatically without resorting to hackery. |
| 1888 |
% |
| 1889 |
% And: the performance impact might (hopefully) be small... |
| 1890 |
\pgfplots@coord@trafo@inv@for{hist/data}% |
| 1891 |
}% |
| 1892 |
\def\pgfplotsplothandlersurveyend@hist@loop#1{% |
| 1893 |
\def\pgfplots@loc@TMPa{#1}% |
| 1894 |
\ifx\pgfplots@loc@TMPa\pgfplots@EOI |
| 1895 |
\else |
| 1896 |
\pgfplotsplothandlerhistgetbinfor@{#1}% |
| 1897 |
\expandafter\pgfplotsplothandlerhistadvancebin\expandafter{\pgfmathresult}% |
| 1898 |
% |
| 1899 |
\expandafter\pgfplotsplothandlersurveyend@hist@loop |
| 1900 |
\fi |
| 1901 |
}% |
| 1902 |
\def\pgfplotsplothandlerhistadvancebin#1{% |
| 1903 |
\pgfplotsarrayselect{#1}\of{pgfp@hist}\to\pgfplots@loc@TMPa% |
| 1904 |
\pgfplotsutil@advancestringcounter\pgfplots@loc@TMPa |
| 1905 |
\pgfplotsarrayletentry{#1}\of{pgfp@hist}=\pgfplots@loc@TMPa |
| 1906 |
}% |
| 1907 |
\def\pgfplotsplothandlerhistgetintervalstartfor#1{% |
| 1908 |
\pgfmathfloatparsenumber{#1}% |
| 1909 |
\expandafter\pgfplotsplothandlerhistgetintervalstartfor@\expandafter{\pgfmathresult}% |
| 1910 |
}% |
| 1911 |
\def\pgfplotsplothandlerhistgetintervalstartfor@#1{% |
| 1912 |
\pgfmathfloatmultiply@{\pgfplotsplothandlerhistogram@h}{#1}% |
| 1913 |
\expandafter\pgfmathfloatadd@\expandafter{\pgfmathresult}{\pgfplotsplothandlerhistogram@datamin}% |
| 1914 |
}% |
| 1915 |
\def\pgfplotsplothandlerhistgetbinfor#1{% |
| 1916 |
\pgfmathfloatparsenumber{#1}% |
| 1917 |
\expandafter\pgfplotsplothandlerhistgetbinfor@\expandafter{\pgfmathresult}% |
| 1918 |
}% |
| 1919 |
|
| 1920 |
\def\pgfplotsplothandlerhistsettol#1{% |
| 1921 |
\begingroup |
| 1922 |
\pgfmathfloatparsenumber{#1}% |
| 1923 |
\global\let\pgfplotsplothandlerhisttol@parsed=\pgfmathresult |
| 1924 |
\endgroup |
| 1925 |
}% |
| 1926 |
\pgfplotsplothandlerhistsettol{1e-4}% |
| 1927 |
|
| 1928 |
\def\pgfplotsplothandlerhistgetbinfor@#1{% |
| 1929 |
\pgfmathfloatsubtract@{#1}{\pgfplotsplothandlerhistogram@datamin}% |
| 1930 |
\expandafter\pgfmathfloatmultiply@\expandafter{\pgfmathresult}{\pgfplotsplothandlerhistogram@invh}% |
| 1931 |
\expandafter\pgfmathfloatadd@\expandafter{\pgfmathresult}{\pgfplotsplothandlerhisttol@parsed}% |
| 1932 |
\pgfmathfloattofixed{\pgfmathresult}% |
| 1933 |
\afterassignment\pgfplots@gobble@until@relax |
| 1934 |
\c@pgf@counta=\pgfmathresult\relax |
| 1935 |
\ifnum\pgfplotsplothandlerhistogram@Nfixed>\c@pgf@counta |
| 1936 |
\ifnum\c@pgf@counta<0 |
| 1937 |
\def\pgfmathresult{0}% |
| 1938 |
\else |
| 1939 |
\def\pgfmathresult{\the\c@pgf@counta}% |
| 1940 |
\fi |
| 1941 |
\else |
| 1942 |
\let\pgfmathresult=\pgfplotsplothandlerhistogram@Nmax |
| 1943 |
\fi |
| 1944 |
}% |
| 1945 |
|
| 1946 |
|
| 1947 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5 |
| 1948 |
% |
| 1949 |
% Contour plots |
| 1950 |
% |
| 1951 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%5 |
| 1952 |
|
| 1953 |
\newif\ifpgfplotsplothandlercontour@labels |
| 1954 |
\newif\ifpgfplotsplothandlercontour@filled |
| 1955 |
\newif\ifpgfplotsplothandlercontour@corners |
| 1956 |
|
| 1957 |
\def\pgfplotsplothandlercontour@axis@set@inverse#1#2#3#4{% |
| 1958 |
\pgfplotsutilifstringequal{#1}{#4}{% |
| 1959 |
\expandafter\def\csname pgfplotsplothandlercontour@axis@inv@#4\endcsname{x}% |
| 1960 |
}{% |
| 1961 |
\pgfplotsutilifstringequal{#2}{#4}{% |
| 1962 |
\expandafter\def\csname pgfplotsplothandlercontour@axis@inv@#4\endcsname{y}% |
| 1963 |
}{% |
| 1964 |
\pgfplotsutilifstringequal{#3}{#4}{% |
| 1965 |
\expandafter\def\csname pgfplotsplothandlercontour@axis@inv@#4\endcsname{z}% |
| 1966 |
}{% |
| 1967 |
\pgfplotsthrow{invalid argument}{\pgfplots@loc@TMPa}{Sorry, the choice axes={#1}{#2}{#3} is illegal. Please use only values x, y, and z and ensure that there is a 1:1 correspondence}\pgfeov% |
| 1968 |
}% |
| 1969 |
}% |
| 1970 |
}% |
| 1971 |
} |
| 1972 |
|
| 1973 |
\pgfplotsset{ |
| 1974 |
contour prepared/.code={% |
| 1975 |
\let\tikz@plot@handler=\pgfplotsplothandlercontourprepared |
| 1976 |
\pgfqkeys{/pgfplots/contour}{% |
| 1977 |
every contour plot,% |
| 1978 |
#1,% |
| 1979 |
}% |
| 1980 |
}, |
| 1981 |
contour prepared filled/.style={% |
| 1982 |
/pgfplots/contour prepared={draw color=mapped color!80!black,labels=false,filled=true}, |
| 1983 |
}, |
| 1984 |
contour filled/.code={% |
| 1985 |
\pgfqkeys{/pgfplots/contour}{% |
| 1986 |
every filled contour plot,% |
| 1987 |
/pgfplots/surf,% |
| 1988 |
/pgfplots/shader=interp,% |
| 1989 |
/pgfplots/colormap access=const,% |
| 1990 |
#1,% |
| 1991 |
}% |
| 1992 |
\let\tikz@plot@handler=\pgfplotsplothandlercontourfilled |
| 1993 |
}, |
| 1994 |
% FIXME : should use \tikz@plot@handler instead of just the |
| 1995 |
% visualization thing! |
| 1996 |
contour/handler/.style={/tikz/sharp plot}, |
| 1997 |
contour prepared format/.is choice, |
| 1998 |
contour prepared format/standard/.code= {\def\pgfplotsplothandlercontourprepared@format{s}}, |
| 1999 |
contour prepared format/matlab/.code= {\def\pgfplotsplothandlercontourprepared@format{m}}, |
| 2000 |
contour prepared format/standard, |
| 2001 |
contour/draw color/.initial=mapped color, |
| 2002 |
contour/fill color/.initial=mapped color, |
| 2003 |
contour/label distance/.initial=70pt, |
| 2004 |
contour/label node code/.code={% |
| 2005 |
\node {\pgfmathprintnumber{#1}}; |
| 2006 |
},% |
| 2007 |
contour/labels/.is if=pgfplotsplothandlercontour@labels, |
| 2008 |
contour/labels=true, |
| 2009 |
% |
| 2010 |
% XXX : this here is dead code... it has been superseded by |
| 2011 |
% \pgfplotsplothandlercontourfilled: |
| 2012 |
contour/filled/.is if=pgfplotsplothandlercontour@filled, |
| 2013 |
contour/filled/.default=true, |
| 2014 |
% EXPERIMENTAL: WILL CHANGE EVENTUALLY! |
| 2015 |
% this is (only) used for contour filled: |
| 2016 |
% data limits={(xmin,ymin,zmin,cmin) (xmax,ymax,ymax,cmax} |
| 2017 |
contour/data limits/.initial=,% FIXME EXPERIMENTAL |
| 2018 |
contour/every filled contour plot/.style={ |
| 2019 |
/pgfplots/area legend, |
| 2020 |
}, |
| 2021 |
contour/every contour plot/.style={ |
| 2022 |
/pgfplots/legend image post style={sharp plot}, |
| 2023 |
}, |
| 2024 |
contour/every contour label/.style={% |
| 2025 |
sloped,% |
| 2026 |
transform shape,% |
| 2027 |
inner sep=2pt, |
| 2028 |
font=\scriptsize, |
| 2029 |
every node/.style={mapped color!50!black,fill=white},% |
| 2030 |
/pgf/number format/relative*={\pgfplotspointmetarangeexponent},% |
| 2031 |
%every node/.style={yshift=10pt},% |
| 2032 |
}, |
| 2033 |
contour/labels over line/.style={ |
| 2034 |
/pgfplots/contour/every contour label/.append style={% |
| 2035 |
every node/.append style={% |
| 2036 |
fill=none, |
| 2037 |
anchor=base, |
| 2038 |
yshift=1pt, |
| 2039 |
}, |
| 2040 |
}, |
| 2041 |
}, |
| 2042 |
contour/contour label style/.style={ |
| 2043 |
/pgfplots/contour/every contour label/.append style={#1}}, |
| 2044 |
% |
| 2045 |
contour/corners/.is if=pgfplotsplothandlercontour@corners, |
| 2046 |
contour/corners=false, |
| 2047 |
% |
| 2048 |
% Styles to actually *compute* the contour. |
| 2049 |
% These are mostly placeholders here: As long as the |
| 2050 |
% algorithm is not ready, we have to resort to external tools. |
| 2051 |
% |
| 2052 |
% Shared parameters: |
| 2053 |
contour/number/.initial=5, |
| 2054 |
contour/levels/.initial=, |
| 2055 |
contour/levels from colormap/.initial=, |
| 2056 |
% |
| 2057 |
% |
| 2058 |
contour/contour dir/.is choice, |
| 2059 |
contour/contour dir/x/.style={/pgfplots/contour/axes={y}{z}{x}}, |
| 2060 |
contour/contour dir/y/.style={/pgfplots/contour/axes={x}{z}{y}}, |
| 2061 |
contour/contour dir/z/.style={/pgfplots/contour/axes={x}{y}{z}}, |
| 2062 |
contour/axes/.code args={#1#2#3}{% |
| 2063 |
\edef\pgfplotsplothandlercontour@axis@x{#1}% |
| 2064 |
\edef\pgfplotsplothandlercontour@axis@y{#2}% |
| 2065 |
\edef\pgfplotsplothandlercontour@axis@z{#3}% |
| 2066 |
% |
| 2067 |
\edef\pgfplots@loc@TMPa{{\pgfplotsplothandlercontour@axis@x}{\pgfplotsplothandlercontour@axis@y}{\pgfplotsplothandlercontour@axis@z}}% |
| 2068 |
% |
| 2069 |
\expandafter\pgfplotsplothandlercontour@axis@set@inverse\pgfplots@loc@TMPa{x}% |
| 2070 |
\expandafter\pgfplotsplothandlercontour@axis@set@inverse\pgfplots@loc@TMPa{y}% |
| 2071 |
\expandafter\pgfplotsplothandlercontour@axis@set@inverse\pgfplots@loc@TMPa{z}% |
| 2072 |
% |
| 2073 |
},% |
| 2074 |
contour/contour dir=z, |
| 2075 |
% |
| 2076 |
% |
| 2077 |
% Interface to external tools: |
| 2078 |
contour external/.code={% |
| 2079 |
\edef\tikz@plot@handler{\noexpand\pgfplotsplothandlercontourexternal}% |
| 2080 |
\pgfqkeys{/pgfplots/contour external}{% |
| 2081 |
every contour plot,% |
| 2082 |
#1% |
| 2083 |
}% |
| 2084 |
}, |
| 2085 |
contour external/scanline marks/.is choice, |
| 2086 |
contour external/scanline marks/false/.code={\def\pgfplotsplothandlercontourexternal@scanlinemode{0}}, |
| 2087 |
contour external/scanline marks/if in input/.code={\def\pgfplotsplothandlercontourexternal@scanlinemode{1}}, |
| 2088 |
contour external/scanline marks/required/.code={\def\pgfplotsplothandlercontourexternal@scanlinemode{2}}, |
| 2089 |
contour external/scanline marks/true/.code={\def\pgfplotsplothandlercontourexternal@scanlinemode{2}}, |
| 2090 |
contour external/scanline marks/if in input, |
| 2091 |
contour external/output point meta/.initial=, |
| 2092 |
contour external/file/.initial=,% auto-generate |
| 2093 |
contour external/script extension/.initial=script, |
| 2094 |
contour external/script/.initial=,% not yet initialised |
| 2095 |
contour external/cmd/.initial=,% not yet initialised |
| 2096 |
contour external/script type/.is choice=,% |
| 2097 |
contour external/script type/system call/.code={\def\pgfplotsplothandlercontourexternal@script@type{S}},% |
| 2098 |
contour external/script type/lua/.code={\def\pgfplotsplothandlercontourexternal@script@type{L}\pgfkeyssetvalue{/pgfplots/contour external/script extension}{lua}},% |
| 2099 |
contour external/script type/system call,% |
| 2100 |
contour external/script input format/.is choice,% |
| 2101 |
contour external/script input format/x y meta meta/.code={\def\pgfplotsplothandlercontourexternal@script@input@format{M}},% |
| 2102 |
contour external/script input format/x y z meta/.code={\def\pgfplotsplothandlercontourexternal@script@input@format{Z}},% |
| 2103 |
contour external/script input format=x y meta meta,% |
| 2104 |
contour external/@before cmd/.initial=, |
| 2105 |
contour external/@after cmd/.initial=, |
| 2106 |
contour external/.search also=/pgfplots/contour, |
| 2107 |
contour gnuplot/.style={ |
| 2108 |
contour external={% |
| 2109 |
scanline marks=required, |
| 2110 |
script={ |
| 2111 |
unset surface; |
| 2112 |
\ifx\thecontourlevels\empty |
| 2113 |
set cntrparam levels \thecontournumber; |
| 2114 |
\else |
| 2115 |
set cntrparam levels discrete \thecontourlevels; |
| 2116 |
\fi |
| 2117 |
set contour; |
| 2118 |
set table \"\outfile\"; |
| 2119 |
splot \"\infile\"; |
| 2120 |
}, |
| 2121 |
cmd={gnuplot \"\script\"},% |
| 2122 |
#1,% |
| 2123 |
}, |
| 2124 |
}, |
| 2125 |
}% |
| 2126 |
|
| 2127 |
\def\pgfplotsplothandlercontourprepared{% |
| 2128 |
\pgfplotsresetplothandler |
| 2129 |
\pgfplotsset{empty line=jump}% |
| 2130 |
\let\pgf@plotstreamstart=\pgfplotsplothandlervisstart@contour |
| 2131 |
\let\pgfplotsplothandlersurveystart=\pgfplotsplothandlersurveystart@contour |
| 2132 |
\let\pgfplotsplothandlersurveyend=\pgfplotsplothandlersurveyend@contour |
| 2133 |
\let\pgfplotsplothandlersurveypoint=\pgfplotsplothandlersurveypoint@contour |
| 2134 |
\if m\pgfplotsplothandlercontourprepared@format |
| 2135 |
\let\pgfplotsplothandlersurveystart=\pgfplotsplothandlersurveystart@contourmatlabformat |
| 2136 |
\let\pgfplotsplothandlersurveypoint=\pgfplotsplothandlersurveypoint@contourmatlabformat |
| 2137 |
\pgfplotsaxisifhaspointmeta{}{% |
| 2138 |
\pgfplotsset{/pgfplots/point meta=explicit}% |
| 2139 |
}% |
| 2140 |
\fi |
| 2141 |
\pgfplotsplothandlercontour@prepare@point@meta |
| 2142 |
\def\pgfplotsplothandlersurveybeforesetpointmeta{% |
| 2143 |
% ensure that 'point meta=z' respects 'axes={y}{z}{x}' -- it |
| 2144 |
% should assign the 'x' coordinate as point meta! |
| 2145 |
% To this end, we have to convert to reordered axes |
| 2146 |
% temporarily. |
| 2147 |
\pgfplotsplothandlersurveypoint@contour@axes@std@to@reordered |
| 2148 |
\pgfplotsplothandlersurveybeforesetpointmeta@default |
| 2149 |
}% |
| 2150 |
\def\pgfplotsplothandlersurveyaftersetpointmeta{% |
| 2151 |
\pgfplotsplothandlersurveyaftersetpointmeta@default |
| 2152 |
% ... and undo the reordering after point meta has been set: |
| 2153 |
\pgfplotsplothandlersurveypoint@contour@axes@reordered@to@std |
| 2154 |
}% |
| 2155 |
\def\pgfplotsplothandlername{contour prepared}% |
| 2156 |
}% |
| 2157 |
|
| 2158 |
\def\pgfplotsplothandlersurveystart@contour{% |
| 2159 |
\pgfplotsplothandlersurveystart@default |
| 2160 |
% |
| 2161 |
\pgfplotsplothandlersurveypoint@contour@prepare@axes x% |
| 2162 |
\pgfplotsplothandlersurveypoint@contour@prepare@axes y% |
| 2163 |
\pgfplotsplothandlersurveypoint@contour@prepare@axes z% |
| 2164 |
}% |
| 2165 |
|
| 2166 |
\def\pgfplotsplothandlercontour@prepare@point@meta{% |
| 2167 |
\ifpgfplots@curplot@threedim |
| 2168 |
\pgfplotsset{/pgfplots/set point meta if empty=z}% |
| 2169 |
\else |
| 2170 |
\pgfplotsaxisifhaspointmeta{}{% |
| 2171 |
\pgfkeysgetvalue{/pgfplots/table/meta index}\pgfplots@loc@TMPa |
| 2172 |
\ifx\pgfplots@loc@TMPa\pgfutil@empty |
| 2173 |
% FIXME : this here is reasonable, but it should be sanity checked! |
| 2174 |
\pgfkeyssetvalue{/pgfplots/table/meta index}{2}% |
| 2175 |
\fi |
| 2176 |
\pgfplotsset{/pgfplots/set point meta if empty=explicit}% |
| 2177 |
}% |
| 2178 |
%\pgfplots@error{Sorry, 'contour external' requires \string\addplot3 (or a non-empty `point meta' used as label data)}% |
| 2179 |
\fi |
| 2180 |
\def\pgfplotsplothandlercontour@empty@pointmeta@error@@{0}% |
| 2181 |
}% |
| 2182 |
\def\pgfplotsplothandlercontour@empty@pointmeta@error{% |
| 2183 |
\if0\pgfplotsplothandlercontour@empty@pointmeta@error@@ |
| 2184 |
\def\pgfplotsplothandlercontour@empty@pointmeta@error@@{1}% |
| 2185 |
\def\pgfplots@current@point@meta{0}% |
| 2186 |
\pgfplotsthrow{invalid argument}{\pgfplots@current@point@meta}{Sorry, contour plots require non--empty `point meta'. Please use '\string\addplot3[contour ...] together with 'view={0}{90}' or provide a valid 'point meta=<value>' (for example `<value>=z'?)}\pgfeov% |
| 2187 |
\fi |
| 2188 |
}% |
| 2189 |
|
| 2190 |
\def\pgfplotsplothandlersurveystart@contourmatlabformat{% |
| 2191 |
\def\c@pgfplotsplothandlercontourprepared@matlabformat@cur{0}% |
| 2192 |
\def\c@pgfplotsplothandlercontourprepared@matlabformat@count{0}% |
| 2193 |
\pgfmathfloatparsenumber{nan}% |
| 2194 |
\let\pgfplotsplothandlercontourprepared@matlabformat@meta=\pgfmathresult |
| 2195 |
% |
| 2196 |
\pgfplotsplothandlersurveystart@contour |
| 2197 |
} |
| 2198 |
\def\pgfplotsplothandlersurveypoint@contourmatlabformat{% |
| 2199 |
\ifnum\c@pgfplotsplothandlercontourprepared@matlabformat@cur=\c@pgfplotsplothandlercontourprepared@matlabformat@count\relax |
| 2200 |
\pgfmathfloatparsenumber{\pgfplots@current@point@y}% |
| 2201 |
\pgfmathfloattoint\pgfmathresult |
| 2202 |
\let\c@pgfplotsplothandlercontourprepared@matlabformat@count=\pgfmathresult |
| 2203 |
\def\c@pgfplotsplothandlercontourprepared@matlabformat@cur{0}% |
| 2204 |
% |
| 2205 |
\pgfmathfloatparsenumber{\pgfplots@current@point@x}% |
| 2206 |
\let\pgfplots@loc@TMPa=\pgfplotsplothandlercontourprepared@matlabformat@meta |
| 2207 |
\let\pgfplotsplothandlercontourprepared@matlabformat@meta=\pgfmathresult |
| 2208 |
% |
| 2209 |
\ifx\pgfplots@loc@TMPa\pgfplotsplothandlercontourprepared@matlabformat@meta |
| 2210 |
% oh. We have two successive segments of the SAME contour |
| 2211 |
% level. Call the jump handler: |
| 2212 |
\pgfplotsscanlinecomplete |
| 2213 |
\fi |
| 2214 |
% |
| 2215 |
\else |
| 2216 |
\let\pgfplots@current@point@z=\pgfplotsplothandlercontourprepared@matlabformat@meta |
| 2217 |
\let\pgfplots@current@point@meta=\pgfplotsplothandlercontourprepared@matlabformat@meta |
| 2218 |
\pgfplotsplothandlersurveypoint@contour |
| 2219 |
\pgfplotsutil@advancestringcounter\c@pgfplotsplothandlercontourprepared@matlabformat@cur |
| 2220 |
\fi |
| 2221 |
}% |
| 2222 |
|
| 2223 |
\def\pgfplotsplothandlersurveypoint@contour{% |
| 2224 |
% |
| 2225 |
\pgfplotsplothandlersurveypoint@contour@axes@reordered@to@std |
| 2226 |
% |
| 2227 |
\pgfplotsplothandlersurveypoint@default |
| 2228 |
} |
| 2229 |
|
| 2230 |
\def\pgfplotsplothandlersurveyend@contour{% |
| 2231 |
\pgfplotsplothandlercontour@init@limits |
| 2232 |
\ifx\pgfplotsplothandlercontour@limits@low@meta\pgfutil@empty |
| 2233 |
\else |
| 2234 |
\pgfplotsaxisupdatelimitsforpointmeta\pgfplotsplothandlercontour@limits@low@meta |
| 2235 |
\fi |
| 2236 |
}% |
| 2237 |
|
| 2238 |
\def\pgfplotsplothandlervisstart@contour{% |
| 2239 |
% |
| 2240 |
\ifpgfplotsplothandlercontour@labels |
| 2241 |
\pgfkeysgetvalue{/pgfplots/contour/label distance}\pgfplotsplothandlercontour@labeldist |
| 2242 |
\pgfmathparse{\pgfplotsplothandlercontour@labeldist}% |
| 2243 |
\edef\pgfplotsplothandlercontour@labeldist{\pgfmathresult pt}% |
| 2244 |
% |
| 2245 |
\pgfplotsapplistXnewempty\pgfplotsplothandlercontour@storedlabels |
| 2246 |
\let\pgfplotsplothandlercontour@handlesplinesegment=\pgfplotsplothandlercontour@handlesplinesegment@forlabels |
| 2247 |
\else |
| 2248 |
\def\pgfplotsplothandlercontour@handlesplinesegment##1##2##3{}% |
| 2249 |
\fi |
| 2250 |
% |
| 2251 |
\ifpgfplotsplothandlercontour@filled |
| 2252 |
\pgfseteorule |
| 2253 |
\let\pgfplotsplothandlercontour@sequence@sort@cmp=\pgfutil@empty |
| 2254 |
\pgfplotsapplistXnewempty\pgfplotsplothandlercontour@stored@lastcontourpath |
| 2255 |
\pgfplotsplothandlercontour@init@limits |
| 2256 |
\fi |
| 2257 |
% |
| 2258 |
\pgfplotsresetplothandler |
| 2259 |
\pgfplotsset{/pgfplots/contour/handler}% |
| 2260 |
\tikz@plot@handler |
| 2261 |
% |
| 2262 |
\def\pgfplotsplothandlercontour@haspendingjump{0}% |
| 2263 |
\let\pgfplotsplothandlervisualizejump=\pgfplotsplothandlercontour@jump |
| 2264 |
% |
| 2265 |
\let\pgfplotsplothandlercontour@handler@start=\pgf@plotstreamstart |
| 2266 |
\let\pgfplotsplothandlercontour@lastcontour=\pgfutil@empty |
| 2267 |
\global\let\pgf@plotstreampoint=\pgfplotsplothandlercontour@streampoint |
| 2268 |
\global\let\pgf@plotstreamend=\pgfplotsplothandlercontour@streamend |
| 2269 |
}% |
| 2270 |
|
| 2271 |
\def\pgfplotsplothandlercontour@jump{% |
| 2272 |
\def\pgfplotsplothandlercontour@haspendingjump{1}% |
| 2273 |
}% |
| 2274 |
|
| 2275 |
\def\pgfplotsplothandlercontour@streamend{% |
| 2276 |
\ifx\pgfplotsplothandlercontour@lastcontour\pgfutil@empty |
| 2277 |
\else |
| 2278 |
% |
| 2279 |
\def\pgfplotsplothandlercontour@haspendingjump{0}% important! (this is a different case than a jump) |
| 2280 |
\pgfplotsplothandlercontour@finishcontourline |
| 2281 |
% |
| 2282 |
\ifpgfplotsplothandlercontour@filled |
| 2283 |
\if0\pgfplotsplothandlercontour@processed@outer |
| 2284 |
\pgfplotsplothandlercontour@stream@bbcontour |
| 2285 |
\pgfplotsplothandlercontour@finishcontourline |
| 2286 |
\fi |
| 2287 |
\fi |
| 2288 |
% |
| 2289 |
\ifpgfplotsplothandlercontour@labels |
| 2290 |
\scope[/pgfplots/contour/every contour label] |
| 2291 |
\let\pgfplots@restore@drawmodes=\relax% FIXME : necessary? |
| 2292 |
\pgfplotsapplistXlet\pgfplotsplothandlercontour@storedlabels@=\pgfplotsplothandlercontour@storedlabels |
| 2293 |
\pgfplotsapplistXnewempty\pgfplotsplothandlercontour@storedlabels |
| 2294 |
\expandafter\pgfplotsplothandlercontourplacelabels\pgfplotsplothandlercontour@storedlabels@\pgfplots@EOI |
| 2295 |
\endscope |
| 2296 |
\fi |
| 2297 |
\fi |
| 2298 |
}% |
| 2299 |
\def\pgfplotsplothandlercontour@check@bbcontour{% |
| 2300 |
\ifpgfplotsplothandlercontour@filled |
| 2301 |
\if0\pgfplotsplothandlercontour@processed@outer |
| 2302 |
\pgfplotscoordmath{meta}{if less than} |
| 2303 |
{\pgfplotsplothandlercontour@act@contour} |
| 2304 |
{\pgfplotsplothandlercontour@limits@low@meta} |
| 2305 |
{% |
| 2306 |
% TRUE! |
| 2307 |
\pgfplotsplothandlercontour@stream@bbcontour@inbetween |
| 2308 |
}{}% |
| 2309 |
\fi |
| 2310 |
\fi |
| 2311 |
}% |
| 2312 |
\def\pgfplotsplothandlercontour@stream@bbcontour@inbetween{% |
| 2313 |
\def\pgfplotsplothandlercontour@processed@outer{1}% |
| 2314 |
}% |
| 2315 |
|
| 2316 |
\def\pgfplotsplothandlercontour@stream@bbcontour{% |
| 2317 |
%\message{contour: processing OUTER data limit contour...}% |
| 2318 |
\def\pgfplotsplothandlercontour@haspendingjump{0}% important |
| 2319 |
% |
| 2320 |
% forbid labels: |
| 2321 |
\let\pgfplotsplothandlercontour@stream@bbcontour@oldlabelsetting=\pgfplotsplothandlercontour@handlesplinesegment |
| 2322 |
\def\pgfplotsplothandlercontour@handlesplinesegment##1##2##3{}% |
| 2323 |
% |
| 2324 |
\let\pgfplots@current@point@meta=\pgfplotsplothandlercontour@limits@low@meta |
| 2325 |
\pgfplotsplothandlercontour@streampoint{% |
| 2326 |
\pgfplotsplothandlerpointxyz |
| 2327 |
\pgfplotsplothandlercontour@limits@low@x |
| 2328 |
\pgfplotsplothandlercontour@limits@low@y |
| 2329 |
\pgfplotsplothandlercontour@limits@low@z |
| 2330 |
}% |
| 2331 |
\pgfplotsplothandlercontour@streampoint{% |
| 2332 |
\pgfplotsplothandlerpointxyz |
| 2333 |
\pgfplotsplothandlercontour@limits@high@x |
| 2334 |
\pgfplotsplothandlercontour@limits@low@y |
| 2335 |
\pgfplotsplothandlercontour@limits@low@z |
| 2336 |
}% |
| 2337 |
\pgfplotsplothandlercontour@streampoint{% |
| 2338 |
\pgfplotsplothandlerpointxyz |
| 2339 |
\pgfplotsplothandlercontour@limits@high@x |
| 2340 |
\pgfplotsplothandlercontour@limits@high@y |
| 2341 |
\pgfplotsplothandlercontour@limits@low@z |
| 2342 |
}% |
| 2343 |
\pgfplotsplothandlercontour@streampoint{% |
| 2344 |
\pgfplotsplothandlerpointxyz |
| 2345 |
\pgfplotsplothandlercontour@limits@low@x |
| 2346 |
\pgfplotsplothandlercontour@limits@high@y |
| 2347 |
\pgfplotsplothandlercontour@limits@low@z |
| 2348 |
}% |
| 2349 |
\pgfplotsplothandlercontour@streampoint{% |
| 2350 |
\pgfplotsplothandlerpointxyz |
| 2351 |
\pgfplotsplothandlercontour@limits@low@x |
| 2352 |
\pgfplotsplothandlercontour@limits@low@y |
| 2353 |
\pgfplotsplothandlercontour@limits@low@z |
| 2354 |
}% |
| 2355 |
\def\pgfplotsplothandlercontour@processed@outer{1}% |
| 2356 |
% |
| 2357 |
% restore labels: |
| 2358 |
\let\pgfplotsplothandlercontour@handlesplinesegment=\pgfplotsplothandlercontour@stream@bbcontour@oldlabelsetting |
| 2359 |
}% |
| 2360 |
\def\pgfplotsplothandlercontourplacelabels#1{% |
| 2361 |
\def\pgfplots@loc@TMPa{#1}% |
| 2362 |
\ifx\pgfplots@loc@TMPa\pgfplots@EOI |
| 2363 |
\else |
| 2364 |
% |
| 2365 |
\pgfplotsplothandlercontourplacelabels@act#1\relax |
| 2366 |
% |
| 2367 |
\expandafter\pgfplotsplothandlercontourplacelabels |
| 2368 |
\fi |
| 2369 |
}% |
| 2370 |
\def\pgfplotsplothandlercontourplacelabels@act#1,#2;#3,#4;#5\relax{% |
| 2371 |
\begingroup |
| 2372 |
\def\pgfplots@current@point@meta{#5}% |
| 2373 |
\pgfplotsaxisvisphasetransformpointmeta |
| 2374 |
\pgfplotscolormapdefinemappedcolor{\pgfplotspointmetatransformed}% |
| 2375 |
% |
| 2376 |
\pgftransformlineattime{0.5}{\pgfqpoint{#1}{#2}}{\pgfqpoint{#3}{#4}}% |
| 2377 |
\pgfkeysvalueof{/pgfplots/contour/label node code/.@cmd}#5\pgfeov |
| 2378 |
\endgroup |
| 2379 |
}% |
| 2380 |
|
| 2381 |
\def\pgfplotsplothandlercontour@streampoint#1{% |
| 2382 |
\pgf@process{#1}% |
| 2383 |
% remember point: |
| 2384 |
\edef\pgfplotsplothandlercontour@act@canvas{\pgf@x=\the\pgf@x\space\pgf@y=\the\pgf@y\space}% |
| 2385 |
% |
| 2386 |
\let\pgfplotsplothandlercontour@act@contour=\pgfplots@current@point@meta |
| 2387 |
\ifx\pgfplotsplothandlercontour@act@contour\pgfutil@empty |
| 2388 |
% oh. No Z data!? That should not happen! |
| 2389 |
\pgfplotsplothandlercontour@empty@pointmeta@error |
| 2390 |
\fi |
| 2391 |
\ifx\pgfplotsplothandlercontour@lastcontour\pgfutil@empty |
| 2392 |
% oh. its the very first point. |
| 2393 |
\def\pgfplotsplothandlercontour@haspendingjump{0}% important! (this is a different case than a jump) |
| 2394 |
\pgfplotsplothandlercontour@preparenewcontourline |
| 2395 |
\else |
| 2396 |
\ifx\pgfplotsplothandlercontour@lastcontour\pgfplotsplothandlercontour@act@contour |
| 2397 |
% belongs to the same contour. |
| 2398 |
\if1\pgfplotsplothandlercontour@haspendingjump |
| 2399 |
\pgfplotsplothandlercontour@finishcontourline |
| 2400 |
\pgfplotsplothandlercontour@preparenewcontourline |
| 2401 |
\fi |
| 2402 |
\else |
| 2403 |
% oh, a new contour line. |
| 2404 |
\def\pgfplotsplothandlercontour@haspendingjump{0}% important! (this is a different case than a jump) |
| 2405 |
\pgfplotsplothandlercontour@finishcontourline |
| 2406 |
\pgfplotsplothandlercontour@check@bbcontour |
| 2407 |
\pgfplotsplothandlercontour@preparenewcontourline |
| 2408 |
\fi |
| 2409 |
\fi |
| 2410 |
% |
| 2411 |
% |
| 2412 |
% handle difference vector for label placement: |
| 2413 |
\ifx\pgfplotsplothandlercontour@lastcanvas\pgfutil@empty |
| 2414 |
\else |
| 2415 |
\pgfplotsplothandlercontour@handlesplinesegment |
| 2416 |
{\pgfplotsplothandlercontour@lastcanvas} |
| 2417 |
{\pgfplotsplothandlercontour@act@canvas}% |
| 2418 |
{\pgfplotsplothandlercontour@act@contour}% |
| 2419 |
\fi |
| 2420 |
% |
| 2421 |
\pgfplotsplothandlercontour@handler@streampoint{\pgfplotsplothandlercontour@act@canvas}% |
| 2422 |
\let\pgfplotsplothandlercontour@lastlastcanvas=\pgfplotsplothandlercontour@lastcanvas |
| 2423 |
\let\pgfplotsplothandlercontour@lastcanvas=\pgfplotsplothandlercontour@act@canvas |
| 2424 |
\let\pgfplotsplothandlercontour@lastcontour=\pgfplotsplothandlercontour@act@contour |
| 2425 |
% |
| 2426 |
\ifpgfplotsplothandlercontour@filled |
| 2427 |
\t@pgfplots@toka=\expandafter{\expandafter{\pgfplotsplothandlercontour@act@canvas}}% |
| 2428 |
\expandafter\pgfplotsapplistXpushback\expandafter\pgf@plotstreampoint\the\t@pgfplots@toka |
| 2429 |
\to\pgfplotsplothandlercontour@stored@lastcontourpath |
| 2430 |
\fi |
| 2431 |
% |
| 2432 |
\ifx\pgf@plotstreampoint\pgfplotsplothandlercontour@streampoint |
| 2433 |
\else |
| 2434 |
\let\pgfplotsplothandlercontour@handler@streampoint=\pgf@plotstreampoint |
| 2435 |
\fi |
| 2436 |
\global\let\pgf@plotstreampoint=\pgfplotsplothandlercontour@streampoint |
| 2437 |
\global\let\pgf@plotstreamend=\pgfplotsplothandlercontour@streamend |
| 2438 |
% ATTENTION : if the low level plot handler introduces extra |
| 2439 |
% levels of scopes, this *will* fail! |
| 2440 |
}% |
| 2441 |
|
| 2442 |
% |
| 2443 |
% #1 : source |
| 2444 |
% #2 : target |
| 2445 |
% #3 : contour value |
| 2446 |
\def\pgfplotsplothandlercontour@handlesplinesegment@forlabels#1#2#3{% |
| 2447 |
#2% |
| 2448 |
\pgf@xb=\pgf@x |
| 2449 |
\pgf@yb=\pgf@y |
| 2450 |
#1% |
| 2451 |
\pgf@xc=\pgf@x |
| 2452 |
\pgf@yc=\pgf@y |
| 2453 |
\pgfpointdiff |
| 2454 |
{\pgf@x=\pgf@xc \pgf@y=\pgf@yc} |
| 2455 |
{\pgf@x=\pgf@xb \pgf@y=\pgf@yb}% |
| 2456 |
\edef\pgfplots@loc@TMPa{{\pgf@sys@tonumber\pgf@x}{\pgf@sys@tonumber\pgf@y}}% |
| 2457 |
\expandafter\pgfmath@basic@veclen@\pgfplots@loc@TMPa |
| 2458 |
\pgf@xa=\pgfmathresult pt |
| 2459 |
% |
| 2460 |
\advance\pgf@xa by\pgfplotsplothandlercontour@len\relax |
| 2461 |
\edef\pgfplotsplothandlercontour@len{\the\pgf@xa}% |
| 2462 |
%\message{contour(\pgfplotsplothandlercontour@act@contour): cur len=\pgfplotsplothandlercontour@len > \pgfplotsplothandlercontour@labeldist ? [segment from #1--#2];}% |
| 2463 |
\ifdim\pgf@xa>\pgfplotsplothandlercontour@labeldist\relax |
| 2464 |
\def\pgfplotsplothandlercontour@haslabel{1}% |
| 2465 |
\edef\pgfplots@loc@TMPa{{\the\pgf@xc,\the\pgf@yc;\the\pgf@xb,\the\pgf@yb;{#3}}}% |
| 2466 |
\expandafter\pgfplotsapplistXpushback\expandafter{\pgfplots@loc@TMPa}\to\pgfplotsplothandlercontour@storedlabels |
| 2467 |
\advance\pgf@xa by-\pgfplotsplothandlercontour@labeldist\relax |
| 2468 |
\edef\pgfplotsplothandlercontour@len{\the\pgf@xa\relax}% |
| 2469 |
\fi |
| 2470 |
}% |
| 2471 |
|
| 2472 |
% #1: the transformed point meta of the last contour. |
| 2473 |
\def\pgfplotsplothandlercontour@filled@assert@is@sorted#1{% |
| 2474 |
\ifx\pgfplotsplothandlercontour@lastcontour\pgfutil@empty |
| 2475 |
\else |
| 2476 |
\ifx\pgfplotsplothandlercontour@sequence@sort@cmp\pgfutil@empty |
| 2477 |
% we need to determine the sorting: |
| 2478 |
\pgfplotscoordmath{float}{if less than}{\pgfplotsplothandlercontour@lastcontour}{\pgfplots@current@point@meta}{% |
| 2479 |
\def\pgfplotsplothandlercontour@sequence@sort@cmp{+}% |
| 2480 |
}{% |
| 2481 |
\pgfplotscoordmath{float}{if less than}{\pgfplots@current@point@meta}{\pgfplotsplothandlercontour@lastcontour}{% |
| 2482 |
\def\pgfplotsplothandlercontour@sequence@sort@cmp{-}% |
| 2483 |
}{% |
| 2484 |
% undecided - the contours have the same label. |
| 2485 |
}% |
| 2486 |
}% |
| 2487 |
\else |
| 2488 |
\if +\pgfplotsplothandlercontour@sequence@sort@cmp |
| 2489 |
\pgfplotscoordmath{float}{if less than}{\pgfplots@current@point@meta}{\pgfplotsplothandlercontour@lastcontour}{% |
| 2490 |
\pgfplotsplothandlercontour@filled@assert@is@sorted@fail{ASCENDING}% |
| 2491 |
}{% |
| 2492 |
}% |
| 2493 |
\else |
| 2494 |
\pgfplotscoordmath{float}{if less than}{\pgfplotsplothandlercontour@lastcontour}{\pgfplots@current@point@meta}{% |
| 2495 |
\pgfplotsplothandlercontour@filled@assert@is@sorted@fail{DESCENDING}% |
| 2496 |
}{% |
| 2497 |
}% |
| 2498 |
\fi |
| 2499 |
\fi |
| 2500 |
\fi |
| 2501 |
}% |
| 2502 |
\def\pgfplotsplothandlercontour@filled@assert@is@sorted@fail#1{% |
| 2503 |
\begingroup |
| 2504 |
\pgfplotscoordmath{float}{tostring}{\pgfplots@current@point@meta}% |
| 2505 |
\let\offending=\pgfmathresult |
| 2506 |
\pgfplotscoordmath{float}{tostring}{\pgfplotsplothandlercontour@lastcontour}% |
| 2507 |
\let\lastcontour=\pgfmathresult |
| 2508 |
\pgfplots@error{Sorry, filled contours implicitly assume that the contour levels are SORTED (in the given case, they appear to be sorted in #1 order). Please make sure your input data has sorted contour levels. The offending level is \offending; the previous contour level is \lastcontour}% |
| 2509 |
\endgroup |
| 2510 |
} |
| 2511 |
\def\pgfplotsplothandlercontour@preparenewcontourline{% |
| 2512 |
\if0\pgfplotsplothandlercontour@haspendingjump |
| 2513 |
%\message{PREPARE NEW CONTOUR LEVEL (\pgfplots@current@point@meta).}% |
| 2514 |
% a completely new level has been |
| 2515 |
% started, not due to jumps inside of one level. |
| 2516 |
% |
| 2517 |
\let\pgfplotspointmetatransformed@lastcontour=\pgfplotspointmetatransformed |
| 2518 |
% thus, we need to compute 'mapped color': |
| 2519 |
\pgfplotsaxisvisphasetransformpointmeta |
| 2520 |
\pgfplotscolormapdefinemappedcolor{\pgfplotspointmetatransformed}% |
| 2521 |
\pgfsetstrokecolor{\pgfkeysvalueof{/pgfplots/contour/draw color}}% |
| 2522 |
\ifpgfplotsplothandlercontour@filled |
| 2523 |
\pgfplotsplothandlercontour@filled@assert@is@sorted{\pgfplotspointmetatransformed@lastcontour}% |
| 2524 |
\pgfsetfillcolor{\pgfkeysvalueof{/pgfplots/contour/fill color}}% |
| 2525 |
\fi |
| 2526 |
% |
| 2527 |
% furthermore, we need to handle the 'filled' style: |
| 2528 |
\ifpgfplotsplothandlercontour@filled |
| 2529 |
\pgfplotsapplistXlet\pgfplotsplothandlercontour@stored@lastcontourpath@=\pgfplotsplothandlercontour@stored@lastcontourpath |
| 2530 |
% flush: |
| 2531 |
\pgfplotsapplistXnewempty\pgfplotsplothandlercontour@stored@lastcontourpath |
| 2532 |
% |
| 2533 |
% process it: |
| 2534 |
\ifx\pgfplotsplothandlercontour@stored@lastcontourpath@\pgfutil@empty |
| 2535 |
% oh. This here is the very first contour. Nothing to do! |
| 2536 |
\else |
| 2537 |
% ok. This here is the i'th contour level, i>0. |
| 2538 |
% Thus, we have the 'i-1'th contour stored. |
| 2539 |
% REPLICATE its path to fill the space between the (i-1)'th contour and the i'th one! |
| 2540 |
\let\pgf@plotstreamstart=\pgfplotsplothandlercontour@handler@start |
| 2541 |
\pgf@plotstreamstart |
| 2542 |
\pgfplotsplothandlercontour@stored@lastcontourpath@ |
| 2543 |
\pgf@plotstreamend |
| 2544 |
\fi |
| 2545 |
\fi |
| 2546 |
\else |
| 2547 |
%\message{PREPARE NEW CONTOUR for the already begun level \pgfplots@current@point@meta.}% |
| 2548 |
\ifpgfplotsplothandlercontour@filled |
| 2549 |
\pgfplotsapplistXpushback\pgf@plotstreamstart\to\pgfplotsplothandlercontour@stored@lastcontourpath |
| 2550 |
\fi |
| 2551 |
\fi |
| 2552 |
% |
| 2553 |
\let\pgfplotsplothandlercontour@lastcanvas=\pgfutil@empty |
| 2554 |
\let\pgfplotsplothandlercontour@lastlastcanvas=\pgfutil@empty |
| 2555 |
\ifpgfplotsplothandlercontour@labels |
| 2556 |
\def\pgfplotsplothandlercontour@haslabel{0}% |
| 2557 |
% |
| 2558 |
% this here means that 20% of labeldist are already there. |
| 2559 |
% it moves the first label nearer to its start. |
| 2560 |
\pgf@xa=\pgfplotsplothandlercontour@labeldist\relax |
| 2561 |
\pgf@xa=0.2\pgf@xa |
| 2562 |
\edef\pgfplotsplothandlercontour@len{\the\pgf@xa}% |
| 2563 |
\fi |
| 2564 |
\def\pgfplotsplothandlercontour@haspendingjump{0}% |
| 2565 |
% |
| 2566 |
\pgfplotsplothandlercontour@handler@start |
| 2567 |
\let\pgfplotsplothandlercontour@handler@end=\pgf@plotstreamend |
| 2568 |
\let\pgfplotsplothandlercontour@handler@streampoint=\pgf@plotstreampoint |
| 2569 |
}% |
| 2570 |
\def\pgfplotsplothandlercontour@finishcontourline{% |
| 2571 |
\ifpgfplotsplothandlercontour@labels |
| 2572 |
\if0\pgfplotsplothandlercontour@haslabel |
| 2573 |
\ifx\pgfplotsplothandlercontour@lastlastcanvas\pgfutil@empty |
| 2574 |
\else |
| 2575 |
% force a label: |
| 2576 |
%\message{FORCING A LABEL for contour \pgfplotsplothandlercontour@lastcontour\space from (\pgfplotsplothandlercontour@lastlastcanvas --\pgfplotsplothandlercontour@lastcanvas)}% |
| 2577 |
\edef\pgfplotsplothandlercontour@len{\pgfplotsplothandlercontour@labeldist}% |
| 2578 |
\pgfplotsplothandlercontour@handlesplinesegment |
| 2579 |
{\pgfplotsplothandlercontour@lastlastcanvas} |
| 2580 |
{\pgfplotsplothandlercontour@lastcanvas}% |
| 2581 |
{\pgfplotsplothandlercontour@lastcontour}% |
| 2582 |
\fi |
| 2583 |
\fi |
| 2584 |
\fi |
| 2585 |
\pgfplotsplothandlercontour@handler@end |
| 2586 |
% |
| 2587 |
% \ifpgfplotsplothandlercontour@filled |
| 2588 |
% \pgfpathclose % FIXME this is, in general, not good enough. |
| 2589 |
% \fi |
| 2590 |
\if0\pgfplotsplothandlercontour@haspendingjump |
| 2591 |
%\message{usepath{} to finalize level \pgfplotsplothandlercontour@lastcontour.}% |
| 2592 |
% flush paths if the complete contour level is ready. |
| 2593 |
% do *not* flush paths if we have just a new part of the |
| 2594 |
% existing contour level. |
| 2595 |
% |
| 2596 |
% This makes a difference for the filled contour. |
| 2597 |
\ifpgfplotsplothandlercontour@filled |
| 2598 |
\pgfusepath{fill,stroke}% |
| 2599 |
\else |
| 2600 |
\pgfusepath{stroke}% |
| 2601 |
\fi |
| 2602 |
\else |
| 2603 |
%\message{usepath{} for level \pgfplotsplothandlercontour@lastcontour.}% |
| 2604 |
\ifpgfplotsplothandlercontour@filled |
| 2605 |
\pgfplotsapplistXpushback\pgf@plotstreamend\to\pgfplotsplothandlercontour@stored@lastcontourpath |
| 2606 |
\fi |
| 2607 |
\fi |
| 2608 |
}% |
| 2609 |
|
| 2610 |
\def\pgfplotsplothandlercontour@init@limits{% |
| 2611 |
\def\pgfplotsplothandlercontour@processed@outer{0}% |
| 2612 |
\let\pgfplotsplothandlercontour@limits@low@meta=\pgfutil@empty |
| 2613 |
\let\pgfplotsplothandlercontour@limits@low@x=\pgfutil@empty |
| 2614 |
\let\pgfplotsplothandlercontour@limits@low@y=\pgfutil@empty |
| 2615 |
\let\pgfplotsplothandlercontour@limits@low@z=\pgfutil@empty |
| 2616 |
\let\pgfplotsplothandlercontour@limits@high@meta=\pgfutil@empty |
| 2617 |
\let\pgfplotsplothandlercontour@limits@high@x=\pgfutil@empty |
| 2618 |
\let\pgfplotsplothandlercontour@limits@high@y=\pgfutil@empty |
| 2619 |
\let\pgfplotsplothandlercontour@limits@high@z=\pgfutil@empty |
| 2620 |
% |
| 2621 |
\pgfkeysgetvalue{/pgfplots/contour/data limits}\pgfplots@loc@TMPa |
| 2622 |
\ifx\pgfplots@loc@TMPa\pgfutil@empty |
| 2623 |
\def\pgfplotsplothandlercontour@processed@outer{1}% |
| 2624 |
\else |
| 2625 |
\expandafter\pgfplotsplothandlercontour@init@limits@getboundingboxlow\pgfplots@loc@TMPa\pgfplots@EOI |
| 2626 |
\fi |
| 2627 |
%\message{contour: I processed data limits to MIN = (\pgfplotsplothandlercontour@limits@low@x,\pgfplotsplothandlercontour@limits@low@y,\pgfplotsplothandlercontour@limits@low@z;\pgfplotsplothandlercontour@limits@low@meta) and MAX = (\pgfplotsplothandlercontour@limits@high@x,\pgfplotsplothandlercontour@limits@high@y,\pgfplotsplothandlercontour@limits@high@z;\pgfplotsplothandlercontour@limits@high@meta).}% |
| 2628 |
}% |
| 2629 |
\def\pgfplotsplothandlercontour@init@limits@getboundingboxlow(#1,#2,#3,#4){% |
| 2630 |
\def\pgfplotsplothandlercontour@init@limits@cur{low}% |
| 2631 |
\pgfplotsplothandlercontour@init@limits@read(#1,#2,#3,#4)% |
| 2632 |
\pgfutil@ifnextchar(% |
| 2633 |
\pgfplotsplothandlercontour@init@limits@getboundingboxhigh |
| 2634 |
{\pgfplots@error{Sorry, 'data limits=(xmin,ymin,zmin,contourmin) (xmax,ymax,zmax,contourmax)' has been expected, not \pgfkeysvalueof{/pgfplots/contour/data limits}}\pgfplots@gobble@until@EOI}% |
| 2635 |
}% |
| 2636 |
\def\pgfplotsplothandlercontour@init@limits@getboundingboxhigh(#1,#2,#3,#4){% |
| 2637 |
\def\pgfplotsplothandlercontour@init@limits@cur{high}% |
| 2638 |
\pgfplotsplothandlercontour@init@limits@read(#1,#2,#3,#4)% |
| 2639 |
\pgfutil@gobble |
| 2640 |
}% |
| 2641 |
\def\pgfplotsplothandlercontour@init@limits@read(#1,#2,#3,#4){% |
| 2642 |
% FIXME : logs and trafos and user interface! |
| 2643 |
\pgfplotscoordmath{x}{parsenumber}{#1}% |
| 2644 |
\pgfplotscoordmath{x}{datascaletrafo}\pgfmathresult |
| 2645 |
\expandafter\let\csname pgfplotsplothandlercontour@limits@\pgfplotsplothandlercontour@init@limits@cur @x\endcsname=\pgfmathresult |
| 2646 |
% |
| 2647 |
\pgfplotscoordmath{y}{parsenumber}{#2}% |
| 2648 |
\pgfplotscoordmath{y}{datascaletrafo}\pgfmathresult |
| 2649 |
\expandafter\let\csname pgfplotsplothandlercontour@limits@\pgfplotsplothandlercontour@init@limits@cur @y\endcsname=\pgfmathresult |
| 2650 |
% |
| 2651 |
\ifpgfplots@curplot@threedim |
| 2652 |
\pgfplotscoordmath{z}{parsenumber}{#3}% |
| 2653 |
\pgfplotscoordmath{z}{datascaletrafo}\pgfmathresult |
| 2654 |
\expandafter\let\csname pgfplotsplothandlercontour@limits@\pgfplotsplothandlercontour@init@limits@cur @z\endcsname=\pgfmathresult |
| 2655 |
\fi |
| 2656 |
% |
| 2657 |
\pgfplotscoordmath{meta}{parsenumber}{#4}% |
| 2658 |
\expandafter\let\csname pgfplotsplothandlercontour@limits@\pgfplotsplothandlercontour@init@limits@cur @meta\endcsname=\pgfmathresult |
| 2659 |
}% |
| 2660 |
|
| 2661 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 2662 |
% |
| 2663 |
% contour external implementation |
| 2664 |
% |
| 2665 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 2666 |
|
| 2667 |
\def\pgfplotsplothandlercontourexternal{% |
| 2668 |
\pgfplotsresetplothandler |
| 2669 |
\def\pgfplotsplothandlername{contour external}% |
| 2670 |
% |
| 2671 |
\pgfplotsplothandlercontour@prepare@point@meta |
| 2672 |
% |
| 2673 |
\let\pgfplotsplothandlersurveystart=\pgfplotsplothandlersurveystart@contourexternal |
| 2674 |
\def\pgf@plotstreamstart{% |
| 2675 |
\pgfplotsplothandlercontourprepared |
| 2676 |
\pgf@plotstreamstart |
| 2677 |
}% |
| 2678 |
}% |
| 2679 |
\gdef\c@pgfplotsplothandlersurveystart@contourexternal@fileno{0}% |
| 2680 |
\def\pgfplotsplothandlersurveystart@contourexternal{% |
| 2681 |
% |
| 2682 |
\pgfkeysgetvalue{/pgfplots/contour external/file}\pgfplotsplothandlercontourexternal@file |
| 2683 |
% |
| 2684 |
\ifx\pgfplotsplothandlercontourexternal@file\pgfutil@empty |
| 2685 |
\pgfutil@ifundefined{pgfactualjobname}{% |
| 2686 |
\let\pgfplots@loc@TMPa=\jobname |
| 2687 |
}{% |
| 2688 |
% be compatible with external lib: |
| 2689 |
\let\pgfplots@loc@TMPa=\pgfactualjobname |
| 2690 |
}% |
| 2691 |
\edef\pgfplotsplothandlercontourexternal@file{\pgfplots@loc@TMPa_contourtmp\c@pgfplotsplothandlersurveystart@contourexternal@fileno}% |
| 2692 |
\pgfplotsutil@advancestringcounter@global\c@pgfplotsplothandlersurveystart@contourexternal@fileno |
| 2693 |
\fi |
| 2694 |
% |
| 2695 |
\if0\pgfplotsplothandlercontourexternal@scanlinemode |
| 2696 |
\pgfplotsset{plot to file/scanline marks/false}% |
| 2697 |
\else |
| 2698 |
\pgfplotsset{plot to file/scanline marks/if in input}% the choice 'always' is unaware of existing end-of-scanline marks |
| 2699 |
\fi |
| 2700 |
% |
| 2701 |
\pgfplotsplothandlertofile{\[email protected]}% |
| 2702 |
\pgfplotsplothandlersurveystart |
| 2703 |
\let\pgfplotsplothandlersurveypoint@tofile=\pgfplotsplothandlersurveypoint |
| 2704 |
\let\pgfplotsplothandlersurveyend@tofile=\pgfplotsplothandlersurveyend |
| 2705 |
\let\pgfplotsplothandlersurveypoint=\pgfplotsplothandlersurveypoint@contourexternal |
| 2706 |
\let\pgfplotsplothandlersurveyend=\pgfplotsplothandlersurveyend@contourexternal |
| 2707 |
% |
| 2708 |
\pgfplotsplothandlersurveypoint@contour@prepare@axes x% |
| 2709 |
\pgfplotsplothandlersurveypoint@contour@prepare@axes y% |
| 2710 |
\pgfplotsplothandlersurveypoint@contour@prepare@axes z% |
| 2711 |
% |
| 2712 |
\global\let\pgfplotsplothandlercontourexternal@metamin=\relax |
| 2713 |
\global\let\pgfplotsplothandlercontourexternal@metamax=\relax |
| 2714 |
% |
| 2715 |
}% |
| 2716 |
|
| 2717 |
% #1: either x, y, or z |
| 2718 |
% POSTCONDITION: |
| 2719 |
% The following three macros are defined: |
| 2720 |
% \pgfplotsplothandlersurveypoint@contour@set@axes@x |
| 2721 |
% \pgfplotsplothandlersurveypoint@contour@set@axes@y |
| 2722 |
% \pgfplotsplothandlersurveypoint@contour@set@axes@z |
| 2723 |
% they take no arguments and assign their result to \pgfmathresult. |
| 2724 |
\def\pgfplotsplothandlersurveypoint@contour@prepare@axes#1{% |
| 2725 |
\expandafter\edef\csname pgfplotsplothandlersurveypoint@contour@set@axes@#1\endcsname{% |
| 2726 |
\noexpand\let\noexpand\pgfmathresult=\expandafter\noexpand\csname pgfplots@current@point@\csname pgfplotsplothandlercontour@axis@#1\endcsname\endcsname |
| 2727 |
}% |
| 2728 |
\expandafter\edef\csname pgfplotsplothandlersurveypoint@contour@set@axes@@#1\endcsname{% |
| 2729 |
\noexpand\let\noexpand\pgfmathresult=\expandafter\noexpand\csname pgfplots@current@point@\csname pgfplotsplothandlercontour@axis@inv@#1\endcsname\endcsname |
| 2730 |
}% |
| 2731 |
% |
| 2732 |
%\message{axes #1: STD -> \expandafter\meaning\csname pgfplotsplothandlersurveypoint@contour@set@axes@#1\endcsname^^J}% |
| 2733 |
%\message{axes #1: INV -> \expandafter\meaning\csname pgfplotsplothandlersurveypoint@contour@set@axes@@#1\endcsname^^J}% |
| 2734 |
} |
| 2735 |
|
| 2736 |
\def\pgfplotsplothandlersurveypoint@contour@axes@reordered@to@std{% |
| 2737 |
\pgfplotsplothandlersurveypoint@contour@set@axes@@x |
| 2738 |
\let\pgfplotsplothandlersurveypoint@contour@set@axes@x@=\pgfmathresult |
| 2739 |
% |
| 2740 |
\pgfplotsplothandlersurveypoint@contour@set@axes@@y |
| 2741 |
\let\pgfplotsplothandlersurveypoint@contour@set@axes@y@=\pgfmathresult |
| 2742 |
% |
| 2743 |
\pgfplotsplothandlersurveypoint@contour@set@axes@@z |
| 2744 |
\let\pgfplotsplothandlersurveypoint@contour@set@axes@z@=\pgfmathresult |
| 2745 |
% |
| 2746 |
\let\pgfplots@current@point@x=\pgfplotsplothandlersurveypoint@contour@set@axes@x@ |
| 2747 |
\let\pgfplots@current@point@y=\pgfplotsplothandlersurveypoint@contour@set@axes@y@ |
| 2748 |
\let\pgfplots@current@point@z=\pgfplotsplothandlersurveypoint@contour@set@axes@z@ |
| 2749 |
}% |
| 2750 |
\def\pgfplotsplothandlersurveypoint@contour@axes@std@to@reordered{% |
| 2751 |
\pgfplotsplothandlersurveypoint@contour@set@axes@x |
| 2752 |
\let\pgfplotsplothandlersurveypoint@contour@set@axes@x@=\pgfmathresult |
| 2753 |
% |
| 2754 |
\pgfplotsplothandlersurveypoint@contour@set@axes@y |
| 2755 |
\let\pgfplotsplothandlersurveypoint@contour@set@axes@y@=\pgfmathresult |
| 2756 |
% |
| 2757 |
\pgfplotsplothandlersurveypoint@contour@set@axes@z |
| 2758 |
\let\pgfplotsplothandlersurveypoint@contour@set@axes@z@=\pgfmathresult |
| 2759 |
% |
| 2760 |
\let\pgfplots@current@point@x=\pgfplotsplothandlersurveypoint@contour@set@axes@x@ |
| 2761 |
\let\pgfplots@current@point@y=\pgfplotsplothandlersurveypoint@contour@set@axes@y@ |
| 2762 |
\let\pgfplots@current@point@z=\pgfplotsplothandlersurveypoint@contour@set@axes@z@ |
| 2763 |
}% |
| 2764 |
|
| 2765 |
\def\pgfplotsplothandlersurveypoint@contourexternal{% |
| 2766 |
\ifx\pgfplotsplothandlercontourexternal@metamin\relax |
| 2767 |
% remember values. We want to restore them right before we parse the output of contour external: |
| 2768 |
\global\let\pgfplotsplothandlercontourexternal@metamin=\pgfplots@metamin |
| 2769 |
\global\let\pgfplotsplothandlercontourexternal@metamax=\pgfplots@metamax |
| 2770 |
\fi |
| 2771 |
\pgfplotsplothandlersurveypoint@contour@axes@std@to@reordered |
| 2772 |
% |
| 2773 |
\pgfplotsaxissurveysetpointmeta |
| 2774 |
% |
| 2775 |
\if M\pgfplotsplothandlercontourexternal@script@input@format |
| 2776 |
\let\pgfplots@current@point@z=\pgfplots@current@point@meta |
| 2777 |
\fi |
| 2778 |
% |
| 2779 |
% |
| 2780 |
%\message{contour external collecting point (\pgfplots@current@point@x,\pgfplots@current@point@y,\pgfplots@current@point@z) [\pgfplots@current@point@meta]...}% |
| 2781 |
\pgfplotsplothandlersurveypoint@tofile |
| 2782 |
}% |
| 2783 |
|
| 2784 |
% Utility function which is NOT normally invoked. It can be invoked inside of 'contour external/@before cmd'. Should it become the default? |
| 2785 |
\def\pgfplotscontourpopulateallkeys{% |
| 2786 |
\pgfkeysgetvalue{/pgfplots/contour/levels}\pgfplots@loc@TMPa |
| 2787 |
\ifx\pgfplots@loc@TMPa\pgfutil@empty |
| 2788 |
\ifx\pgfplots@metamax\pgfutil@empty |
| 2789 |
\else |
| 2790 |
\edef\pgfplots@loc@TMPa{\pgfplots@metamin:\pgfplots@metamax}% |
| 2791 |
\edef\thecontournumber{\pgfkeysvalueof{/pgfplots/contour/number}}% |
| 2792 |
\expandafter\pgfplots@domain@to@foreach\pgfplots@loc@TMPa\relax{\thecontournumber}% |
| 2793 |
\expandafter\pgfplots@foreach@to@list@macro\expandafter{\pgfplotsretval}% |
| 2794 |
\pgfkeyslet{/pgfplots/contour/levels}\pgfplotsretval |
| 2795 |
\fi |
| 2796 |
\fi |
| 2797 |
}% |
| 2798 |
|
| 2799 |
{ |
| 2800 |
\catcode`\`=12 |
| 2801 |
\catcode`\'=12 |
| 2802 |
\catcode`\"=12 |
| 2803 |
\catcode`\|=12 |
| 2804 |
\catcode`\;=12 |
| 2805 |
\catcode`\:=12 |
| 2806 |
\catcode`\#=12 |
| 2807 |
\gdef\pgfplotsplothandlersurveyend@contourexternal{% |
| 2808 |
\pgfplotsplothandlersurveyend@tofile |
| 2809 |
\if2\pgfplotsplothandlercontourexternal@scanlinemode |
| 2810 |
\if0\pgfplotsplothandlertofilegeneratedscanlinemarks |
| 2811 |
\pgfplots@error{Sorry, processing the input stream did not lead to end-of-scanline markers; the generated temporary file for 'contour external' does not contain any of them (indicating that matrix structure is lost). To fix this, you have the following options:^^J - Insert end-of-scanline markers into your input data (i.e. empty lines),^^J - provide two of the three options 'mesh/rows=<num matrix rows>, mesh/cols=<num matrix cols>, mesh/num points=<total number points>'}% |
| 2812 |
\fi |
| 2813 |
\fi |
| 2814 |
% |
| 2815 |
\pgfkeysvalueof{/pgfplots/contour external/@before cmd}\relax% |
| 2816 |
\begingroup |
| 2817 |
\let\numcoords=\pgfplots@current@point@coordindex% |
| 2818 |
\pgfplotsautocompletemeshkeys |
| 2819 |
\def\"{"}% |
| 2820 |
\def\|{|}% |
| 2821 |
\def\;{;}% |
| 2822 |
\def\:{:}% |
| 2823 |
\def\#{#}% |
| 2824 |
\def\'{'}% |
| 2825 |
\def\`{`}% |
| 2826 |
\edef\ordering{\pgfplots@plot@mesh@ordering}% |
| 2827 |
\edef\infile{\[email protected]}% |
| 2828 |
\edef\outfile{\[email protected]}% |
| 2829 |
% |
| 2830 |
\pgfkeysgetvalue{/pgfplots/contour external/cmd}\cmd |
| 2831 |
\pgfkeysgetvalue{/pgfplots/contour external/script extension}\scriptext |
| 2832 |
\if S\pgfplotsplothandlercontourexternal@script@type |
| 2833 |
\else |
| 2834 |
% script type=lua |
| 2835 |
\ifx\cmd\pgfutil@empty |
| 2836 |
\pgfkeyssetvalue{/pgfplots/contour external/cmd}{require(\"\scriptbase\")}% |
| 2837 |
\pgfkeysgetvalue{/pgfplots/contour external/cmd}\cmd |
| 2838 |
\fi |
| 2839 |
\fi |
| 2840 |
% |
| 2841 |
\pgfplotscoordmath{meta}{tofixed}{\pgfplots@metamin}% |
| 2842 |
\let\pgfplotsmetamin=\pgfmathresult |
| 2843 |
\pgfplotscoordmath{meta}{tofixed}{\pgfplots@metamax}% |
| 2844 |
\let\pgfplotsmetamax=\pgfmathresult |
| 2845 |
% |
| 2846 |
\edef\script{\pgfplotsplothandlercontourexternal@file.\scriptext}% |
| 2847 |
\edef\scriptbase{\pgfplotsplothandlercontourexternal@file}% |
| 2848 |
\edef\thecontourlevels{\pgfkeysvalueof{/pgfplots/contour/levels}}% |
| 2849 |
\edef\thecontournumber{\pgfkeysvalueof{/pgfplots/contour/number}}% |
| 2850 |
\immediate\openout\w@pgf@writea=\script |
| 2851 |
\immediate\write\w@pgf@writea{\pgfkeysvalueof{/pgfplots/contour external/script}}% |
| 2852 |
\immediate\closeout\w@pgf@writea |
| 2853 |
% |
| 2854 |
\if S\pgfplotsplothandlercontourexternal@script@type |
| 2855 |
\pgfplots@shellescape{\cmd}% |
| 2856 |
\else |
| 2857 |
\ifpgfplots@LUA@supported |
| 2858 |
\pgfplotsutil@directlua{\pgfkeysvalueof{/pgfplots/contour external/cmd}}% |
| 2859 |
\else |
| 2860 |
\pgfplots@error{Calls to 'lua' are currently unsupported. Please invoke lualatex instead.}% |
| 2861 |
\fi |
| 2862 |
\fi |
| 2863 |
\pgfkeysvalueof{/pgfplots/contour external/@after cmd}\relax% |
| 2864 |
\endgroup |
| 2865 |
% |
| 2866 |
% RESET point meta computation here such that it can be collected from the 'contour prepared' stream (i.e. the output of contour external): |
| 2867 |
\global\let\pgfplots@metamin=\pgfplotsplothandlercontourexternal@metamin |
| 2868 |
\global\let\pgfplots@metamax=\pgfplotsplothandlercontourexternal@metamax |
| 2869 |
% |
| 2870 |
\pgfplotsplothandlercontourprepared |
| 2871 |
% the PREPARE steps in the coord stream start/end have already |
| 2872 |
% been done. we only need to init the plot handler survey |
| 2873 |
% start/end: |
| 2874 |
\def\pgfplots@coord@stream@start{\pgfplotsplothandlersurveystart}% |
| 2875 |
\def\pgfplots@coord@stream@end{\pgfplotsplothandlersurveyend}% |
| 2876 |
\pgfkeysgetvalue{/pgfplots/contour external/output point meta}\pgfplots@loc@TMPa |
| 2877 |
\ifx\pgfplots@loc@TMPa\pgfutil@empty |
| 2878 |
\ifpgfplots@curplot@threedim |
| 2879 |
\pgfplotssetpointmetainput{z}{}% |
| 2880 |
\else |
| 2881 |
\pgfplotssetpointmetainput{explicit}{}% |
| 2882 |
\fi |
| 2883 |
\else |
| 2884 |
\expandafter\pgfplots@pgfkeys@set@point@meta@value\expandafter{\pgfplots@loc@TMPa}% |
| 2885 |
\fi |
| 2886 |
\pgfplots@addplotimpl@file@streamit{\[email protected]}% |
| 2887 |
\closein\r@pgfplots@reada |
| 2888 |
}% |
| 2889 |
} |
| 2890 |
|
| 2891 |
|
| 2892 |
|
| 2893 |
|
| 2894 |
|
| 2895 |
% the `plot unprocessed to file' plot handler simply copies the input data |
| 2896 |
% UNPROCESSED to an output file. |
| 2897 |
% |
| 2898 |
% I use it as helper tool for `contour gnuplot'. |
| 2899 |
% |
| 2900 |
% this cannot be combined with other plot handlers unless the other |
| 2901 |
% plot handlers controls that explicitly |
| 2902 |
% |
| 2903 |
% Immediately after the survey ends, this plot handler will set |
| 2904 |
% \pgfplotsplothandlertofilegeneratedscanlinemarks to '1' or '0'. |
| 2905 |
\pgfplotsset{ |
| 2906 |
plot unprocessed to file/.code={ |
| 2907 |
\edef\tikz@plot@handler{\noexpand\pgfplotsplothandlertofile{#1}}% |
| 2908 |
}, |
| 2909 |
plot to file/scanline marks/.is choice, |
| 2910 |
plot to file/scanline marks/false/.code={\def\pgfplotsplothandlertofile@scanlinemarks{0}}, |
| 2911 |
plot to file/scanline marks/if in input/.code={\def\pgfplotsplothandlertofile@scanlinemarks{1}}, |
| 2912 |
plot to file/scanline marks/always/.code={\def\pgfplotsplothandlertofile@scanlinemarks{2}}, |
| 2913 |
plot to file/scanline marks/true/.code={\def\pgfplotsplothandlertofile@scanlinemarks{2}}, |
| 2914 |
plot to file/scanline marks/if in input, |
| 2915 |
plot to file/col sep/.initial=\pgfplots@SPACE, |
| 2916 |
plot to file/end-of-scanline content/.initial=, |
| 2917 |
} |
| 2918 |
|
| 2919 |
\def\pgfplotsplothandlertofile#1{% |
| 2920 |
\edef\pgfplotsplothandlertofile@name{#1}% |
| 2921 |
\pgfplotsresetplothandler |
| 2922 |
\pgfplotsset{empty line=scanline}% |
| 2923 |
\let\pgfplotsplothandlersurveystart=\pgfplotsplothandlersurveystart@tofile |
| 2924 |
\def\pgfplotsplothandlername{plot to file}% |
| 2925 |
\let\pgfplotsplothandlersurveyend=\pgfplotsplothandlersurveyend@tofile |
| 2926 |
\let\pgfplotsplothandlersurveypoint=\pgfplotsplothandlersurveypoint@tofile |
| 2927 |
\let\pgfplotsplothandlernotifyscanlinecomplete=\pgfplotsplothandlernotifyscanlinecomplete@tofile |
| 2928 |
% |
| 2929 |
\if1\pgfplotsplothandlertofile@scanlinemarks |
| 2930 |
% plot to file/scanline marks=if in input |
| 2931 |
% check if we have mesh input: |
| 2932 |
\def\pgfplots@loc@TMP@has@mesh@information{0}% |
| 2933 |
\pgfkeysgetvalue{/pgfplots/mesh/rows}\pgfplots@loc@TMPa |
| 2934 |
\pgfkeysgetvalue{/pgfplots/mesh/cols}\pgfplots@loc@TMPb |
| 2935 |
\pgfkeysgetvalue{/pgfplots/mesh/num points}\pgfplots@loc@TMPc |
| 2936 |
\ifx\pgfplots@loc@TMPa\pgfutil@empty |
| 2937 |
\ifx\pgfplots@loc@TMPc\pgfutil@empty |
| 2938 |
\else |
| 2939 |
% has rows and num points: |
| 2940 |
\def\pgfplots@loc@TMP@has@mesh@information{1}% |
| 2941 |
\fi |
| 2942 |
\else |
| 2943 |
\ifx\pgfplots@loc@TMPb\pgfutil@empty |
| 2944 |
\ifx\pgfplots@loc@TMPc\pgfutil@empty |
| 2945 |
\else |
| 2946 |
% has cols and num points: |
| 2947 |
\def\pgfplots@loc@TMP@has@mesh@information{1}% |
| 2948 |
\fi |
| 2949 |
\else |
| 2950 |
% has rows,cols: |
| 2951 |
\def\pgfplots@loc@TMP@has@mesh@information{1}% |
| 2952 |
\fi |
| 2953 |
\fi |
| 2954 |
\if1\pgfplots@loc@TMP@has@mesh@information |
| 2955 |
% activate 'plot to file/scanline marks=always |
| 2956 |
% --> we have the required information! |
| 2957 |
\def\pgfplotsplothandlertofile@scanlinemarks{2}% |
| 2958 |
\fi |
| 2959 |
\fi |
| 2960 |
% NO \else here! |
| 2961 |
\if2\pgfplotsplothandlertofile@scanlinemarks |
| 2962 |
% plot to file/scanline marks=always |
| 2963 |
\pgfplotsautocompletemeshkeys% |
| 2964 |
\def\c@pgfplotsplothandlertofile@scanlinelength{0}% |
| 2965 |
\if\pgfplots@plot@mesh@ordering0% |
| 2966 |
% ordering = x varies= rowwise -> scanline is cols! |
| 2967 |
\pgfkeysgetvalue{/pgfplots/mesh/cols}\c@pgfplotsplothandlertofile@expectedscanline |
| 2968 |
\else |
| 2969 |
% ordering = y varies = colwise: scanline is rows! |
| 2970 |
\pgfkeysgetvalue{/pgfplots/mesh/rows}\c@pgfplotsplothandlertofile@expectedscanline |
| 2971 |
\fi |
| 2972 |
\fi |
| 2973 |
\pgfplotsplothandlertofile@scanlinependingfalse |
| 2974 |
\pgfkeysgetvalue{/pgfplots/plot to file/col sep}\pgfplotsplothandlertofile@colsep |
| 2975 |
\pgfkeysgetvalue{/pgfplots/plot to file/end-of-scanline content}\pgfplotsplothandlertofile@scanlinemark |
| 2976 |
% |
| 2977 |
% |
| 2978 |
\def\pgfplotsplothandlertofilegeneratedscanlinemarks{0}% |
| 2979 |
}% |
| 2980 |
\def\pgfplotsplothandlertofile@scanlinemarks@check{% |
| 2981 |
\if2\pgfplotsplothandlertofile@scanlinemarks |
| 2982 |
% plot to file/scanline marks=always |
| 2983 |
\pgfplotsutil@advancestringcounter\c@pgfplotsplothandlertofile@scanlinelength |
| 2984 |
\ifnum\c@pgfplotsplothandlertofile@scanlinelength=\c@pgfplotsplothandlertofile@expectedscanline |
| 2985 |
\def\c@pgfplotsplothandlertofile@scanlinelength{0}% |
| 2986 |
\pgfplotsplothandlernotifyscanlinecomplete@tofile |
| 2987 |
\fi |
| 2988 |
\fi |
| 2989 |
}% |
| 2990 |
\newif\ifpgfplotsplothandlertofile@scanlinepending |
| 2991 |
\def\pgfplotsplothandlernotifyscanlinecomplete@tofile{% |
| 2992 |
\if0\pgfplotsplothandlertofile@scanlinemarks |
| 2993 |
\else |
| 2994 |
\pgfplotsplothandlertofile@scanlinependingtrue |
| 2995 |
\fi |
| 2996 |
}% |
| 2997 |
\def\pgfplotsplothandlersurveypoint@tofile{% |
| 2998 |
\ifpgfplotsplothandlertofile@scanlinepending |
| 2999 |
\def\pgfplotsplothandlertofilegeneratedscanlinemarks{1}% |
| 3000 |
\immediate\write\w@pgf@writea{\pgfplotsplothandlertofile@scanlinemark}% end-of-scanline |
| 3001 |
\pgfplotsplothandlertofile@scanlinependingfalse |
| 3002 |
\fi |
| 3003 |
\pgfplotscoordmath{x}{parsenumber}{\pgfplots@current@point@x}% |
| 3004 |
\pgfplotscoordmath{x}{tostring}{\pgfmathresult}% |
| 3005 |
\let\pgfplots@current@point@x=\pgfmathresult |
| 3006 |
% |
| 3007 |
\pgfplotscoordmath{y}{parsenumber}{\pgfplots@current@point@y}% |
| 3008 |
\pgfplotscoordmath{y}{tostring}{\pgfmathresult}% |
| 3009 |
\let\pgfplots@current@point@y=\pgfmathresult |
| 3010 |
% |
| 3011 |
\ifpgfplots@curplot@threedim |
| 3012 |
\pgfplotscoordmath{z}{parsenumber}{\pgfplots@current@point@z}% |
| 3013 |
\pgfplotscoordmath{z}{tostring}{\pgfmathresult}% |
| 3014 |
\let\pgfplots@current@point@z=\pgfmathresult |
| 3015 |
\fi |
| 3016 |
% |
| 3017 |
\pgfplotsaxissurveysetpointmeta |
| 3018 |
\pgfplotsaxisifhaspointmeta{% |
| 3019 |
\pgfplotscoordmath{meta}{tostring}{\pgfplots@current@point@meta}% |
| 3020 |
\let\pgfplots@current@point@meta=\pgfmathresult |
| 3021 |
}{}% |
| 3022 |
% |
| 3023 |
\immediate\write\w@pgf@writea{% |
| 3024 |
\pgfplots@current@point@x\pgfplotsplothandlertofile@colsep |
| 3025 |
\pgfplots@current@point@y\pgfplotsplothandlertofile@colsep |
| 3026 |
\ifpgfplots@curplot@threedim\pgfplots@current@point@z\pgfplotsplothandlertofile@colsep\fi |
| 3027 |
\pgfplots@current@point@meta |
| 3028 |
}% |
| 3029 |
\advance\c@pgfplots@coordindex by1 |
| 3030 |
\pgfplotsplothandlertofile@scanlinemarks@check |
| 3031 |
}% |
| 3032 |
\def\pgfplotsplothandlersurveyend@tofile{% |
| 3033 |
\immediate\closeout\w@pgf@writea |
| 3034 |
}% |
| 3035 |
\def\pgfplotsplothandlersurveystart@tofile{% |
| 3036 |
\immediate\openout\w@pgf@writea=\pgfplotsplothandlertofile@name\relax |
| 3037 |
}% |
| 3038 |
|
| 3039 |
|
| 3040 |
\input pgfplotsmeshplothandler.code.tex |
| 3041 |
% |
| 3042 |
%-------------------------------------------- |
| 3043 |
|
| 3044 |
|
| 3045 |
% Implementation of 'contour filled': it is actually just a small |
| 3046 |
% wrapper around 'surf,shader=interp,colormap access=const' -- with |
| 3047 |
% dedicated color map definitions. |
| 3048 |
\def\pgfplotsplothandlercontourfilled{% |
| 3049 |
\pgfplotsplothandlermesh |
| 3050 |
\let\pgfplotsplothandlersurveyend@contourfilled@orig=\pgfplotsplothandlersurveyend |
| 3051 |
\def\pgfplotsplothandlersurveyend{% |
| 3052 |
\pgfplotsplothandlersurveyend@contourfilled@orig |
| 3053 |
\pgfplotsplothandlersurveyend@contourfilled |
| 3054 |
}% |
| 3055 |
}% |
| 3056 |
|
| 3057 |
\def\pgfplotscontourfilledcolormap{internal:contourfilled} |
| 3058 |
\pgfplotscreatecolormap{\pgfplotscontourfilledcolormap}{color=(black) color=(black)} |
| 3059 |
|
| 3060 |
\def\pgfplotsplothandlersurveyend@contourfilled{% |
| 3061 |
\pgfplotsplothandlersurveyaddoptions{ |
| 3062 |
% ensure that the point meta of the contour makes its way into |
| 3063 |
% the colorbar and the associated color mapping. |
| 3064 |
% |
| 3065 |
% FIXME: that fails if there are more than one contours in the |
| 3066 |
% same axis (or someone else uses 'colorbar source') |
| 3067 |
colorbar source,% |
| 3068 |
% |
| 3069 |
% ensure that other plots to not "corrupt" our mapping: |
| 3070 |
point meta rel=per plot,% |
| 3071 |
}% |
| 3072 |
\def\pgfplots@contour@cm@options{% |
| 3073 |
colorbar style={% |
| 3074 |
/pgfplots/colormap access=const, |
| 3075 |
},% |
| 3076 |
}% |
| 3077 |
% |
| 3078 |
\pgfkeysgetvalue{/pgfplots/contour/levels}\pgfplots@loc@TMPa |
| 3079 |
\ifx\pgfplots@loc@TMPa\pgfutil@empty |
| 3080 |
% no levels. |
| 3081 |
% Ok, check the other keys in the order of precedence: |
| 3082 |
\pgfkeysgetvalue{/pgfplots/contour/levels from colormap}\pgfplots@loc@TMPa |
| 3083 |
\ifx\pgfplots@loc@TMPa\pgfutil@empty |
| 3084 |
% no 'levels from colormap'. |
| 3085 |
% Ok, check the other keys in the order of precedence: |
| 3086 |
\pgfkeysgetvalue{/pgfplots/contour/number}\pgfplots@loc@TMPa |
| 3087 |
\ifx\pgfplots@loc@TMPa\pgfutil@empty |
| 3088 |
% not sure if this is a use-case... |
| 3089 |
\pgfplots@log3{contour plot: skipping definition of suitable colormap (none of 'number', levels', 'levels from colormap' is set)}% |
| 3090 |
\t@pgfplots@toka=\expandafter{\pgfplots@contour@cm@options}% |
| 3091 |
\edef\pgfplots@contour@cm@options{% |
| 3092 |
\the\t@pgfplots@toka% |
| 3093 |
% just copy the current colormap to ensure that it |
| 3094 |
% has the correct name: |
| 3095 |
colormap={\pgfplotscontourfilledcolormap}{of colormap={}},% |
| 3096 |
}% |
| 3097 |
\else |
| 3098 |
% Ah -- we have a number of samples! |
| 3099 |
\t@pgfplots@toka=\expandafter{\pgfplots@contour@cm@options}% |
| 3100 |
\edef\pgfplots@contour@cm@options{% |
| 3101 |
\the\t@pgfplots@toka% |
| 3102 |
colormap={\pgfplotscontourfilledcolormap}{samples of colormap={\pgfplots@loc@TMPa}},% |
| 3103 |
}% |
| 3104 |
\fi |
| 3105 |
\else |
| 3106 |
% Ah - we want to take levels from a colormap definition! |
| 3107 |
% We only need to ensure that the colormap definition fits |
| 3108 |
% into the range [metamin:metamax]. Do that here: |
| 3109 |
\t@pgfplots@toka=\expandafter{\pgfplots@contour@cm@options}% |
| 3110 |
\t@pgfplots@tokb=\expandafter{\pgfplots@loc@TMPa}% |
| 3111 |
\edef\pgfplots@contour@cm@options{% |
| 3112 |
\the\t@pgfplots@toka% |
| 3113 |
/utils/exec={% |
| 3114 |
\noexpand\edef\noexpand\pgfplots@targetpos@restore{% |
| 3115 |
of colormap/target pos min=\pgfkeysvalueof{/pgfplots/of colormap/target pos min},% |
| 3116 |
of colormap/target pos max=\pgfkeysvalueof{/pgfplots/of colormap/target pos max},% |
| 3117 |
of colormap/target pos min/insert=\ifpgfplots@createcolormap@target@pos@includes@limits@min true\else false\fi,% |
| 3118 |
of colormap/target pos max/insert=\ifpgfplots@createcolormap@target@pos@includes@limits@max true\else false\fi,% |
| 3119 |
\if c\pgfplots@ofcolorbar@sample@for@choice |
| 3120 |
of colormap/sample for=const,% |
| 3121 |
\else |
| 3122 |
of colormap/sample for=default,% |
| 3123 |
\fi |
| 3124 |
}% |
| 3125 |
},% |
| 3126 |
of colormap/target pos min*=\pgfplots@metamin,% |
| 3127 |
of colormap/target pos max*=\pgfplots@metamax,% |
| 3128 |
of colormap/sample for=const,% |
| 3129 |
colormap={\pgfplotscontourfilledcolormap}{% |
| 3130 |
\the\t@pgfplots@tokb |
| 3131 |
},% |
| 3132 |
/utils/exec={% |
| 3133 |
\noexpand\expandafter |
| 3134 |
\noexpand\pgfkeysalso |
| 3135 |
\noexpand\expandafter{\noexpand\pgfplots@targetpos@restore}% |
| 3136 |
},% |
| 3137 |
}% |
| 3138 |
\fi |
| 3139 |
\else |
| 3140 |
% Ah - we have a list of positions for the contours! |
| 3141 |
\t@pgfplots@toka=\expandafter{\pgfplots@contour@cm@options}% |
| 3142 |
\edef\pgfplots@contour@cm@options{% |
| 3143 |
\the\t@pgfplots@toka% |
| 3144 |
colormap={\pgfplotscontourfilledcolormap}{% |
| 3145 |
of colormap={% |
| 3146 |
target pos min*=\pgfplots@metamin, |
| 3147 |
target pos max*=\pgfplots@metamax, |
| 3148 |
sample for=const,% |
| 3149 |
target pos={\pgfplots@loc@TMPa}, |
| 3150 |
}% |
| 3151 |
},% |
| 3152 |
}% |
| 3153 |
\fi |
| 3154 |
% |
| 3155 |
\ifx\pgfplots@contour@cm@options\pgfutil@empty |
| 3156 |
\else |
| 3157 |
% move to "late options" such that we carry them outside of |
| 3158 |
% any \begingroup...\endgroup constructions: |
| 3159 |
\expandafter\pgfplotssetlateoptions\expandafter{\pgfplots@contour@cm@options}% |
| 3160 |
%\message{contour filled: assembled options \meaning\pgfplots@contour@cm@options^^J}% |
| 3161 |
\fi |
| 3162 |
}% |