| 1 |
%-------------------------------------------- |
| 2 |
% |
| 3 |
% Package pgfplots |
| 4 |
% |
| 5 |
% Provides a user-friendly interface to create function plots (normal |
| 6 |
% plots, semi-logplots and double-logplots). |
| 7 |
% |
| 8 |
% It is based on Till Tantau's PGF package. |
| 9 |
% |
| 10 |
% Copyright 2007/2008 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 |
\newif\ifpgfplots@log@tick@isminor@tick@pos |
| 28 |
% Checks whether the tick position given as #1.#2=log10(T) belongs to |
| 29 |
% T=i*10^j with an integer i>1. |
| 30 |
% |
| 31 |
% If T=i*10^j, \ifpgfplots@log@tick@isminor@tick@pos will be set to true and |
| 32 |
% \pgfmathresult will contain T. |
| 33 |
% |
| 34 |
% Otherwise, \ifpgfplots@log@tick@isminor@tick@pos will be set to false and |
| 35 |
% pgfmathresult to #1.#2 |
| 36 |
% |
| 37 |
% Arguments: |
| 38 |
% #1.#2 the value log10(T) |
| 39 |
% |
| 40 |
% Implementation: |
| 41 |
% if T = i*10^j, log10(T) = log10(i) + j. |
| 42 |
% That means if log10(T) in \Z, we have T = 10^j. If not, we need to |
| 43 |
% check whether i is an integer. Please note that log10(i) < 1. |
| 44 |
% |
| 45 |
% Further note: log(T) < 0 <=> j<0. |
| 46 |
% In case j<0, we have |
| 47 |
% #1.#2 = j + log(i) |
| 48 |
% = - ( -j - log(i) ) |
| 49 |
% = - ( -j - 1 + (1-log(i)) ) |
| 50 |
% = #1 '.' #2 [ up to the '0.' |
| 51 |
% that means #1 = j-1 and #2 = 1-log(i). |
| 52 |
\def\pgfplots@is@log@tick@a@minor@tick@pos#1.#2\relax{% |
| 53 |
\pgfmathapproxequalto@{#1.#2}{#1.0}% |
| 54 |
\ifpgfmathcomparison |
| 55 |
% in MOST cases, this here will be true: |
| 56 |
\pgfplots@log@tick@isminor@tick@posfalse |
| 57 |
\def\pgfmathresult{#1.#2}% |
| 58 |
\else |
| 59 |
% I guess this won't happen too often. In fact, it's a very |
| 60 |
% special case. |
| 61 |
\begingroup |
| 62 |
\c@pgf@counta=#1\relax |
| 63 |
\ifdim#1.#2pt<0pt % |
| 64 |
\advance\c@pgf@counta by-1 |
| 65 |
\pgfmathsubtract@{1}{0.#2}% |
| 66 |
\expandafter\pgfplots@is@log@tick@a@minor@tick@pos@IDENTIFY@LOGi\pgfmathresult\relax |
| 67 |
\ifpgfplots@log@tick@isminor@tick@pos |
| 68 |
\aftergroup\pgfplots@log@tick@isminor@tick@postrue |
| 69 |
\edef\pgfmathresult{\pgfmathresult e\the\c@pgf@counta}% |
| 70 |
\else |
| 71 |
\aftergroup\pgfplots@log@tick@isminor@tick@posfalse |
| 72 |
\def\pgfmathresult{#1.#2}% |
| 73 |
\fi |
| 74 |
\else |
| 75 |
\pgfplots@is@log@tick@a@minor@tick@pos@IDENTIFY@LOGi0.#2\relax |
| 76 |
\ifpgfplots@log@tick@isminor@tick@pos |
| 77 |
\aftergroup\pgfplots@log@tick@isminor@tick@postrue |
| 78 |
\edef\pgfmathresult{\pgfmathresult e\the\c@pgf@counta}% |
| 79 |
\else |
| 80 |
\aftergroup\pgfplots@log@tick@isminor@tick@posfalse |
| 81 |
\def\pgfmathresult{#1.#2}% |
| 82 |
\fi |
| 83 |
\fi |
| 84 |
\pgfmath@smuggleone\pgfmathresult |
| 85 |
\endgroup |
| 86 |
\fi |
| 87 |
} |
| 88 |
|
| 89 |
% expects a positive number. |
| 90 |
\def\pgfplots@is@log@tick@a@minor@tick@pos@IDENTIFY@LOGi0.#1\relax{% |
| 91 |
\pgfplots@log@tick@isminor@tick@postrue |
| 92 |
\pgfmathapproxequalto@{0.#1}{0.3010299956639}% |
| 93 |
\ifpgfmathcomparison |
| 94 |
\def\pgfmathresult{2}% |
| 95 |
\else |
| 96 |
\pgfmathapproxequalto@{0.#1}{0.4771212547196}% |
| 97 |
\ifpgfmathcomparison |
| 98 |
\def\pgfmathresult{3}% |
| 99 |
\else |
| 100 |
\pgfmathapproxequalto@{0.#1}{0.6020599913279}% |
| 101 |
\ifpgfmathcomparison |
| 102 |
\def\pgfmathresult{4}% |
| 103 |
\else |
| 104 |
\pgfmathapproxequalto@{0.#1}{0.698970004}% |
| 105 |
\ifpgfmathcomparison |
| 106 |
\def\pgfmathresult{5}% |
| 107 |
\else |
| 108 |
\pgfmathapproxequalto@{0.#1}{0.7781512503}% |
| 109 |
\ifpgfmathcomparison |
| 110 |
\def\pgfmathresult{6}% |
| 111 |
\else |
| 112 |
\pgfmathapproxequalto@{0.#1}{0.8450980400}% |
| 113 |
\ifpgfmathcomparison |
| 114 |
\def\pgfmathresult{7}% |
| 115 |
\else |
| 116 |
\pgfmathapproxequalto@{0.#1}{0.9030899869}% |
| 117 |
\ifpgfmathcomparison |
| 118 |
\def\pgfmathresult{8}% |
| 119 |
\else |
| 120 |
\pgfmathapproxequalto@{0.#1}{0.954242509439}% |
| 121 |
\ifpgfmathcomparison |
| 122 |
\def\pgfmathresult{9}% |
| 123 |
\else |
| 124 |
\pgfplots@log@tick@isminor@tick@posfalse |
| 125 |
\fi |
| 126 |
\fi |
| 127 |
\fi |
| 128 |
\fi |
| 129 |
\fi |
| 130 |
\fi |
| 131 |
\fi |
| 132 |
\fi |
| 133 |
} |
| 134 |
|
| 135 |
% Checks whether we need to create a separate 'tick scale label', |
| 136 |
% a node with ' * 10^3' on the side of the axis: |
| 137 |
% |
| 138 |
% PRECONDITION: |
| 139 |
% Axis limits for #1 are given. I need their values before any data |
| 140 |
% scale transformation has been applied. |
| 141 |
% If |
| 142 |
% \pgfplots@#1min@unscaled@as@float |
| 143 |
% and |
| 144 |
% \pgfplots@#1max@unscaled@as@float |
| 145 |
% exist; I will use these macros. |
| 146 |
% Otherwise, I will use \pgfplots@#1min and \pgfplots@#1max; |
| 147 |
% assuming that no data scale transformation is active. |
| 148 |
% FIXME : does that need further attention? |
| 149 |
\def\pgfplots@init@scaled@tick@for#1{% |
| 150 |
\global\def\pgfplots@glob@TMPa{0}% |
| 151 |
\expandafter\pgfplotslistcheckempty\csname pgfplots@prepared@tick@positions@major@#1\endcsname |
| 152 |
\ifpgfplotslistempty |
| 153 |
% we have no tick labels. Omit the tick scale label as well! |
| 154 |
\else |
| 155 |
\begingroup |
| 156 |
\ifcase\csname pgfplots@scaled@ticks@#1@choice\endcsname\relax |
| 157 |
% CASE 0 : scaled #1 ticks=false: do nothing here. |
| 158 |
\or |
| 159 |
% CASE 1 : scaled #1 ticks=true: |
| 160 |
%-------------------------------- |
| 161 |
% the \pgfplots@xmin@unscaled@as@float is set just before the data |
| 162 |
% scale transformation is initialised. |
| 163 |
% |
| 164 |
% The variables are empty if there is no datascale transformation. |
| 165 |
\expandafter\let\expandafter\pgfplots@cur@min@unscaled\csname pgfplots@#1min@unscaled@as@float\endcsname |
| 166 |
\expandafter\let\expandafter\pgfplots@cur@max@unscaled\csname pgfplots@#1max@unscaled@as@float\endcsname |
| 167 |
% |
| 168 |
\ifx\pgfplots@cur@min@unscaled\pgfutil@empty |
| 169 |
\edef\pgfplots@loc@TMPa{\csname pgfplots@#1min\endcsname}% |
| 170 |
\expandafter\pgfmathfloatparsenumber\expandafter{\pgfplots@loc@TMPa}% |
| 171 |
\let\pgfplots@cur@min@unscaled=\pgfmathresult |
| 172 |
\edef\pgfplots@loc@TMPa{\csname pgfplots@#1max\endcsname}% |
| 173 |
\expandafter\pgfmathfloatparsenumber\expandafter{\pgfplots@loc@TMPa}% |
| 174 |
\let\pgfplots@cur@max@unscaled=\pgfmathresult |
| 175 |
\fi |
| 176 |
% |
| 177 |
\expandafter\pgfmathfloat@decompose@E\pgfplots@cur@min@unscaled\relax\pgfmathfloat@a@E |
| 178 |
\expandafter\pgfmathfloat@decompose@E\pgfplots@cur@max@unscaled\relax\pgfmathfloat@b@E |
| 179 |
\pgfplots@init@scaled@tick@normalize@exponents |
| 180 |
\ifnum\pgfmathfloat@b@E<\pgfmathfloat@a@E |
| 181 |
\pgfmathfloat@b@E=\pgfmathfloat@a@E |
| 182 |
\fi |
| 183 |
\xdef\pgfplots@glob@TMPa{\pgfplots@scale@ticks@above@exponent}% |
| 184 |
\ifnum\pgfplots@glob@TMPa<\pgfmathfloat@b@E |
| 185 |
% ok, scale it: |
| 186 |
\multiply\pgfmathfloat@b@E by-1 |
| 187 |
\xdef\pgfplots@glob@TMPa{\the\pgfmathfloat@b@E}% |
| 188 |
\else |
| 189 |
\xdef\pgfplots@glob@TMPa{\pgfplots@scale@ticks@below@exponent}% |
| 190 |
\ifnum\pgfplots@glob@TMPa>\pgfmathfloat@b@E |
| 191 |
% ok, scale it: |
| 192 |
\multiply\pgfmathfloat@b@E by-1 |
| 193 |
\xdef\pgfplots@glob@TMPa{\the\pgfmathfloat@b@E}% |
| 194 |
\else |
| 195 |
% no scaling necessary: |
| 196 |
\xdef\pgfplots@glob@TMPa{0}% |
| 197 |
\fi |
| 198 |
\fi |
| 199 |
\or |
| 200 |
% CASE 2 : scaled #1 ticks=base 10: |
| 201 |
%-------------------------------- |
| 202 |
\c@pgf@counta=\csname pgfplots@scaled@ticks@#1@arg\endcsname\relax |
| 203 |
%\multiply\c@pgf@counta by-1 |
| 204 |
\xdef\pgfplots@glob@TMPa{\the\c@pgf@counta}% |
| 205 |
\or |
| 206 |
% CASE 3 : scaled #1 ticks=real: |
| 207 |
%-------------------------------- |
| 208 |
\pgfmathfloatparsenumber{\csname pgfplots@scaled@ticks@#1@arg\endcsname}% |
| 209 |
\global\let\pgfplots@glob@TMPa=\pgfmathresult |
| 210 |
\or |
| 211 |
% CASE 4 : scaled #1 ticks=manual: |
| 212 |
\expandafter\global\expandafter\let\expandafter\pgfplots@glob@TMPa\csname pgfplots@scaled@ticks@#1@arg\endcsname |
| 213 |
\fi |
| 214 |
\endgroup |
| 215 |
\fi |
| 216 |
\expandafter\let\csname pgfplots@tick@scale@#1\endcsname=\pgfplots@glob@TMPa% |
| 217 |
} |
| 218 |
|
| 219 |
% Handles the case that one of the limits is 0 (or unbounded, although |
| 220 |
% that might not be a use-case at all). |
| 221 |
% |
| 222 |
% Note that 0 = 0*10^A (naturally). In this case, A can be undefined, |
| 223 |
% and we want to use B's exponent (only) for the decision here. |
| 224 |
% |
| 225 |
% INPUT: |
| 226 |
% - \pgfplots@cur@min@unscaled, |
| 227 |
% - \pgfplots@cur@max@unscaled, |
| 228 |
% - \pgfmathfloat@a@E |
| 229 |
% - \pgfmathfloat@b@E |
| 230 |
% |
| 231 |
% Output: |
| 232 |
% normalized values of \pgfmathfloat@a@E and \pgfmathfloat@b@E |
| 233 |
\def\pgfplots@init@scaled@tick@normalize@exponents{% |
| 234 |
\pgfmathfloatgetflags\pgfplots@cur@min@unscaled\pgfmathfloat@a@S |
| 235 |
\pgfmathfloatgetflags\pgfplots@cur@max@unscaled\pgfmathfloat@b@S |
| 236 |
\ifcase\pgfmathfloat@a@S% |
| 237 |
% min = 0. |
| 238 |
\ifcase\pgfmathfloat@b@S |
| 239 |
% max =0 |
| 240 |
% normalize to 0 * 10^0 ! |
| 241 |
\pgfmathfloat@a@E=0 % |
| 242 |
\pgfmathfloat@b@E=0 % |
| 243 |
\or |
| 244 |
% max > 0 |
| 245 |
% since 0 = 0 * 10^A for any A, tick scaling is based on |
| 246 |
% B only. |
| 247 |
\pgfmathfloat@a@E=\pgfmathfloat@b@E |
| 248 |
\or |
| 249 |
% max < 0 |
| 250 |
\pgfmathfloat@a@E=\pgfmathfloat@b@E |
| 251 |
\else |
| 252 |
% max is unbounded. normalize exponent to something |
| 253 |
% useful: |
| 254 |
\pgfmathfloat@a@E=0 % |
| 255 |
\pgfmathfloat@b@E=0 % |
| 256 |
\fi |
| 257 |
\or |
| 258 |
% min>0 |
| 259 |
\ifcase\pgfmathfloat@b@S |
| 260 |
% max =0 |
| 261 |
% since 0 = 0 * 10^B for any B, tick scaling is based on |
| 262 |
% A only. |
| 263 |
\pgfmathfloat@b@E=\pgfmathfloat@a@E |
| 264 |
\or |
| 265 |
% max > 0 |
| 266 |
\or |
| 267 |
% max < 0 |
| 268 |
\else |
| 269 |
% max is unbounded. normalize exponent to something |
| 270 |
% useful: |
| 271 |
\pgfmathfloat@b@E=\pgfmathfloat@a@E |
| 272 |
\fi |
| 273 |
\or |
| 274 |
% min<0 |
| 275 |
\ifcase\pgfmathfloat@b@S |
| 276 |
% max =0 |
| 277 |
% since 0 = 0 * 10^B for any B, tick scaling is based on |
| 278 |
% A only. |
| 279 |
\pgfmathfloat@b@E=\pgfmathfloat@a@E |
| 280 |
\or |
| 281 |
% max > 0 |
| 282 |
\or |
| 283 |
% max < 0 |
| 284 |
\else |
| 285 |
% max is unbounded. normalize exponent to something |
| 286 |
% useful: |
| 287 |
\pgfmathfloat@b@E=\pgfmathfloat@a@E |
| 288 |
\fi |
| 289 |
\else |
| 290 |
% min is unbounded: |
| 291 |
% normalize somehow. |
| 292 |
\pgfmathfloat@a@E=0 % |
| 293 |
\pgfmathfloat@b@E=0 % |
| 294 |
\fi |
| 295 |
} |
| 296 |
|
| 297 |
% x-axis tick labels for #1th tick |
| 298 |
% #1: the axis (x,y or z) |
| 299 |
% #2: the value |
| 300 |
% #3,#4+#5: arguments for \pgfplotspointonorientedsurfaceabwithbshift |
| 301 |
% #5: ticknumber |
| 302 |
\def\pgfplots@show@ticklabel#1#2(#3,#4+#5)#6{% |
| 303 |
\begingroup% |
| 304 |
\edef\pgfmathresult{#2}% |
| 305 |
\pgfkeyslet{/pgfplots/sloped/at position}\pgfmathresult% |
| 306 |
\csname ifpgfplots@#1ticklabel@interval\endcsname |
| 307 |
% Special case for the INTERVAL feature: |
| 308 |
% we have to do additional work here. |
| 309 |
\pgfmathparse{#3}% |
| 310 |
\edef\pgfplots@show@ticklabel@coord@x@new{\pgfmathresult}% |
| 311 |
\pgfmathparse{#4}% |
| 312 |
\edef\pgfplots@show@ticklabel@coord@y@new{\pgfmathresult}% |
| 313 |
% |
| 314 |
\pgfplots@show@ticklabel@{#1}{#2}% |
| 315 |
\let\nexttick=\tick |
| 316 |
\ifx\pgfplots@show@ticklabel@LASTTICK\pgfutil@empty |
| 317 |
% its the first call. Simply remember arguments and wait |
| 318 |
% for interval boundary before proceeding. |
| 319 |
\else |
| 320 |
% acquire options of first interval boundary: |
| 321 |
\pgfplots@show@ticklabel@LASTTICK |
| 322 |
% compute new node position: |
| 323 |
\pgfmathparse{0.5*(\pgfplots@show@ticklabel@coord@x + \pgfplots@show@ticklabel@coord@x@new)}% |
| 324 |
\let\pgfplots@show@ticklabel@coord@x=\pgfmathresult% |
| 325 |
\pgfmathparse{0.5*(\pgfplots@show@ticklabel@coord@y + \pgfplots@show@ticklabel@coord@y@new)}% |
| 326 |
\let\pgfplots@show@ticklabel@coord@y=\pgfmathresult% |
| 327 |
\let\ticknum=\pgfplots@show@ticklabel@num\relax% |
| 328 |
\let\tick=\pgfplots@show@ticklabel@tick% |
| 329 |
\pgfplots@show@ticklabel@@{#1} |
| 330 |
{\pgfplotspointonorientedsurfaceabwithbshift{\pgfplots@show@ticklabel@coord@x}{\pgfplots@show@ticklabel@coord@y}{#5}}% |
| 331 |
\fi |
| 332 |
\xdef\pgfplots@show@ticklabel@LASTTICK{% |
| 333 |
\noexpand\def\noexpand\pgfplots@show@ticklabel@tick{\nexttick}% |
| 334 |
\noexpand\def\noexpand\pgfplots@show@ticklabel@coord@x{\pgfplots@show@ticklabel@coord@x@new}% |
| 335 |
\noexpand\def\noexpand\pgfplots@show@ticklabel@coord@y{\pgfplots@show@ticklabel@coord@y@new}% |
| 336 |
\noexpand\edef\noexpand\pgfplots@show@ticklabel@num{#6}% |
| 337 |
}% |
| 338 |
\else |
| 339 |
\let\ticknum=#6\relax% |
| 340 |
\pgfplots@show@ticklabel@{#1}{#2}% |
| 341 |
\pgfplots@show@ticklabel@@{#1}{\pgfplotspointonorientedsurfaceabwithbshift{#3}{#4}{#5}}% |
| 342 |
\fi |
| 343 |
\endgroup |
| 344 |
} |
| 345 |
|
| 346 |
% #1: the axis (x,y or z) |
| 347 |
% #2: the location where to place it. |
| 348 |
\def\pgfplots@show@ticklabel@@#1#2{% |
| 349 |
% Typeset the label! |
| 350 |
\pgfinterruptboundingbox |
| 351 |
% What makes this complicated is the 'ticklabel cs' feature. |
| 352 |
% What we need is to compute the MAXIMUM LENGTH over each tick |
| 353 |
% label IN DIRECTION OF THE OUTER NORMAL. |
| 354 |
% |
| 355 |
% This needs to |
| 356 |
% 1. enable bounding box computation even in case of |
| 357 |
% 'overlay', |
| 358 |
% 2. projection of the bounding box in direction of the outer |
| 359 |
% normal, |
| 360 |
% 3. update of the bounding box if 'overlay' is not active. |
| 361 |
\begingroup |
| 362 |
% |
| 363 |
% prepare step (1.): |
| 364 |
\pgfkeysalso{% |
| 365 |
/tikz/every node/.append code={% |
| 366 |
\ifpgf@relevantforpicturesize |
| 367 |
\gdef\pgfplots@show@ticklabel@@update@BB{1}% |
| 368 |
\else |
| 369 |
\gdef\pgfplots@show@ticklabel@@update@BB{0}% |
| 370 |
\fi |
| 371 |
\pgf@relevantforpicturesizetrue |
| 372 |
}% |
| 373 |
}% |
| 374 |
% |
| 375 |
% Compute and remember the position '#2': |
| 376 |
\pgf@process{#2}% |
| 377 |
\edef\pgfplots@ticklabel@at@x{\the\pgf@x}% |
| 378 |
\edef\pgfplots@ticklabel@at@y{\the\pgf@y}% |
| 379 |
% |
| 380 |
% ok, generate the label! |
| 381 |
\node at (\pgfplots@ticklabel@at@x,\pgfplots@ticklabel@at@y) {\csname pgfplots@#1ticklabel\endcsname};% |
| 382 |
% |
| 383 |
% compute the label's dimensions, step (2.): |
| 384 |
\pgfplots@ticklabel@maxtickdimen@updateforcurrentpath |
| 385 |
{#1} |
| 386 |
{\pgf@x=\pgfplots@ticklabel@at@x\space\pgf@y=\pgfplots@ticklabel@at@y\space}%% |
| 387 |
% |
| 388 |
% prepare step (3.): update of bounding box: |
| 389 |
\if\pgfplots@show@ticklabel@@update@BB1% |
| 390 |
\xdef\pgfplots@glob@TMPa{% |
| 391 |
\pgf@xa=\the\pgf@picminx\space |
| 392 |
\pgf@xb=\the\pgf@picminy\space |
| 393 |
\pgf@ya=\the\pgf@picmaxx\space |
| 394 |
\pgf@yb=\the\pgf@picmaxy\space |
| 395 |
\noexpand\pgf@protocolsizes{\pgf@xa}{\pgf@xb}% |
| 396 |
\noexpand\pgf@protocolsizes{\pgf@ya}{\pgf@yb}% |
| 397 |
\noexpand\pgf@resetpathsizes |
| 398 |
}% |
| 399 |
\else |
| 400 |
\global\let\pgfplots@glob@TMPa=\relax |
| 401 |
\fi |
| 402 |
\endgroup |
| 403 |
\endpgfinterruptboundingbox |
| 404 |
\begingroup |
| 405 |
\pgfplots@glob@TMPa |
| 406 |
\endgroup |
| 407 |
}% |
| 408 |
|
| 409 |
% TICK LABEL DIMENSION CONTROL |
| 410 |
% |
| 411 |
% The following framework is supposed to accumulate the value for |
| 412 |
% \pgfplotsvalueoflargesttickdimen. |
| 413 |
% |
| 414 |
% It works like this: |
| 415 |
% |
| 416 |
% \pgfplots@ticklabel@maxtickdimen@reset{#1} |
| 417 |
% \pgfplots@ticklabel@maxtickdimen@prepare@for@normalvec{#1}{<normal vector>} |
| 418 |
% ... |
| 419 |
% \pgfplots@ticklabel@maxtickdimen@updateforcurrentpath{#1} |
| 420 |
% \pgfplots@ticklabel@maxtickdimen@updateforcurrentpath{#1} |
| 421 |
% \pgfplots@ticklabel@maxtickdimen@updateforcurrentpath{#1} |
| 422 |
% ... |
| 423 |
% \pgfplots@ticklabel@maxtickdimen@finish{#1} |
| 424 |
% |
| 425 |
% -> then, \pgfplotsvalueoflargesttickdimen expands to the largest |
| 426 |
% distance from a tick's coordinate to its tick label bounding box in |
| 427 |
% direction of the outer normal vector. |
| 428 |
\def\pgfplots@ticklabel@maxtickdimen@reset#1{% |
| 429 |
\expandafter\gdef\csname pgfplots@maxtickdimen@#1\endcsname{0pt}% |
| 430 |
\expandafter\gdef\csname pgfplots@maxtickdimen@extrashift@#1\endcsname{0pt}% |
| 431 |
}% |
| 432 |
|
| 433 |
% Adds the extra shift '#2' along the normal vector for axis '#1'. |
| 434 |
\def\pgfplots@ticklabel@maxtickdimen@extrashift#1#2{% |
| 435 |
\begingroup |
| 436 |
\afterassignment\pgfplots@gobble@until@relax |
| 437 |
\pgf@xa=#2pt\relax |
| 438 |
\advance\pgf@xa by\csname pgfplots@maxtickdimen@extrashift@#1\endcsname\relax |
| 439 |
\expandafter\xdef\csname pgfplots@maxtickdimen@extrashift@#1\endcsname{\the\pgf@xa}% |
| 440 |
\endgroup |
| 441 |
} |
| 442 |
|
| 443 |
% Finalizes the maxtickdimen computation. |
| 444 |
% |
| 445 |
% This applies any extra shifts (including '#1ticklabel shift'). |
| 446 |
\def\pgfplots@ticklabel@maxtickdimen@finish#1{% |
| 447 |
\pgfkeysgetvalue{/pgfplots/#1ticklabel shift}\pgfmathresult |
| 448 |
\ifx\pgfmathresult\pgfutil@empty |
| 449 |
\else |
| 450 |
\pgfplots@ticklabel@maxtickdimen@extrashift{#1}{\pgfkeysvalueof{/pgfplots/#1ticklabel shift}}% |
| 451 |
\fi |
| 452 |
\begingroup |
| 453 |
\pgf@xa=\csname pgfplots@maxtickdimen@extrashift@#1\endcsname\relax |
| 454 |
\advance\pgf@xa by \csname pgfplots@maxtickdimen@#1\endcsname\relax |
| 455 |
\expandafter\xdef\csname pgfplots@maxtickdimen@#1\endcsname{\the\pgf@xa}% |
| 456 |
\endgroup |
| 457 |
}% |
| 458 |
% |
| 459 |
% #1: the axis (x,y or z) |
| 460 |
% #2: the normal vector |
| 461 |
\def\pgfplots@ticklabel@maxtickdimen@prepare@for@normalvec#1#2{% |
| 462 |
\pgf@process{#2}% |
| 463 |
\edef\pgfplots@loc@vector@to@outside{\pgf@x=\the\pgf@x\space\pgf@y=\the\pgf@y\space}% |
| 464 |
% Identify the corner point of the ticklabel bounding box which |
| 465 |
% shall be used: |
| 466 |
\ifdim\pgf@x>0sp |
| 467 |
\ifdim\pgf@y>0sp |
| 468 |
% NORTH EAST |
| 469 |
\def\pgfplots@loc@ticklabel@bb@corner{\pgf@x=\pgf@picmaxx\pgf@y=\pgf@picmaxy}% |
| 470 |
\else |
| 471 |
% SOUTH EAST |
| 472 |
\def\pgfplots@loc@ticklabel@bb@corner{\pgf@x=\pgf@picmaxx\pgf@y=\pgf@picminy}% |
| 473 |
\fi |
| 474 |
\else |
| 475 |
\ifdim\pgf@y>0sp |
| 476 |
% NORTH WEST |
| 477 |
\def\pgfplots@loc@ticklabel@bb@corner{\pgf@x=\pgf@picminx\pgf@y=\pgf@picmaxy}% |
| 478 |
\else |
| 479 |
% SOUTH WEST |
| 480 |
\def\pgfplots@loc@ticklabel@bb@corner{\pgf@x=\pgf@picminx\pgf@y=\pgf@picminy}% |
| 481 |
\fi |
| 482 |
\fi |
| 483 |
}% |
| 484 |
|
| 485 |
% #1: the axis (x,y or z) |
| 486 |
% #2: the point from where dimension shall be computed (the 'at' |
| 487 |
% argument of the tick label) |
| 488 |
\def\pgfplots@ticklabel@maxtickdimen@updateforcurrentpath#1#2{% |
| 489 |
\pgfplotsscalarproductofvectors |
| 490 |
{\pgfplots@loc@vector@to@outside}% |
| 491 |
{\pgfpointdiff |
| 492 |
{#2\pgf@pos@transform\pgf@x\pgf@y}% |
| 493 |
{\pgfplots@loc@ticklabel@bb@corner}}% |
| 494 |
\ifdim\pgf@x>\csname pgfplots@maxtickdimen@#1\endcsname\relax |
| 495 |
\expandafter\xdef\csname pgfplots@maxtickdimen@#1\endcsname{\the\pgf@x}% |
| 496 |
\fi |
| 497 |
}% |
| 498 |
|
| 499 |
% Expands to the largest distance of a tick position to its tick label |
| 500 |
% bounding box in direction of the outer unit normal vector. |
| 501 |
% |
| 502 |
% It does also include the value of the 'ticklabel shift' key. |
| 503 |
% |
| 504 |
% This function assumes that |
| 505 |
% \pgfplots@ticklabel@maxtickdimen@reset{#1} |
| 506 |
% \pgfplots@ticklabel@maxtickdimen@prepare@for@normalvec{#1}{<normal vector>} |
| 507 |
% ... |
| 508 |
% \pgfplots@ticklabel@maxtickdimen@updateforcurrentpath{#1} |
| 509 |
% \pgfplots@ticklabel@maxtickdimen@updateforcurrentpath{#1} |
| 510 |
% \pgfplots@ticklabel@maxtickdimen@updateforcurrentpath{#1} |
| 511 |
% ... |
| 512 |
% \pgfplots@ticklabel@maxtickdimen@finish{#1} |
| 513 |
% has been invoked completely. |
| 514 |
% |
| 515 |
% #1: either x,y or z. It denotes the axis for which the ticks are |
| 516 |
% requested. |
| 517 |
\def\pgfplotsvalueoflargesttickdimen#1{% |
| 518 |
\csname pgfplots@maxtickdimen@#1\endcsname |
| 519 |
}% |
| 520 |
|
| 521 |
% Just like \pgfplotsqpointoutsideofaxis, but this one here uses the |
| 522 |
% axis on which tick labels will be drawn. |
| 523 |
% |
| 524 |
% #1: one of x, y or z. |
| 525 |
% #2: the coordinate on the tick axis designated by '#1'. |
| 526 |
% #3: a scale (a dimen) in which the point is moved in direction of |
| 527 |
% the outward normal vector of the axis. |
| 528 |
% |
| 529 |
% @see \pgfplotsqpointoutsideofaxis |
| 530 |
\def\pgfplotsqpointoutsideofticklabelaxis#1#2#3{% |
| 531 |
\pgfplotsqpointoutsideofaxis{\csname pgfplots@#1ticklabelaxisspec\endcsname}{#2}{#3}% |
| 532 |
}% |
| 533 |
\def\pgfplotsqpointoutsideofticklabelaxisrel#1#2#3{% |
| 534 |
%\message{using \string\pgfplotsqpointoutsideofaxisrel{\csname pgfplots@#1ticklabelaxisspec\endcsname}{#2}{#3}^^J}% |
| 535 |
\pgfplotsqpointoutsideofaxisrel{\csname pgfplots@#1ticklabelaxisspec\endcsname}{#2}{#3}% |
| 536 |
}% |
| 537 |
\def\pgfplotsqpointoutsideofticklabelaxistransformed#1#2#3{% |
| 538 |
\pgfplotsqpointoutsideofaxistransformed{\csname pgfplots@#1ticklabelaxisspec\endcsname}{#2}{#3}% |
| 539 |
}% |
| 540 |
|
| 541 |
% Expands to the three-character-identification for the axis |
| 542 |
% containing tick labels for axis #1. |
| 543 |
% |
| 544 |
% #1: either x, y or z. |
| 545 |
\def\pgfplotsticklabelaxisspec#1{\csname pgfplots@#1ticklabelaxisspec\endcsname}% |
| 546 |
|
| 547 |
% The unit outer normal vector for axis #1. |
| 548 |
% #1: one of x, y or z. |
| 549 |
\def\pgfplotspointouternormalvectorofticklabelaxis#1{% |
| 550 |
\pgfplotspointouternormalvectorofaxis{\csname pgfplots@#1ticklabelaxisspec\endcsname}% |
| 551 |
} |
| 552 |
|
| 553 |
% Defines \tick by applying any necessary math to the (possibly |
| 554 |
% transformed) tick value #2. |
| 555 |
% |
| 556 |
% #1: axis (x or y) |
| 557 |
% #2: tick value. |
| 558 |
\def\pgfplots@show@ticklabel@#1#2{% |
| 559 |
\csname ifpgfplots@apply@datatrafo@#1\endcsname |
| 560 |
\pgfplotscoordmath{#1}{datascaletrafo inverse}{#2}% |
| 561 |
\ifcase\csname pgfplots@scaled@ticks@#1@choice\endcsname |
| 562 |
\or |
| 563 |
\expandafter\pgfmathfloatshift@\expandafter{\pgfmathresult}{\csname pgfplots@tick@scale@#1\endcsname}% |
| 564 |
\or |
| 565 |
\expandafter\pgfmathfloatshift@\expandafter{\pgfmathresult}{\csname pgfplots@tick@scale@#1\endcsname}% |
| 566 |
\or |
| 567 |
\expandafter\pgfmathfloatdivide@\expandafter{\pgfmathresult}{\csname pgfplots@tick@scale@#1\endcsname}% |
| 568 |
\or |
| 569 |
% scaled #1 ticks=manual. Invoke manual tick scaling code: |
| 570 |
\expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@tick@scale@#1\endcsname |
| 571 |
\begingroup |
| 572 |
\pgfkeys{/pgf/fpu=true}% |
| 573 |
\expandafter\pgfplots@loc@TMPa\expandafter{\pgfmathresult}% |
| 574 |
\pgfmath@smuggleone\pgfmathresult |
| 575 |
\endgroup |
| 576 |
\pgfmathfloatparsenumber\pgfmathresult% |
| 577 |
\fi |
| 578 |
% .. and this here provides \tick as fixed point repr: |
| 579 |
\expandafter\pgfmathfloattofixed\expandafter{\pgfmathresult}% |
| 580 |
\let\tick=\pgfmathresult |
| 581 |
\else |
| 582 |
\edef\tick{#2}% |
| 583 |
\pgfplots@if{pgfplots@#1islinear}{% |
| 584 |
\ifnum\csname pgfplots@scaled@ticks@#1@choice\endcsname=0 |
| 585 |
\else |
| 586 |
\pgfmathfloatparsenumber{#2}% |
| 587 |
\ifnum\csname pgfplots@scaled@ticks@#1@choice\endcsname=3 |
| 588 |
\expandafter\pgfmathfloatdivide@\expandafter{\pgfmathresult}{\csname pgfplots@tick@scale@#1\endcsname}% |
| 589 |
\else |
| 590 |
\expandafter\pgfmathfloatshift@\expandafter{\pgfmathresult}{\csname pgfplots@tick@scale@#1\endcsname}% |
| 591 |
\fi |
| 592 |
\expandafter\pgfmathfloattofixed\expandafter{\pgfmathresult}% |
| 593 |
\let\tick=\pgfmathresult |
| 594 |
\fi |
| 595 |
}{}% |
| 596 |
\fi |
| 597 |
\pgfplots@coord@inv@trafo@apply{#1}{\tick}% |
| 598 |
\let\tick=\pgfmathresult |
| 599 |
}% |
| 600 |
|
| 601 |
\def\pgfplots@user@ticklabel@list@x{% |
| 602 |
\pgfplotslistselectorempty\ticknum\of\pgfplots@xticklabels\to\tick |
| 603 |
\pgfplots@ticklabel@typeset@arg\tick |
| 604 |
} |
| 605 |
\def\pgfplots@user@ticklabel@list@y{% |
| 606 |
\pgfplotslistselectorempty\ticknum\of\pgfplots@yticklabels\to\tick |
| 607 |
\pgfplots@ticklabel@typeset@arg\tick |
| 608 |
} |
| 609 |
\def\pgfplots@user@ticklabel@list@z{% |
| 610 |
\pgfplotslistselectorempty\ticknum\of\pgfplots@zticklabels\to\tick |
| 611 |
\pgfplots@ticklabel@typeset@arg\tick |
| 612 |
} |
| 613 |
\def\pgfplots@user@extra@ticklabel@list@x{% |
| 614 |
\pgfplotslistselectorempty\ticknum\of\pgfplots@extra@xticklabels\to\tick |
| 615 |
\pgfplots@ticklabel@typeset@arg\tick |
| 616 |
} |
| 617 |
\def\pgfplots@user@extra@ticklabel@list@y{% |
| 618 |
\pgfplotslistselectorempty\ticknum\of\pgfplots@extra@yticklabels\to\tick |
| 619 |
\pgfplots@ticklabel@typeset@arg\tick |
| 620 |
} |
| 621 |
\def\pgfplots@user@extra@ticklabel@list@z{% |
| 622 |
\pgfplotslistselectorempty\ticknum\of\pgfplots@extra@zticklabels\to\tick |
| 623 |
\pgfplots@ticklabel@typeset@arg\tick |
| 624 |
} |
| 625 |
|
| 626 |
\def\pgfplots@limit@max@reg#1{% |
| 627 |
\if\pgfkeysvalueof{/pgfplots/#1 dir/value}n% |
| 628 |
\csname pgfplots@#1max@reg\endcsname |
| 629 |
\else |
| 630 |
\csname pgfplots@#1min@reg\endcsname |
| 631 |
\fi |
| 632 |
}% |
| 633 |
\def\pgfplots@limit@min@reg#1{% |
| 634 |
\if\pgfkeysvalueof{/pgfplots/#1 dir/value}n% |
| 635 |
\csname pgfplots@#1min@reg\endcsname |
| 636 |
\else |
| 637 |
\csname pgfplots@#1max@reg\endcsname |
| 638 |
\fi |
| 639 |
}% |
| 640 |
|
| 641 |
% Check if a label does not cross the x-axis |
| 642 |
\def\pgfplots@ytick@check@tickshow{% |
| 643 |
\pgfplots@tickshowtrue |
| 644 |
% |
| 645 |
\pgfplots@if@has@axis@shift x{% |
| 646 |
\pgfplots@hide@obscured@ytickfalse |
| 647 |
}{}% |
| 648 |
% |
| 649 |
\ifpgfplots@hide@obscured@ytick |
| 650 |
\if\pgfplots@yaxislinesnum2% center |
| 651 |
\ifcase\pgfplots@xaxislinesnum\relax |
| 652 |
\pgfplotsmath@ifapproxequal@dim |
| 653 |
{\pgfplots@tmpa}{\pgfplots@limit@min@reg{y}} |
| 654 |
{\pgfplots@loc@tick@placement@tolerance} |
| 655 |
{% |
| 656 |
\pgfplots@tickshowfalse |
| 657 |
}{}% |
| 658 |
\pgfplotsmath@ifapproxequal@dim |
| 659 |
{\pgfplots@tmpa}{\pgfplots@limit@max@reg{y}} |
| 660 |
{\pgfplots@loc@tick@placement@tolerance} |
| 661 |
{% |
| 662 |
\pgfplots@tickshowfalse |
| 663 |
}{}% |
| 664 |
\or |
| 665 |
\pgfplotsmath@ifapproxequal@dim |
| 666 |
{\pgfplots@tmpa}{\pgfplots@limit@min@reg{y}} |
| 667 |
{\pgfplots@loc@tick@placement@tolerance} |
| 668 |
{% |
| 669 |
\pgfplots@tickshowfalse |
| 670 |
}{% |
| 671 |
}% |
| 672 |
\or |
| 673 |
\pgfplotsmath@ifapproxequal@dim |
| 674 |
{\pgfplots@tmpa}{\pgfplots@logical@ZERO@y pt} |
| 675 |
{\pgfplots@loc@tick@placement@tolerance} |
| 676 |
{% |
| 677 |
\pgfplots@tickshowfalse |
| 678 |
}{}% |
| 679 |
\or |
| 680 |
\pgfplotsmath@ifapproxequal@dim |
| 681 |
{\pgfplots@tmpa}{\pgfplots@limit@max@reg{y}} |
| 682 |
{\pgfplots@loc@tick@placement@tolerance} |
| 683 |
{% |
| 684 |
\pgfplots@tickshowfalse |
| 685 |
}{}% |
| 686 |
\fi |
| 687 |
\fi |
| 688 |
\fi |
| 689 |
} |
| 690 |
\def\pgfplots@ztick@check@tickshow{% |
| 691 |
\pgfplots@tickshowtrue |
| 692 |
% |
| 693 |
\pgfplots@if@has@axis@shift x{% |
| 694 |
\pgfplots@if@has@axis@shift y{% |
| 695 |
\pgfplots@hide@obscured@ztickfalse |
| 696 |
}{}% |
| 697 |
}{}% |
| 698 |
% |
| 699 |
\ifpgfplots@hide@obscured@ztick |
| 700 |
\if\pgfplots@zaxislinesnum2% center |
| 701 |
\pgfplotsmath@ifapproxequal@dim |
| 702 |
{\pgfplots@tmpa}{\pgfplots@logical@ZERO@z pt} |
| 703 |
{\pgfplots@loc@tick@placement@tolerance} |
| 704 |
{% |
| 705 |
\pgfplots@tickshowfalse |
| 706 |
}{}% |
| 707 |
\fi |
| 708 |
\fi |
| 709 |
}% |
| 710 |
|
| 711 |
% Fills the macros |
| 712 |
% \pgfplots@tick@LOWER@b \pgfplots@tick@end@a |
| 713 |
% \pgfplots@tick@UPPER@b \pgfplots@tick@end@b |
| 714 |
% with coordinates such that |
| 715 |
% (\pgfplots@tick@LOWER@b,\pgfplots@tmpa) -- (\pgfplots@tick@end@a,\pgfplots@tmpa) |
| 716 |
% produces a correct tick line. |
| 717 |
% |
| 718 |
% The '@b' variant is only used in case of \pgfplots@ytickposnum = 0 |
| 719 |
% |
| 720 |
% #1 : the current axis (x or y). |
| 721 |
% #2 : the current tick width |
| 722 |
% |
| 723 |
\def\pgfplots@prepare@tick@offsets@for@#1#2{% |
| 724 |
% |
| 725 |
% FIXME : this stuff was ok for 2D. |
| 726 |
% For 3D, it works only for the cases of boxed axes or centered |
| 727 |
% axis lines. |
| 728 |
\ifcase\csname pgfplots@#1tickposnum\endcsname\relax |
| 729 |
% both |
| 730 |
%(\pgfplots@xcoordminTEX-\pgfplots@tick@offset, \pgfplots@tmpa) -- ++( #2, 0pt) |
| 731 |
\edef\pgfplots@tick@LOWER@b{\csname pgfplots@\pgfplotspointonorientedsurfaceB min\endcsname}% |
| 732 |
% |
| 733 |
%(\pgfplots@xcoordmaxTEX+\pgfplots@tick@offset, \pgfplots@tmpa) -- ++(-#2, 0pt) |
| 734 |
\edef\pgfplots@tick@UPPER@b{\csname pgfplots@\pgfplotspointonorientedsurfaceB max\endcsname}% |
| 735 |
\or |
| 736 |
% left |
| 737 |
% (\pgfplots@xcoordminTEX-\pgfplots@tick@offset, \pgfplots@tmpa) -- ++( #2, 0pt); |
| 738 |
\edef\pgfplots@tick@LOWER@b{\csname pgfplots@\pgfplotspointonorientedsurfaceB min\endcsname}% |
| 739 |
\or |
| 740 |
% center |
| 741 |
% (\pgfplots@ZERO@x -\pgfplots@tick@offset, \pgfplots@tmpa) -- ++( #2, 0pt); |
| 742 |
\edef\pgfplots@tick@LOWER@b{\csname pgfplots@logical@ZERO@\pgfplotspointonorientedsurfaceB \endcsname}% |
| 743 |
\or |
| 744 |
% right |
| 745 |
% (\pgfplots@xcoordmaxTEX+\pgfplots@tick@offset, \pgfplots@tmpa) -- ++(-#2, 0pt); |
| 746 |
\edef\pgfplots@tick@UPPER@b{\csname pgfplots@\pgfplotspointonorientedsurfaceB max\endcsname}% |
| 747 |
\else |
| 748 |
% FALL BACK. never used, I guess? |
| 749 |
% (\pgfplots@xcoordminTEX-\pgfplots@tick@offset, \pgfplots@tmpa) -- ++( #2, 0pt); |
| 750 |
\edef\pgfplots@tick@LOWER@b{\csname pgfplots@\pgfplotspointonorientedsurfaceB min\endcsname}% |
| 751 |
\fi |
| 752 |
% |
| 753 |
\ifcase\csname pgfplots@#1tickalignnum\endcsname\relax |
| 754 |
\def\pgfplots@tick@offset{0}% |
| 755 |
\or |
| 756 |
\edef\pgfplots@tick@offset{#2}% |
| 757 |
\or |
| 758 |
\pgfmathmultiply@{0.5}{#2}% |
| 759 |
\let\pgfplots@tick@offset=\pgfmathresult% |
| 760 |
\fi |
| 761 |
% |
| 762 |
\edef\pgfplots@tick@LOWER@shiftbeg{-\pgfplots@tick@offset}% |
| 763 |
\pgfmathadd@{\pgfplots@tick@LOWER@shiftbeg}{#2}% |
| 764 |
\let\pgfplots@tick@LOWER@shiftend=\pgfmathresult |
| 765 |
% |
| 766 |
\edef\pgfplots@tick@UPPER@shiftbeg{\pgfplots@tick@offset}% |
| 767 |
\pgfmathsubtract@{\pgfplots@tick@UPPER@shiftbeg}{#2}% |
| 768 |
\let\pgfplots@tick@UPPER@shiftend=\pgfmathresult |
| 769 |
% |
| 770 |
% Assemble the \pgfplots@drawticklines@for@placecomputedtick |
| 771 |
% command. |
| 772 |
\def\pgfplots@drawticklines@for@placecomputedtick@LOWER{% |
| 773 |
\pgfpathmoveto{\pgfplotspointonorientedsurfaceabwithbshift{\pgfplots@curtickpos}{\pgfplots@tick@LOWER@b}{\pgfplots@tick@LOWER@shiftbeg pt}}% |
| 774 |
\pgfpathlineto{\pgfplotspointonorientedsurfaceabwithbshift{\pgfplots@curtickpos}{\pgfplots@tick@LOWER@b}{\pgfplots@tick@LOWER@shiftend pt}}% |
| 775 |
}% |
| 776 |
\def\pgfplots@drawticklines@for@placecomputedtick@UPPER{% |
| 777 |
\pgfpathmoveto{\pgfplotspointonorientedsurfaceabwithbshift{\pgfplots@curtickpos}{\pgfplots@tick@UPPER@b}{\pgfplots@tick@UPPER@shiftbeg pt}}% |
| 778 |
\pgfpathlineto{\pgfplotspointonorientedsurfaceabwithbshift{\pgfplots@curtickpos}{\pgfplots@tick@UPPER@b}{\pgfplots@tick@UPPER@shiftend pt}}% |
| 779 |
}% |
| 780 |
%\message{place computed tick: LOWEROK=\pgfplots@drawticklines@for@placecomputedtick@LOWEROK; UPPEROK=\pgfplots@drawticklines@for@placecomputedtick@UPPEROK.}% |
| 781 |
}% |
| 782 |
|
| 783 |
|
| 784 |
\newif\ifpgfplots@needsminorloop |
| 785 |
|
| 786 |
\def\pgfplots@draw@tick@scale@label@for#1{% |
| 787 |
\csname ifpgfplots@#1islinear\endcsname |
| 788 |
\begingroup |
| 789 |
\def\pgfplots@temp@isbaseten{0}% |
| 790 |
\ifcase\csname pgfplots@scaled@ticks@#1@choice\endcsname |
| 791 |
\global\let\pgfplots@glob@TMPa=\pgfutil@empty |
| 792 |
\or |
| 793 |
\xdef\pgfplots@glob@TMPa{\csname pgfplots@tick@scale@#1\endcsname}% |
| 794 |
\def\pgfplots@temp@isbaseten{1}% |
| 795 |
\or |
| 796 |
\xdef\pgfplots@glob@TMPa{\csname pgfplots@tick@scale@#1\endcsname}% |
| 797 |
\def\pgfplots@temp@isbaseten{1}% |
| 798 |
\or |
| 799 |
\xdef\pgfplots@glob@TMPa{\csname pgfplots@tick@scale@#1\endcsname}% |
| 800 |
% real: |
| 801 |
\or |
| 802 |
% manual: |
| 803 |
\global\def\pgfplots@glob@TMPa{dummyargument}% |
| 804 |
\fi |
| 805 |
\if1\pgfplots@temp@isbaseten |
| 806 |
\expandafter\c@pgf@counta\pgfplots@glob@TMPa\relax |
| 807 |
\multiply\c@pgf@counta by-1 |
| 808 |
\ifnum\c@pgf@counta=0\relax |
| 809 |
\global\let\pgfplots@glob@TMPa=\pgfutil@empty |
| 810 |
\else |
| 811 |
\xdef\pgfplots@glob@TMPa{\the\c@pgf@counta}% |
| 812 |
\fi |
| 813 |
\fi |
| 814 |
\endgroup |
| 815 |
\ifx\pgfplots@glob@TMPa\pgfutil@empty |
| 816 |
\else |
| 817 |
\begingroup |
| 818 |
\pgfkeysgetvalue{/pgfplots/#1tick scale label code/.@cmd}\pgfplots@loc@TMPa |
| 819 |
\ifx\pgfplots@loc@TMPa\pgfplots@empty@command@key |
| 820 |
\else |
| 821 |
\edef\pgfplots@tick@scale@labels{\noexpand\pgfplots@invoke@pgfkeyscode{/pgfplots/#1tick scale label code/.@cmd}{\pgfplots@glob@TMPa}}% |
| 822 |
% |
| 823 |
\pgfplots@change@pgfpoints@to@descriptioncs |
| 824 |
% |
| 825 |
\node[% |
| 826 |
/pgfplots/every tick label,% |
| 827 |
/pgfplots/every #1 tick label,% |
| 828 |
/pgfplots/every #1 tick scale label] |
| 829 |
{\pgfplots@tick@scale@labels}; |
| 830 |
\fi |
| 831 |
\endgroup |
| 832 |
\fi |
| 833 |
\fi |
| 834 |
} |
| 835 |
|
| 836 |
% Check if the current tick position, stored in \pgfplots@tmpa, |
| 837 |
% does not cross the y-axis. |
| 838 |
% |
| 839 |
% This is just a special case for centered axis lines. |
| 840 |
\def\pgfplots@xtick@check@tickshow{% |
| 841 |
\pgfplots@tickshowtrue |
| 842 |
% |
| 843 |
\pgfplots@if@has@axis@shift y{% |
| 844 |
\pgfplots@hide@obscured@xtickfalse |
| 845 |
}{}% |
| 846 |
% |
| 847 |
\ifpgfplots@hide@obscured@xtick |
| 848 |
\if\pgfplots@xaxislinesnum2% center |
| 849 |
\ifcase\pgfplots@yaxislinesnum\relax |
| 850 |
\pgfplotsmath@ifapproxequal@dim |
| 851 |
{\pgfplots@tmpa}{\pgfplots@limit@min@reg{x}} |
| 852 |
{\pgfplots@loc@tick@placement@tolerance} |
| 853 |
{% |
| 854 |
\pgfplots@tickshowfalse |
| 855 |
}{}% |
| 856 |
\pgfplotsmath@ifapproxequal@dim |
| 857 |
{\pgfplots@tmpa}{\pgfplots@limit@max@reg{x}} |
| 858 |
{\pgfplots@loc@tick@placement@tolerance} |
| 859 |
{% |
| 860 |
\pgfplots@tickshowfalse |
| 861 |
}{}% |
| 862 |
\or |
| 863 |
\pgfplotsmath@ifapproxequal@dim |
| 864 |
{\pgfplots@tmpa}{\pgfplots@limit@min@reg{x}} |
| 865 |
{\pgfplots@loc@tick@placement@tolerance} |
| 866 |
{% |
| 867 |
\pgfplots@tickshowfalse |
| 868 |
}{}% |
| 869 |
\or |
| 870 |
\pgfplotsmath@ifapproxequal@dim |
| 871 |
{\pgfplots@tmpa}{\pgfplots@logical@ZERO@x pt} |
| 872 |
{\pgfplots@loc@tick@placement@tolerance} |
| 873 |
{% |
| 874 |
\pgfplots@tickshowfalse |
| 875 |
}{}% |
| 876 |
\or |
| 877 |
\pgfplotsmath@ifapproxequal@dim |
| 878 |
{\pgfplots@tmpa}{\pgfplots@limit@max@reg{x}} |
| 879 |
{\pgfplots@loc@tick@placement@tolerance} |
| 880 |
{% |
| 881 |
\pgfplots@tickshowfalse |
| 882 |
}{}% |
| 883 |
\fi |
| 884 |
\fi |
| 885 |
\fi |
| 886 |
} |
| 887 |
|
| 888 |
% Draws extra ticks including grid lines, tick lines and tick labels |
| 889 |
% along the current oriented surface. |
| 890 |
% |
| 891 |
% See \pgfplots@drawticklines@onorientedsurf@ for a description of the |
| 892 |
% oriented surface. |
| 893 |
% |
| 894 |
% #1 : tick position list |
| 895 |
\def\pgfplots@draw@extra@ticks@onorientedsurf{% |
| 896 |
\expandafter\pgfplots@draw@extra@ticks@onorientedsurf@\pgfplotspointonorientedsurfaceA |
| 897 |
}% |
| 898 |
% #1: axis (x or y) |
| 899 |
% #2: tick position list |
| 900 |
\def\pgfplots@draw@extra@ticks@onorientedsurf@#1#2{% |
| 901 |
\begingroup |
| 902 |
\def\pgfplots@scaled@ticks@x@choice{0}% |
| 903 |
\def\pgfplots@scaled@ticks@y@choice{0}% |
| 904 |
\def\pgfplots@scaled@ticks@z@choice{0}% |
| 905 |
\csname pgfplots@#1minorticksfalse\endcsname |
| 906 |
\csname pgfplots@#1minorgridsfalse\endcsname |
| 907 |
\expandafter\let\expandafter\pgfplots@ticklabel@pos@orig\csname pgfplots@#1ticklabel@pos\endcsname% |
| 908 |
\expandafter\let\expandafter\axis@TMP\csname pgfplots@extra@#1ticklabel\endcsname |
| 909 |
\expandafter\let\csname pgfplots@#1ticklabel\endcsname=\axis@TMP |
| 910 |
% \pgfplotsset{/pgfplots/every extra #1 tick}% |
| 911 |
% use a scope here such that line width and draw color can be set. |
| 912 |
\scope[/pgfplots/.cd,/pgfplots/every extra #1 tick] |
| 913 |
\expandafter\let\expandafter\pgfplots@ticklabel@pos@\csname pgfplots@#1ticklabel@pos\endcsname |
| 914 |
\ifx\pgfplots@ticklabel@pos@\pgfplots@ticklabel@pos@orig |
| 915 |
\else |
| 916 |
\pgfplots@init@ticklabelaxisspec |
| 917 |
\fi |
| 918 |
\pgfplots@prepare@tick@coordlists@for{#1}{#2}% |
| 919 |
\pgfplots@drawgridlines@onorientedsurf% |
| 920 |
\pgfplots@drawticklines@onorientedsurf% |
| 921 |
\pgfplots@drawticklabels@onorientedsurf% |
| 922 |
\endscope |
| 923 |
\endgroup |
| 924 |
} |
| 925 |
|
| 926 |
% Computes final major and minor tick positions into global lists |
| 927 |
% \pgfplots@prepared@tick@positions@major@x |
| 928 |
% and |
| 929 |
% \pgfplots@prepared@tick@positions@minor@x. |
| 930 |
% |
| 931 |
% Both lists contain entries of the form {<index>}{<logical position>} |
| 932 |
% @see \pgfplots@prepared@tick@pos@unpack |
| 933 |
% |
| 934 |
% #1: the axis |
| 935 |
% #2: the tick list. |
| 936 |
% |
| 937 |
% PRECONDITION: |
| 938 |
% - \pgfplots@determinedefaultvalues has been executed. |
| 939 |
% That means particularly that \pgfplots@[xy][min,max] are available in TeX point |
| 940 |
% range (after datascaling and logs). |
| 941 |
% POSTCONDITION: |
| 942 |
% - the lists |
| 943 |
% \pgfplots@prepared@tick@positions@major@x |
| 944 |
% \pgfplots@prepared@tick@positions@major@tickindices@x |
| 945 |
% \pgfplots@prepared@tick@positions@minor@x |
| 946 |
% are ready. |
| 947 |
\def\pgfplots@prepare@tick@coordlists@for#1#2{% |
| 948 |
\begingroup |
| 949 |
\expandafter\let\expandafter\ifpgfplots@islinear\csname ifpgfplots@#1islinear\endcsname |
| 950 |
\expandafter\let\expandafter\ifpgfplots@minorticks\csname ifpgfplots@#1minorticks\endcsname |
| 951 |
\expandafter\let\expandafter\ifpgfplots@minorgrids\csname ifpgfplots@#1minorgrids\endcsname |
| 952 |
% these lists need to be global such that I can fill them inside |
| 953 |
% of \foreach statements. And, yes: I have also added a TeX group |
| 954 |
% on my own (but that's not the problem). |
| 955 |
\global\pgfplotslistnewempty\pgfplots@prepared@tick@positions@major |
| 956 |
%\global\pgfplotslistnewempty\pgfplots@prepared@tick@positions@major@tickindices |
| 957 |
\global\pgfplotslistnewempty\pgfplots@prepared@tick@positions@minor |
| 958 |
% |
| 959 |
\pgfplots@prepare@tick@coordlists@for@handletolerance#1% |
| 960 |
% |
| 961 |
\edef\pgfplots@loc@TMPa{#2}% |
| 962 |
\ifx\pgfplots@loc@TMPa\pgfutil@empty |
| 963 |
\else |
| 964 |
\ifpgfplots@minorticks |
| 965 |
\pgfplots@needsminorlooptrue |
| 966 |
\else |
| 967 |
\ifpgfplots@minorgrids |
| 968 |
\pgfplots@needsminorlooptrue |
| 969 |
\else |
| 970 |
\pgfplots@needsminorloopfalse |
| 971 |
\fi |
| 972 |
\fi |
| 973 |
\pgfkeysgetvalue{/pgfplots/minor #1tick}\pgfplots@minor@tick@list |
| 974 |
\ifx\pgfplots@minor@tick@list\pgfutil@empty |
| 975 |
\else |
| 976 |
\pgfplots@needsminorloopfalse |
| 977 |
\fi |
| 978 |
% |
| 979 |
\ifpgfplots@needsminorloop |
| 980 |
\ifpgfplots@islinear |
| 981 |
\pgfkeysgetvalue{/pgfplots/minor #1 tick num}\pgfplots@minor@tick@num |
| 982 |
\begingroup |
| 983 |
\c@pgf@counta=\pgfplots@minor@tick@num\relax |
| 984 |
\advance\c@pgf@counta by1\relax |
| 985 |
\pgfplots@tmpa=\csname pgfplots@tick@distance@#1\endcsname pt % |
| 986 |
\divide\pgfplots@tmpa by\c@pgf@counta |
| 987 |
\edef\pgfmathresult{\pgf@sys@tonumber{\pgfplots@tmpa}}% |
| 988 |
\pgfmath@smuggleone\pgfmathresult |
| 989 |
\endgroup |
| 990 |
\let\pgfplots@minor@tick@dist=\pgfmathresult |
| 991 |
\else |
| 992 |
\def\pgfplots@minor@tick@num{9}% |
| 993 |
\fi |
| 994 |
\fi |
| 995 |
% |
| 996 |
% Prepare the [xy]tick[min|max] key processing: |
| 997 |
\let\pgfplots@checktickminmax=\pgfutil@empty |
| 998 |
\expandafter\ifx\csname pgfplots@#1tickmin\endcsname\pgfutil@empty |
| 999 |
\else |
| 1000 |
\expandafter\def\expandafter\pgfplots@checktickminmax\expandafter{% |
| 1001 |
\pgfplots@checktickminmax |
| 1002 |
\pgfplots@prepare@tick@coordlists@for@checktickmin#1% |
| 1003 |
}% |
| 1004 |
\fi |
| 1005 |
\expandafter\ifx\csname pgfplots@#1tickmax\endcsname\pgfutil@empty |
| 1006 |
\else |
| 1007 |
\expandafter\def\expandafter\pgfplots@checktickminmax\expandafter{% |
| 1008 |
\pgfplots@checktickminmax |
| 1009 |
\pgfplots@prepare@tick@coordlists@for@checktickmax#1% |
| 1010 |
}% |
| 1011 |
\fi |
| 1012 |
% |
| 1013 |
% compute the last index because it won't receive minor ticks: |
| 1014 |
\gdef\pgfplots@glob@TMPd{-1}% |
| 1015 |
\foreach \x in {#2} {% |
| 1016 |
\pgfplotsutil@advancestringcounter@global\pgfplots@glob@TMPd |
| 1017 |
}% |
| 1018 |
\let\c@pgfplots@ticknum@last=\pgfplots@glob@TMPd |
| 1019 |
% |
| 1020 |
\gdef\pgfplots@glob@TMPa{0}% |
| 1021 |
\foreach \x in {#2} {% |
| 1022 |
\let\pgfplots@ticknum=\pgfplots@glob@TMPa |
| 1023 |
% |
| 1024 |
\pgfplots@prepare@tick@coordlists@for@assign\pgfplots@tmpa=\x |
| 1025 |
\csname pgfplots@#1tick@check@tickshow\endcsname |
| 1026 |
\pgfplots@prepare@tick@coordlists@for@checkdatalimits#1% |
| 1027 |
\pgfplots@checktickminmax |
| 1028 |
% |
| 1029 |
\ifpgfplots@tickshow |
| 1030 |
\edef\x{{\pgfplots@ticknum}{\x}}% |
| 1031 |
\expandafter\pgfplotslistpushbackglobal\x\to\pgfplots@prepared@tick@positions@major |
| 1032 |
%\expandafter\pgfplotslistpushbackglobal\pgfplots@ticknum\to\pgfplots@prepared@tick@positions@major@tickindices |
| 1033 |
\fi |
| 1034 |
% X-Axis ticks bottom and top |
| 1035 |
\ifpgfplots@needsminorloop |
| 1036 |
\ifnum\pgfplots@ticknum=\c@pgfplots@ticknum@last\relax |
| 1037 |
\else |
| 1038 |
% SEE BELOW for the 'minor #1tick' feature -- it has a |
| 1039 |
% separate loop. |
| 1040 |
\foreach \pgfplots@i in {1,...,\pgfplots@minor@tick@num} {% |
| 1041 |
% XXX : bug 165 [minor ticks] minor tick drawn after the last xtick |
| 1042 |
% seems to be here. Does that harm? |
| 1043 |
\ifpgfplots@islinear |
| 1044 |
\pgfmathmultiply@{\pgfplots@i}{\pgfplots@minor@tick@dist}% |
| 1045 |
\else |
| 1046 |
% in log: |
| 1047 |
% log( i*10^k ) = log\pgfplots@i + k\log10 -> draw ticks for i=1..9 |
| 1048 |
\pgfplotscoordmath{#1}{log unsigned int}{\pgfplots@i}% |
| 1049 |
\pgfplotscoordmath{#1}{tofixed}{\pgfmathresult}% |
| 1050 |
\fi |
| 1051 |
\pgfplots@prepare@tick@coordlists@for@advance\pgfplots@tmpa by\pgfmathresult |
| 1052 |
\pgfplots@tickshowtrue |
| 1053 |
\pgfplots@prepare@tick@coordlists@for@checkdatalimits#1% |
| 1054 |
\pgfplots@checktickminmax |
| 1055 |
\ifpgfplots@tickshow |
| 1056 |
\pgfplots@prepare@tick@coordlists@for@tofixed\pgfplots@tmpa |
| 1057 |
\c@pgf@counta=\pgfplots@ticknum\relax |
| 1058 |
\advance\c@pgf@counta by\pgfplots@i\relax |
| 1059 |
\edef\x{{\the\c@pgf@counta}{\pgfmathresult}}% |
| 1060 |
\expandafter\pgfplotslistpushbackglobal\x\to\pgfplots@prepared@tick@positions@minor |
| 1061 |
\fi |
| 1062 |
}% |
| 1063 |
\fi |
| 1064 |
\fi |
| 1065 |
\pgfplotsutil@advancestringcounter\pgfplots@ticknum |
| 1066 |
% carry \ticknum outside of this scope: |
| 1067 |
\global\let\pgfplots@glob@TMPa=\pgfplots@ticknum |
| 1068 |
}% |
| 1069 |
% |
| 1070 |
\ifx\pgfplots@minor@tick@list\pgfutil@empty |
| 1071 |
\else |
| 1072 |
% handle the 'minor #1tick' feature: |
| 1073 |
\def\pgfplots@loc@TMPa{\foreach \x in }% |
| 1074 |
\expandafter\pgfplots@loc@TMPa\expandafter{\pgfplots@minor@tick@list} {% |
| 1075 |
\let\pgfplots@ticknum=\pgfplots@glob@TMPa |
| 1076 |
% |
| 1077 |
\pgfplots@prepare@tick@coordlists@for@assign\pgfplots@tmpa=\x |
| 1078 |
\pgfplots@tickshowtrue |
| 1079 |
\pgfplots@prepare@tick@coordlists@for@checkdatalimits#1% |
| 1080 |
\pgfplots@checktickminmax |
| 1081 |
\ifpgfplots@tickshow |
| 1082 |
\edef\x{{\pgfplots@ticknum}{\x}}% |
| 1083 |
\expandafter\pgfplotslistpushbackglobal\x\to\pgfplots@prepared@tick@positions@minor |
| 1084 |
\fi |
| 1085 |
\pgfplotsutil@advancestringcounter\pgfplots@ticknum |
| 1086 |
% carry \ticknum outside of this scope: |
| 1087 |
\global\let\pgfplots@glob@TMPa=\pgfplots@ticknum |
| 1088 |
}% |
| 1089 |
\fi |
| 1090 |
\fi |
| 1091 |
\endgroup |
| 1092 |
\expandafter\let\csname pgfplots@prepared@tick@positions@minor@#1\endcsname=\pgfplots@prepared@tick@positions@minor |
| 1093 |
\expandafter\let\csname pgfplots@prepared@tick@positions@major@#1\endcsname=\pgfplots@prepared@tick@positions@major |
| 1094 |
%\expandafter\let\csname pgfplots@prepared@tick@positions@major@tickindices@#1\endcsname=\pgfplots@prepared@tick@positions@major@tickindices |
| 1095 |
\global\let\pgfplots@prepared@tick@positions@major=\relax |
| 1096 |
%\global\let\pgfplots@prepared@tick@positions@major@tickindices=\relax |
| 1097 |
\global\let\pgfplots@prepared@tick@positions@minor=\relax |
| 1098 |
}% |
| 1099 |
|
| 1100 |
% The following set of macros can be used to replace the TeX register |
| 1101 |
% arithmetics used to speed up the computations inside of |
| 1102 |
% \pgfplots@prepare@tick@coordlists@for by something different. |
| 1103 |
% |
| 1104 |
% FIXME : that is no clean programming! Perhaps a new math class |
| 1105 |
% should be used here, and implemented during the complete tick |
| 1106 |
% preparation!? |
| 1107 |
% |
| 1108 |
% Keep in mind that these tick positions are in "transformed |
| 1109 |
% range", i.e. they are expected to be in the range -16000...16000. At |
| 1110 |
% the time of this modification, only the smithchart lib needs special |
| 1111 |
% handling here... does this justify a re-design? |
| 1112 |
\def\pgfplots@prepare@tick@coordlists@for@assign#1=#2{% |
| 1113 |
#1=#2pt |
| 1114 |
}% |
| 1115 |
\def\pgfplots@prepare@tick@coordlists@for@advance#1by#2{% |
| 1116 |
\advance#1 by#2 pt % |
| 1117 |
}% |
| 1118 |
\def\pgfplots@prepare@tick@coordlists@for@tofixed#1{% |
| 1119 |
\edef\pgfmathresult{\pgf@sys@tonumber{#1}}% |
| 1120 |
}% |
| 1121 |
\def\pgfplots@prepare@tick@coordlists@for@handletolerance#1{% |
| 1122 |
\afterassignment\pgfplots@gobble@until@relax |
| 1123 |
\pgfplots@tmpa=\pgfkeysvalueof{/pgfplots/#1tick placement tolerance}pt\relax |
| 1124 |
\pgfplots@tmpa=\csname pgfplots@#1@inverseveclength\endcsname\pgfplots@tmpa |
| 1125 |
\edef\pgfplots@loc@tick@placement@tolerance{\the\pgfplots@tmpa}% |
| 1126 |
% |
| 1127 |
\advance\csname pgfplots@#1min@reg\endcsname by-\pgfplots@tmpa |
| 1128 |
\advance\csname pgfplots@#1max@reg\endcsname by\pgfplots@tmpa |
| 1129 |
}% |
| 1130 |
\def\pgfplots@prepare@tick@coordlists@for@checktickmin#1{% |
| 1131 |
\ifdim\pgfplots@tmpa<\csname pgfplots@#1tickmin\endcsname pt |
| 1132 |
\pgfplots@tickshowfalse |
| 1133 |
\fi |
| 1134 |
}% |
| 1135 |
\def\pgfplots@prepare@tick@coordlists@for@checktickmax#1{% |
| 1136 |
\ifdim\pgfplots@tmpa>\csname pgfplots@#1tickmax\endcsname pt |
| 1137 |
\pgfplots@tickshowfalse |
| 1138 |
\fi |
| 1139 |
}% |
| 1140 |
\def\pgfplots@prepare@tick@coordlists@for@checkdatalimits#1{% |
| 1141 |
\ifdim\pgfplots@tmpa<\csname pgfplots@#1min@reg\endcsname |
| 1142 |
\pgfplots@tickshowfalse |
| 1143 |
\else |
| 1144 |
\ifdim\pgfplots@tmpa>\csname pgfplots@#1max@reg\endcsname |
| 1145 |
\pgfplots@tickshowfalse |
| 1146 |
\fi |
| 1147 |
\fi |
| 1148 |
}% |
| 1149 |
|
| 1150 |
% Unpacks entries of the \pgfplots@prepared@tick@positions@* lists. |
| 1151 |
% |
| 1152 |
% Defines \pgfplots@tick to be the actual tick position and |
| 1153 |
% \pgfplots@ticknum to be its index. |
| 1154 |
% |
| 1155 |
% Usage: |
| 1156 |
% \expandafter\pgfplots@prepared@tick@pos@unpack\entry |
| 1157 |
\def\pgfplots@prepared@tick@pos@unpack#1#2{% |
| 1158 |
\def\pgfplots@tick{#2}% |
| 1159 |
\def\pgfplots@ticknum{#1}% |
| 1160 |
} |
| 1161 |
|
| 1162 |
% Draws grid lines at the a-positions of the currently set oriented |
| 1163 |
% surface. |
| 1164 |
% |
| 1165 |
% Tick positions are taken out of the already precomputed list |
| 1166 |
% \pgfplots@prepared@tick@positions@major@... |
| 1167 |
% |
| 1168 |
% See \pgfplots@drawticklines@onorientedsurf@ for a description of the |
| 1169 |
% oriented surface. |
| 1170 |
% |
| 1171 |
% #1 : the verbatim axis name (either 'x' or 'y') |
| 1172 |
% #2 : the index of the axis (either 0 or 1) |
| 1173 |
\def\pgfplots@drawgridlines@onorientedsurf{% |
| 1174 |
\expandafter\pgfplots@drawgridlines@onorientedsurf@\pgfplotspointonorientedsurfaceA |
| 1175 |
}% |
| 1176 |
\def\pgfplots@drawgridlines@onorientedsurf@#1{% |
| 1177 |
\pgfplots@if{pgfplots@shownothingof@\pgfplotspointonorientedsurfaceB}{% |
| 1178 |
\relax |
| 1179 |
}{% |
| 1180 |
\begingroup |
| 1181 |
\pgfplots@ifgridlines@onorientedsurf@should@be@drawn{% |
| 1182 |
\expandafter\let\expandafter\pgfplots@prepared@tick@positions@major@\csname pgfplots@prepared@tick@positions@major@#1\endcsname |
| 1183 |
\expandafter\let\expandafter\pgfplots@prepared@tick@positions@minor@\csname pgfplots@prepared@tick@positions@minor@#1\endcsname |
| 1184 |
\pgfplots@loop@CONTINUEfalse |
| 1185 |
\pgfplots@if{pgfplots@#1majorgrids}{\pgfplots@loop@CONTINUEtrue}{}% |
| 1186 |
\pgfplots@if{pgfplots@#1minorgrids}{\pgfplots@loop@CONTINUEtrue}{}% |
| 1187 |
\ifpgfplots@loop@CONTINUE |
| 1188 |
% I support only ONE layer for both, minor and major |
| 1189 |
% grid lines -- no distinction! I am lazy... FIXME |
| 1190 |
\pgfplotsgetlayerforstyle{% |
| 1191 |
every axis grid,% |
| 1192 |
every minor grid,% |
| 1193 |
every axis #1 grid,% |
| 1194 |
every major grid,% |
| 1195 |
every minor #1 grid,% |
| 1196 |
every major #1 grid% |
| 1197 |
}% |
| 1198 |
\pgfplotsonlayer{\pgfplotsretval}{#1 grid style}% |
| 1199 |
\scope |
| 1200 |
\pgfplots@drawgridlines@INSTALLCLIP@onorientedsurf#1% |
| 1201 |
% |
| 1202 |
\pgfplots@if{pgfplots@#1minorgrids}{% |
| 1203 |
\draw[% |
| 1204 |
/pgfplots/every axis grid, |
| 1205 |
/pgfplots/every minor grid, |
| 1206 |
/pgfplots/every axis #1 grid, |
| 1207 |
/pgfplots/every minor #1 grid]% |
| 1208 |
\pgfextra |
| 1209 |
\pgfplotslistforeach\pgfplots@prepared@tick@positions@minor@\as\pgfplots@curgridpos{% |
| 1210 |
\expandafter\pgfplots@prepared@tick@pos@unpack\pgfplots@curgridpos |
| 1211 |
\pgfplots@drawgridlines@onorientedsurf@fromto\pgfplots@tick |
| 1212 |
}% |
| 1213 |
\endpgfextra; |
| 1214 |
}{}% |
| 1215 |
% |
| 1216 |
\pgfplots@if{pgfplots@#1majorgrids}{% |
| 1217 |
\draw[% |
| 1218 |
/pgfplots/every axis grid, |
| 1219 |
/pgfplots/every major grid, |
| 1220 |
/pgfplots/every axis #1 grid, |
| 1221 |
/pgfplots/every major #1 grid]% |
| 1222 |
\pgfextra |
| 1223 |
\pgfplotslistforeach\pgfplots@prepared@tick@positions@major@\as\pgfplots@curgridpos{% |
| 1224 |
\expandafter\pgfplots@prepared@tick@pos@unpack\pgfplots@curgridpos |
| 1225 |
\pgfplots@drawgridlines@onorientedsurf@fromto\pgfplots@tick |
| 1226 |
}% |
| 1227 |
\endpgfextra; |
| 1228 |
}{}% |
| 1229 |
% |
| 1230 |
\endscope |
| 1231 |
\endpgfplotsonlayer |
| 1232 |
\fi |
| 1233 |
}{}% |
| 1234 |
\endgroup |
| 1235 |
}% |
| 1236 |
} |
| 1237 |
|
| 1238 |
% Should draw a single grid line on the actual oriented surface. |
| 1239 |
% #1 the value of the grid line. |
| 1240 |
% |
| 1241 |
% PRECONDITION |
| 1242 |
% \pgfplots@ticknum contains the index of the current tick. |
| 1243 |
\def\pgfplots@drawgridlines@onorientedsurf@fromto#1{% |
| 1244 |
\pgfpathmoveto{\pgfplotspointonorientedsurfaceab{#1}{\csname pgfplots@\pgfplotspointonorientedsurfaceB min\endcsname}}% |
| 1245 |
\pgfpathlineto{\pgfplotspointonorientedsurfaceab{#1}{\csname pgfplots@\pgfplotspointonorientedsurfaceB max\endcsname}}% |
| 1246 |
}% |
| 1247 |
|
| 1248 |
% Implements 'axis x line shift' and its friends. |
| 1249 |
% |
| 1250 |
% It is called by grid line drawing instructions, tick lines, and tick |
| 1251 |
% labels and installs a common shift. The purpose is to shift the |
| 1252 |
% _entire_ axis along the outer normal. |
| 1253 |
% |
| 1254 |
% The operation is supposed to be used when an oriented surf is |
| 1255 |
% installed. |
| 1256 |
% |
| 1257 |
% #1 used to determine the axis for which the outer normal is to be |
| 1258 |
% determined. #1 is the 'a' value of the current oriented surf, i.e. |
| 1259 |
% one of 0, 1, 2, or v. |
| 1260 |
% |
| 1261 |
% #2 same as '#1', but this here determines the 'b' value of the |
| 1262 |
% current oriented surf. |
| 1263 |
% |
| 1264 |
% exactly one of '#1' or '#2' must be 'v' such that a unique line can |
| 1265 |
% be identified. |
| 1266 |
\def\pgfplots@transformshift@along@outer@normal@on@line@of@oriented@surf#1#2{% |
| 1267 |
\if v#1% |
| 1268 |
\let\pgfplots@loc@TMPa=\pgfplotspointonorientedsurfaceA% |
| 1269 |
\if v#2% |
| 1270 |
\pgfplots@error{Exactly one of '#1' or '#2' must be 'v', not both}% |
| 1271 |
\fi |
| 1272 |
\else |
| 1273 |
\if v#2% |
| 1274 |
\let\pgfplots@loc@TMPa=\pgfplotspointonorientedsurfaceB% |
| 1275 |
\else |
| 1276 |
\pgfplots@error{One of '#1' or '#2' must be 'v'}% |
| 1277 |
\fi |
| 1278 |
\fi |
| 1279 |
% |
| 1280 |
\pgfkeysgetvalue{/pgfplots/axis \pgfplots@loc@TMPa\space line shift}\pgfplots@loc@TMPb |
| 1281 |
\ifx\pgfplots@loc@TMPb\pgfutil@empty |
| 1282 |
\else |
| 1283 |
% in this case, we KNOW that is is |
| 1284 |
% (a) parsed and |
| 1285 |
% (b) nonzero and |
| 1286 |
% (c) a dimension WITHOUT unit |
| 1287 |
% See \pgfplots@init@axis@shift |
| 1288 |
\ifpgfplots@separate@axis@lines |
| 1289 |
\else |
| 1290 |
\pgfplots@error{Internal error encountered: separate axis lines=false but axis shift found}% |
| 1291 |
\fi |
| 1292 |
\pgftransformshift{% |
| 1293 |
\expandafter\pgfqpointscale\expandafter{\pgfplots@loc@TMPb}{% |
| 1294 |
\begingroup |
| 1295 |
\pgf@process{% |
| 1296 |
\pgfplotspointonorientedsurfaceabtolinespec{#1}{#2}% |
| 1297 |
\expandafter\pgfplotspointouternormalvectorofaxis\expandafter{\pgfplotsretval}% |
| 1298 |
}% |
| 1299 |
\endgroup |
| 1300 |
}% |
| 1301 |
}% |
| 1302 |
\fi |
| 1303 |
}% |
| 1304 |
\let\pgfplots@transformshift@along@outer@normal@on@line@of@oriented@surf@orig=\pgfplots@transformshift@along@outer@normal@on@line@of@oriented@surf |
| 1305 |
|
| 1306 |
% Draws ticks on the currently active "oriented surface". |
| 1307 |
% |
| 1308 |
% The oriented surface is two dimensional and has been initialised |
| 1309 |
% with \pgfplotspointonorientedsurfaceabsetupfor*** somehow. |
| 1310 |
% |
| 1311 |
% The idea is now the following: |
| 1312 |
% - the tick positions change along the FIRST coordinate of this |
| 1313 |
% surface: |
| 1314 |
% |
| 1315 |
% x ---- x ---- x ---- x |
| 1316 |
% --> FIRST --> |
| 1317 |
% |
| 1318 |
% - the tick lines are drawn along the SECOND coordinate of this |
| 1319 |
% surface: |
| 1320 |
% |
| 1321 |
% | ---- | ---- | ---- | | SECOND |
| 1322 |
% | | | | v |
| 1323 |
% |
| 1324 |
% for example, |
| 1325 |
% \pgfplotspointonorientedsurfaceab@setupfor@xyZ{1} |
| 1326 |
% \pgfplots@drawticklines@onorientedsurf |
| 1327 |
% will draw ticks at x-positions designated by \pgfplots@xtick. The |
| 1328 |
% small tick lines will be drawn along the y axis. For each processed |
| 1329 |
% point, the z coordinate will be fixed to '1'. |
| 1330 |
% |
| 1331 |
% Another example: |
| 1332 |
% \pgfplotspointonorientedsurfaceab@setupfor@yxZ{-1} |
| 1333 |
% \pgfplots@drawticklines@onorientedsurf |
| 1334 |
% will draw ticks at y-positions designated by \pgfplots@ytick. The |
| 1335 |
% small tick lines will be drawn along the x axis. For each processed |
| 1336 |
% point, the z coordinate will be fixed to '-1'. |
| 1337 |
% |
| 1338 |
% Tick positions are taken out of the already precomputed list |
| 1339 |
% \pgfplots@prepared@tick@positions@major@... |
| 1340 |
\def\pgfplots@drawticklines@onorientedsurf{% |
| 1341 |
\expandafter\pgfplots@drawticklines@onorientedsurf@\pgfplotspointonorientedsurfaceA |
| 1342 |
}% |
| 1343 |
|
| 1344 |
\def\pgfplots@drawticklines@INSTALLCLIP@onorientedsurf#1{% |
| 1345 |
\pgfplots@drawtickgridlines@INSTALLCLIP@onorientedsurf{#1}% |
| 1346 |
}% |
| 1347 |
\def\pgfplots@drawgridlines@INSTALLCLIP@onorientedsurf#1{% |
| 1348 |
\pgfplots@drawtickgridlines@INSTALLCLIP@onorientedsurf{#1}% |
| 1349 |
}% |
| 1350 |
% Avoids tick lines which are too thick by introducing a clipping |
| 1351 |
% region. Tick lines (and grid lines) won't extend to the left or |
| 1352 |
% right of axis #1. |
| 1353 |
\def\pgfplots@drawtickgridlines@INSTALLCLIP@onorientedsurf#1{% |
| 1354 |
\ifpgfplots@enable@tick@line@clipping |
| 1355 |
% this is LEGACY SUPPORT only. I did not want to change |
| 1356 |
% existing bounding boxes. |
| 1357 |
% Starting with 'compat=1.11', this is OFF. |
| 1358 |
\pgfplots@drawtickgridlines@INSTALLCLIP@onorientedsurf@{#1}% |
| 1359 |
\fi |
| 1360 |
} |
| 1361 |
\def\pgfplots@drawtickgridlines@INSTALLCLIP@onorientedsurf@#1{% |
| 1362 |
\pgfinterruptboundingbox% |
| 1363 |
\begingroup |
| 1364 |
% the case ||e_b|| == 0 should never happen here! Should be |
| 1365 |
% caught before entering this routine. |
| 1366 |
\let\pgfplots@loc@LENGTH=\pgfmathresult |
| 1367 |
\expandafter\let\expandafter\pgfplots@loc@MIN\csname pgfplots@\pgfplotspointonorientedsurfaceB min\endcsname |
| 1368 |
\expandafter\let\expandafter\pgfplots@loc@MAX\csname pgfplots@\pgfplotspointonorientedsurfaceB max\endcsname |
| 1369 |
\pgfpathmoveto{\pgfplotspointonorientedsurfaceabwithbshift{\csname pgfplots@#1min\endcsname}{\pgfplots@loc@MIN}{-5cm}}% |
| 1370 |
\pgfpathlineto{\pgfplotspointonorientedsurfaceabwithbshift{\csname pgfplots@#1max\endcsname}{\pgfplots@loc@MIN}{-5cm}}% |
| 1371 |
\pgfpathlineto{\pgfplotspointonorientedsurfaceabwithbshift{\csname pgfplots@#1max\endcsname}{\pgfplots@loc@MAX}{5cm}}% |
| 1372 |
\pgfpathlineto{\pgfplotspointonorientedsurfaceabwithbshift{\csname pgfplots@#1min\endcsname}{\pgfplots@loc@MAX}{5cm}}% |
| 1373 |
\pgfusepath{clip}% |
| 1374 |
\endgroup |
| 1375 |
\endpgfinterruptboundingbox% |
| 1376 |
}% |
| 1377 |
|
| 1378 |
\def\pgfplots@drawticklines@onorientedsurf@#1{% |
| 1379 |
\pgfplots@if{pgfplots@shownothingof@\pgfplotspointonorientedsurfaceB}{% |
| 1380 |
\relax |
| 1381 |
}{% |
| 1382 |
\begingroup |
| 1383 |
% FIXME : the case of centered axis lines is missing here. |
| 1384 |
% 0 = lower limit, |
| 1385 |
% 1 = upper limit |
| 1386 |
% 2 = centered... |
| 1387 |
% Currently, "0" is also used for centered axis lines. |
| 1388 |
\if 2\csname pgfplots@\pgfplotspointonorientedsurfaceA axislinesnum\endcsname |
| 1389 |
% centered axis lines need no complicated visibility |
| 1390 |
% checks. They need tick lines in *any* case. |
| 1391 |
% So, enabled them here! |
| 1392 |
\def\pgfplots@drawticklines@for@placecomputedtick@LOWEROK{1}% |
| 1393 |
% |
| 1394 |
% UPPEROK is unnecessary in this context - for centered |
| 1395 |
% axis lines, it will be disabled anyway because the |
| 1396 |
% styles like 'axis x line*' set \pgfplots@xticknum to |
| 1397 |
% center - and that means that no tick lines will be drawn |
| 1398 |
% (see below). |
| 1399 |
\def\pgfplots@drawticklines@for@placecomputedtick@UPPEROK{0}% |
| 1400 |
\else |
| 1401 |
\pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn{0}{% |
| 1402 |
\def\pgfplots@drawticklines@for@placecomputedtick@LOWEROK{1}% |
| 1403 |
}{% |
| 1404 |
\def\pgfplots@drawticklines@for@placecomputedtick@LOWEROK{0}% |
| 1405 |
}% |
| 1406 |
\pgfplots@ifaxisline@B@onorientedsurf@should@be@drawn{1}{% |
| 1407 |
\def\pgfplots@drawticklines@for@placecomputedtick@UPPEROK{1}% |
| 1408 |
}{% |
| 1409 |
\def\pgfplots@drawticklines@for@placecomputedtick@UPPEROK{0}% |
| 1410 |
}% |
| 1411 |
\fi |
| 1412 |
\if\pgfkeysvalueof{/pgfplots/\pgfplotspointonorientedsurfaceB\space dir/value}r% |
| 1413 |
% local special handling for reversed axes: exchange |
| 1414 |
% meaning of 'left' and 'right' here. |
| 1415 |
% |
| 1416 |
% the rest of the pgfplots code does that automatically because |
| 1417 |
% there, tickposnum is relevant to determine the axes |
| 1418 |
% which contains tick labels. And this algorithm checks |
| 1419 |
% for reversed axes implicitly. |
| 1420 |
% |
| 1421 |
\if1\csname pgfplots@\pgfplotspointonorientedsurfaceA tickposnum\endcsname |
| 1422 |
\expandafter\def\csname pgfplots@\pgfplotspointonorientedsurfaceA tickposnum\endcsname{3}% |
| 1423 |
\else |
| 1424 |
\if3\csname pgfplots@\pgfplotspointonorientedsurfaceA tickposnum\endcsname |
| 1425 |
\expandafter\def\csname pgfplots@\pgfplotspointonorientedsurfaceA tickposnum\endcsname{1}% |
| 1426 |
\fi |
| 1427 |
\fi |
| 1428 |
\fi |
| 1429 |
\ifcase\csname pgfplots@\pgfplotspointonorientedsurfaceA tickposnum\endcsname\relax |
| 1430 |
% both |
| 1431 |
\or |
| 1432 |
% lower |
| 1433 |
\def\pgfplots@drawticklines@for@placecomputedtick@UPPEROK{0}% |
| 1434 |
\or |
| 1435 |
% center |
| 1436 |
\def\pgfplots@drawticklines@for@placecomputedtick@UPPEROK{0}% |
| 1437 |
\or |
| 1438 |
% upper |
| 1439 |
\def\pgfplots@drawticklines@for@placecomputedtick@LOWEROK{0}% |
| 1440 |
\else |
| 1441 |
% never used? |
| 1442 |
\def\pgfplots@drawticklines@for@placecomputedtick@UPPEROK{0}% |
| 1443 |
\fi |
| 1444 |
\expandafter\let\expandafter\pgfplots@prepared@tick@positions@major@\csname pgfplots@prepared@tick@positions@major@#1\endcsname |
| 1445 |
\expandafter\let\expandafter\pgfplots@prepared@tick@positions@minor@\csname pgfplots@prepared@tick@positions@minor@#1\endcsname |
| 1446 |
% |
| 1447 |
% There is only ONE layer for both, minor and major |
| 1448 |
% tick lines -- no distinction! |
| 1449 |
\pgfplotsgetlayerforstyle{% |
| 1450 |
every tick,% |
| 1451 |
every minor tick,% |
| 1452 |
every #1 tick,% |
| 1453 |
every major tick,% |
| 1454 |
every minor #1 tick,% |
| 1455 |
every major #1 tick% |
| 1456 |
}% |
| 1457 |
\pgfplotsonlayer{\pgfplotsretval}{#1tick style}% |
| 1458 |
\scope |
| 1459 |
\pgfplots@drawticklines@INSTALLCLIP@onorientedsurf#1 |
| 1460 |
% |
| 1461 |
\pgfplots@if{pgfplots@#1minorticks}{% |
| 1462 |
\draw[% |
| 1463 |
/pgfplots/every tick, |
| 1464 |
/pgfplots/every minor tick, |
| 1465 |
/pgfplots/every #1 tick, |
| 1466 |
/pgfplots/every minor #1 tick]% |
| 1467 |
\pgfextra |
| 1468 |
\pgfmathparse{\pgfplots@subtickwidth}% |
| 1469 |
\let\pgfplots@subtickwidth@=\pgfmathresult |
| 1470 |
\let\pgfplots@subtickwidth@=\pgfmathresult |
| 1471 |
\let\pgfplots@subtickwidth=\pgfmathresult |
| 1472 |
\pgfplots@prepare@tick@offsets@for@{#1}{\pgfplots@subtickwidth@}% |
| 1473 |
\if\pgfplots@drawticklines@for@placecomputedtick@LOWEROK1% |
| 1474 |
\begingroup |
| 1475 |
\pgfplots@transformshift@along@outer@normal@on@line@of@oriented@surf v0% |
| 1476 |
\pgfplotslistforeach\pgfplots@prepared@tick@positions@minor@\as\pgfplots@curtickpos{% |
| 1477 |
\expandafter\pgfplots@prepared@tick@pos@unpack\pgfplots@curtickpos |
| 1478 |
\let\pgfplots@curtickpos=\pgfplots@tick |
| 1479 |
\pgfplotspointouternormalvectorofaxissetv{}{\pgfplots@curtickpos}% |
| 1480 |
\pgfplots@drawticklines@for@placecomputedtick@LOWER |
| 1481 |
}% |
| 1482 |
\endgroup |
| 1483 |
\fi |
| 1484 |
% |
| 1485 |
\if\pgfplots@drawticklines@for@placecomputedtick@UPPEROK1% |
| 1486 |
\begingroup |
| 1487 |
\pgfplots@transformshift@along@outer@normal@on@line@of@oriented@surf v1% |
| 1488 |
\pgfplotslistforeach\pgfplots@prepared@tick@positions@minor@\as\pgfplots@curtickpos{% |
| 1489 |
\expandafter\pgfplots@prepared@tick@pos@unpack\pgfplots@curtickpos |
| 1490 |
\let\pgfplots@curtickpos=\pgfplots@tick |
| 1491 |
\pgfplotspointouternormalvectorofaxissetv{}{\pgfplots@curtickpos}% |
| 1492 |
\pgfplots@drawticklines@for@placecomputedtick@UPPER |
| 1493 |
}% |
| 1494 |
\endgroup |
| 1495 |
\fi |
| 1496 |
\endpgfextra; |
| 1497 |
}{}% |
| 1498 |
% |
| 1499 |
\pgfplots@if{pgfplots@#1majorticks}{% |
| 1500 |
\draw[% |
| 1501 |
/pgfplots/every tick, |
| 1502 |
/pgfplots/every major tick, |
| 1503 |
/pgfplots/every #1 tick, |
| 1504 |
/pgfplots/every major #1 tick]% |
| 1505 |
\pgfextra |
| 1506 |
\pgfmathparse{\pgfplots@tickwidth}% |
| 1507 |
\let\pgfplots@tickwidth@=\pgfmathresult |
| 1508 |
\let\pgfplots@tickwidth@=\pgfmathresult |
| 1509 |
\let\pgfplots@tickwidth=\pgfmathresult |
| 1510 |
\pgfplots@prepare@tick@offsets@for@{#1}{\pgfplots@tickwidth@}% |
| 1511 |
\if\pgfplots@drawticklines@for@placecomputedtick@LOWEROK1% |
| 1512 |
\begingroup |
| 1513 |
\pgfplots@transformshift@along@outer@normal@on@line@of@oriented@surf v0% |
| 1514 |
\pgfplotslistforeach\pgfplots@prepared@tick@positions@major@\as\pgfplots@curtickpos{% |
| 1515 |
\expandafter\pgfplots@prepared@tick@pos@unpack\pgfplots@curtickpos |
| 1516 |
\let\pgfplots@curtickpos=\pgfplots@tick |
| 1517 |
\pgfplotspointouternormalvectorofaxissetv{}{\pgfplots@curtickpos}% |
| 1518 |
\pgfplots@drawticklines@for@placecomputedtick@LOWER |
| 1519 |
}% |
| 1520 |
\endgroup |
| 1521 |
\fi |
| 1522 |
% |
| 1523 |
\if\pgfplots@drawticklines@for@placecomputedtick@UPPEROK1% |
| 1524 |
\begingroup |
| 1525 |
\pgfplots@transformshift@along@outer@normal@on@line@of@oriented@surf v1% |
| 1526 |
\pgfplotslistforeach\pgfplots@prepared@tick@positions@major@\as\pgfplots@curtickpos{% |
| 1527 |
\expandafter\pgfplots@prepared@tick@pos@unpack\pgfplots@curtickpos |
| 1528 |
\let\pgfplots@curtickpos=\pgfplots@tick |
| 1529 |
\pgfplotspointouternormalvectorofaxissetv{}{\pgfplots@curtickpos}% |
| 1530 |
\pgfplots@drawticklines@for@placecomputedtick@UPPER |
| 1531 |
}% |
| 1532 |
\endgroup |
| 1533 |
\fi |
| 1534 |
\endpgfextra; |
| 1535 |
}{}% |
| 1536 |
% |
| 1537 |
\endscope |
| 1538 |
\endpgfplotsonlayer |
| 1539 |
\endgroup |
| 1540 |
}% |
| 1541 |
} |
| 1542 |
|
| 1543 |
% Draws tick labels at the positions of the currently set oriented |
| 1544 |
% surface. |
| 1545 |
% |
| 1546 |
% Tick positions are taken out of the already precomputed list |
| 1547 |
% \pgfplots@prepared@tick@positions@major@... |
| 1548 |
% |
| 1549 |
% For 2D axes, this task is relatively simple: |
| 1550 |
% we iterate through every prepared major tick position and place a |
| 1551 |
% tick label. Open points, however, are the question whether to use |
| 1552 |
% the RIGHT or the LEFT axis line on the current oriented surface: |
| 1553 |
% |
| 1554 |
% direction 'b' (second oriented) |
| 1555 |
% |-------------------------| |
| 1556 |
% | | |
| 1557 |
% | | |
| 1558 |
% | |direction 'a' (first oriented) |
| 1559 |
% | | |
| 1560 |
% | | |
| 1561 |
% | | |
| 1562 |
% |-------------------------| |
| 1563 |
% Left Right |
| 1564 |
% |
| 1565 |
% Given the axis line which shall contain the labels, we have to |
| 1566 |
% decide how to align the tick label nodes: on the left or on the |
| 1567 |
% right? Of course, we want to align them such that they are "outside" |
| 1568 |
% of the figure! That's simple as well: "Left axis line => outside |
| 1569 |
% means left", "Right axis line => outside means right". |
| 1570 |
% |
| 1571 |
% That's all, basically. |
| 1572 |
% |
| 1573 |
% For 3D axes, all these points are basically ... the same! |
| 1574 |
% Now it can happen that the current oriented surface shall |
| 1575 |
% not contain ANY tick label. In that case, we do nothing. |
| 1576 |
% Furthermore, the "outside" direction (i.e. the anchoring of the |
| 1577 |
% label nodes) is a little bit more difficult. |
| 1578 |
% |
| 1579 |
% |
| 1580 |
% See \pgfplots@drawticklines@onorientedsurf@ for a description of the |
| 1581 |
% oriented surface. |
| 1582 |
\def\pgfplots@drawticklabels@onorientedsurf{% |
| 1583 |
\expandafter\pgfplots@drawticklabels@onorientedsurf@\pgfplotspointonorientedsurfaceA |
| 1584 |
} |
| 1585 |
\def\pgfplots@drawticklabels@onorientedsurf@#1{% |
| 1586 |
\begingroup |
| 1587 |
\expandafter\let\expandafter\pgfplots@prepared@tick@positions@major@\csname pgfplots@prepared@tick@positions@major@#1\endcsname |
| 1588 |
% check whether |
| 1589 |
% - we need to place tick labels on the LEFT side, |
| 1590 |
% - we need to place tick labels on the RIGHT side, |
| 1591 |
% - we don't need tick labels for the current surface at all: |
| 1592 |
\pgfplotspointonorientedsurfaceabmatchaxisline{\csname pgfplots@#1ticklabelaxisspec\endcsname}{\pgfplots@ticklabelside}% |
| 1593 |
\ifx\pgfplots@ticklabelside\pgfutil@empty |
| 1594 |
% SKIP. The current oriented surface shall not get tick labels |
| 1595 |
% for #1. |
| 1596 |
\else |
| 1597 |
\pgfplots@if{pgfplots@#1majorticks}{% |
| 1598 |
\pgfplots@if{pgfplots@#1islinear}{% |
| 1599 |
\pgfplots@init@scaled@tick@for{#1}% |
| 1600 |
}{\relax}% |
| 1601 |
\begingroup |
| 1602 |
\pgfplotsgetlayerforstyle{every tick label,every #1 tick label}% |
| 1603 |
\pgfplotsonlayer\pgfplotsretval{#1tick label style}% |
| 1604 |
\pgfkeysalso{/tikz/every node/.append style={/pgfplots/every tick label,/pgfplots/every #1 tick label}}% |
| 1605 |
\pgfplots@drawticklabels@onorientedsurf@prepareanchor#1% |
| 1606 |
% |
| 1607 |
\pgfplotsmath@ifzero{\csname pgfplots@\pgfplotspointonorientedsurfaceB @veclength\endcsname}{% |
| 1608 |
\def\pgfplots@tick@offset{0}% |
| 1609 |
}{% |
| 1610 |
\ifcase\csname pgfplots@#1tickalignnum\endcsname\relax |
| 1611 |
\def\pgfmathresult{0}% |
| 1612 |
\or |
| 1613 |
\pgfmathparse{\pgfplots@tickwidth}% |
| 1614 |
\or |
| 1615 |
\pgfmathmultiply{0.5}{\pgfplots@tickwidth}% |
| 1616 |
\fi |
| 1617 |
\let\pgfplots@tick@offset=\pgfmathresult |
| 1618 |
\pgfplots@ticklabel@maxtickdimen@extrashift{#1}{\pgfplots@tick@offset}% |
| 1619 |
%\pgfmathmultiply@{\pgfplots@tick@offset}{\csname pgfplots@\pgfplotspointonorientedsurfaceB @inverseveclength\endcsname}% |
| 1620 |
\let\pgfplots@tick@offset=\pgfmathresult |
| 1621 |
}% |
| 1622 |
% |
| 1623 |
\if2\csname pgfplots@#1axislinesnum\endcsname % Centered axis lines? |
| 1624 |
\expandafter\let\expandafter\pgfplots@tick@origin\csname pgfplots@logical@ZERO@\pgfplotspointonorientedsurfaceB\endcsname% |
| 1625 |
% FIXME : that stuff here does not respect |
| 1626 |
% '[xyz]tickpos num' keys! |
| 1627 |
\pgfplots@tickposchoiceb%<-- backw. compat, is usually empty. |
| 1628 |
\if r\pgfkeysvalueof{/pgfplots/\pgfplotspointonorientedsurfaceB\space dir/value}% |
| 1629 |
% special handling for reversed axes. |
| 1630 |
\pgfmathmultiply{-1}{\pgfplots@tick@offset}% |
| 1631 |
\let\pgfplots@tick@offset=\pgfmathresult |
| 1632 |
\fi |
| 1633 |
\edef\pgfplots@tick@offset{-\pgfplots@tick@offset}% |
| 1634 |
%\pgfmathsubtract@{\pgfplots@tick@origin}{\pgfplots@tick@offset}% |
| 1635 |
\else |
| 1636 |
\if0\pgfplots@ticklabelside |
| 1637 |
\expandafter\let\expandafter\pgfplots@tick@origin\csname pgfplots@\pgfplotspointonorientedsurfaceB min\endcsname% |
| 1638 |
\pgfplots@tickposchoiceb%<-- backw. compat, is usually empty. |
| 1639 |
%\pgfmathsubtract@{\pgfplots@tick@origin}{\pgfplots@tick@offset}% |
| 1640 |
\edef\pgfplots@tick@offset{-\pgfplots@tick@offset}% |
| 1641 |
\else |
| 1642 |
\if1\pgfplots@ticklabelside |
| 1643 |
\expandafter\let\expandafter\pgfplots@tick@origin\csname pgfplots@\pgfplotspointonorientedsurfaceB max\endcsname% |
| 1644 |
\pgfplots@tickposchoicea%<-- backw. compat, is usually empty. |
| 1645 |
%\pgfmathadd@{\pgfplots@tick@origin}{\pgfplots@tick@offset}% |
| 1646 |
\else |
| 1647 |
% FIXME : ticklabelside == 2 is, in principle, |
| 1648 |
% a valid choice. It is the case handled with |
| 1649 |
% "if 2 == pgfplots@#1axislinesnum" above, |
| 1650 |
% isn't it!? |
| 1651 |
\expandafter\let\expandafter\pgfplots@tick@origin\csname pgfplots@logical@ZERO@\pgfplotspointonorientedsurfaceB\endcsname% |
| 1652 |
% FIXME : is that correct!? |
| 1653 |
\pgfplots@tickposchoiceb%<-- backw. compat, is usually empty. |
| 1654 |
%\pgfmathsubtract@{\pgfplots@tick@origin}{\pgfplots@tick@offset}% |
| 1655 |
%\edef\pgfplots@tick@offset{-\pgfplots@tick@offset}% |
| 1656 |
% |
| 1657 |
\if2\pgfplots@ticklabelside |
| 1658 |
\else |
| 1659 |
% Should never happen. |
| 1660 |
\pgfplots@error{Internal logic error during tick label placement (got placement character '\pgfplots@ticklabelside'). |
| 1661 |
Please report this as a bug or verify your input arguments to #1ticklabel pos.}% |
| 1662 |
\fi |
| 1663 |
\fi |
| 1664 |
\fi |
| 1665 |
\fi |
| 1666 |
%\let\pgfplots@tick@origin=\pgfmathresult% |
| 1667 |
\edef\pgfplots@tick@offset{\pgfplots@tick@offset pt}% |
| 1668 |
% |
| 1669 |
% make sure the \pgfmathlogtologten method works even for |
| 1670 |
% non-standard 'log basis #1': |
| 1671 |
\def\pgfmathlogtologten@{\pgfplotscoordmath{#1}{log to log 10}}% |
| 1672 |
% |
| 1673 |
\xdef\pgfplots@show@ticklabel@LASTTICK{}% |
| 1674 |
\pgfplots@transformshift@along@outer@normal@on@line@of@oriented@surf{v}{\pgfplots@ticklabelside}% |
| 1675 |
\pgfplotslistforeachungrouped\pgfplots@prepared@tick@positions@major@\as\pgfplots@curtickpos{% |
| 1676 |
\expandafter\pgfplots@prepared@tick@pos@unpack\pgfplots@curtickpos |
| 1677 |
\let\pgfplots@curtickpos=\pgfplots@tick |
| 1678 |
%\expandafter\pgfplotslistpopfront\csname pgfplots@prepared@tick@positions@major@tickindices@#1\endcsname\to\pgfplots@ticknum |
| 1679 |
\pgfplotspointouternormalvectorofaxissetv{}{\pgfplots@curtickpos}% |
| 1680 |
\pgfplots@show@ticklabel |
| 1681 |
{#1}{\pgfplots@curtickpos}(\pgfplots@curtickpos,\pgfplots@tick@origin+\pgfplots@tick@offset)% |
| 1682 |
{\pgfplots@ticknum}% |
| 1683 |
}% |
| 1684 |
\pgfplots@ticklabel@maxtickdimen@finish{#1}% |
| 1685 |
\endpgfplotsonlayer |
| 1686 |
\endgroup |
| 1687 |
\pgfplots@draw@tick@scale@label@for #1% |
| 1688 |
}% |
| 1689 |
{\relax}% if...@major==false |
| 1690 |
\fi |
| 1691 |
\endgroup |
| 1692 |
} |
| 1693 |
|
| 1694 |
% This here does the main work for any tick label ANCHORING. |
| 1695 |
% |
| 1696 |
% FIXME : the new 'near ticklabel' anchors are now the default method |
| 1697 |
% to place tick labels. |
| 1698 |
% |
| 1699 |
% This feature here can be used to disable this anchoring, i.e. set |
| 1700 |
% 'ticklabel anchor=tikz' to use a stupid heuristics. |
| 1701 |
% |
| 1702 |
% There are actually two choices: |
| 1703 |
% Choice 1: near ticklabel |
| 1704 |
% This choice places tick labels fully automatic outside of the |
| 1705 |
% figure, all on a line which is parallel to the axis which |
| 1706 |
% contains the corresponding tick labels. |
| 1707 |
% |
| 1708 |
% Since we are currently working on a restricted surface, we have |
| 1709 |
% three direction related to that surface: |
| 1710 |
% 'a': this is the direction in which tick positions are known. |
| 1711 |
% 'b': the 'orthogonal' axis to 'a' which is also in the surface. |
| 1712 |
% 'n': the surface normal. |
| 1713 |
% Now, the idea for tick labels is to place them at |
| 1714 |
% SCALE_b * b + SCALE_n * n, |
| 1715 |
% where the SCALE_[bn] numbers are chosen such that the label is |
| 1716 |
% outside of the axis. |
| 1717 |
% |
| 1718 |
% The offset is simply added to the transformation matrix (as a |
| 1719 |
% shift). |
| 1720 |
% |
| 1721 |
% Choice 2: tikz. |
| 1722 |
% This is more or less a backwards compatibility feature. It does |
| 1723 |
% not change the transformation matrix. It simply sets the 'at' key |
| 1724 |
% of each node to the tick position and prepares the correct anchors |
| 1725 |
% for the TikZ '\node' commands. |
| 1726 |
% That's all here. |
| 1727 |
% |
| 1728 |
% PRECONDITION: |
| 1729 |
% - called inside of \pgfplots@drawticklabels@onorientedsurf@ |
| 1730 |
% POSTCONDITION: |
| 1731 |
% - defines |
| 1732 |
% - \pgfplots@tickposchoicea |
| 1733 |
% if called, sets keys such that tick labels are RIGHT (TOP) of |
| 1734 |
% the axis, |
| 1735 |
% |
| 1736 |
% - \pgfplots@tickposchoiceb |
| 1737 |
% if called, sets keys such that tick labels are LEFT |
| 1738 |
% (BOTTOM) of the axis, |
| 1739 |
\def\pgfplots@drawticklabels@onorientedsurf@prepareanchor#1{% |
| 1740 |
\if\csname pgfplots@ticklabel@anchor@#1\endcsname0% |
| 1741 |
% auto is the same as 'near ticklabel': |
| 1742 |
\expandafter\def\csname pgfplots@ticklabel@anchor@#1\endcsname{1}% |
| 1743 |
\fi |
| 1744 |
\ifcase\csname pgfplots@ticklabel@anchor@#1\endcsname% |
| 1745 |
% 0: doesn't happen, see above. |
| 1746 |
\or |
| 1747 |
% 1: near ticklabel. |
| 1748 |
% The following code contains automatically |
| 1749 |
% aligned tick labels (especially for 3D axes). |
| 1750 |
% see the manual for the |near ticklabel| anchors. |
| 1751 |
\pgfkeys{/tikz/anchor=near #1ticklabel}% |
| 1752 |
% |
| 1753 |
% process the (optional) ticklabel distance: |
| 1754 |
\begingroup |
| 1755 |
\pgfkeysgetvalue{/pgfplots/#1ticklabel shift}\pgfmathresult |
| 1756 |
\ifx\pgfmathresult\pgfutil@empty |
| 1757 |
\else |
| 1758 |
\afterassignment\pgfplots@gobble@until@relax |
| 1759 |
\pgf@xa=\pgfkeysvalueof{/pgfplots/#1ticklabel shift}pt\relax |
| 1760 |
\multiply\pgf@xa by-1 % the direction vector points to the INSIDE. the shift should have opposite sign. |
| 1761 |
\edef\pgfmathresult{\pgf@sys@tonumber\pgf@xa}% |
| 1762 |
\fi |
| 1763 |
\pgfmath@smuggleone\pgfmathresult |
| 1764 |
\endgroup |
| 1765 |
\let\pgfplots@loc@TMPc=\pgfmathresult |
| 1766 |
\ifx\pgfplots@loc@TMPc\pgfutil@empty |
| 1767 |
\else |
| 1768 |
\pgfplotspointouternormalvectorofaxis@ifdependson@v{\pgfplotsticklabelaxisspec{#1}}{% |
| 1769 |
\tikzset{every node/.append code={% |
| 1770 |
\tikz@addtransform{% |
| 1771 |
\pgftransformshift{% |
| 1772 |
\pgfplotspointouternormalvectorofticklabelaxis{#1}% |
| 1773 |
\pgfqpointscale{-\pgfplots@loc@TMPc}{}% |
| 1774 |
}% |
| 1775 |
}% |
| 1776 |
}% |
| 1777 |
}% |
| 1778 |
}{% |
| 1779 |
\pgftransformshift{% |
| 1780 |
\pgfplotspointouternormalvectorofticklabelaxis{#1}% |
| 1781 |
\pgfqpointscale{-\pgfplots@loc@TMPc}{}% |
| 1782 |
}% |
| 1783 |
}% |
| 1784 |
\fi |
| 1785 |
% |
| 1786 |
% these things are irrelevant here: |
| 1787 |
\let\pgfplots@tickposchoicea=\pgfutil@empty |
| 1788 |
\let\pgfplots@tickposchoiceb=\pgfutil@empty |
| 1789 |
\or |
| 1790 |
% 2: tikz. |
| 1791 |
% We simply prepare the default anchor. |
| 1792 |
% Actually, this code is just for backwards compatibility - |
| 1793 |
% there may be people who prefer to set anchors. The |
| 1794 |
% 'near ticklabel' implementation is much more general, however. |
| 1795 |
\if\pgfplotspointonorientedsurfaceB x |
| 1796 |
\def\pgfplots@tickposchoicea{\tikzset{right}}% |
| 1797 |
\def\pgfplots@tickposchoiceb{\tikzset{left}}% |
| 1798 |
\else |
| 1799 |
\if\pgfplotspointonorientedsurfaceB y |
| 1800 |
\def\pgfplots@tickposchoicea{\tikzset{above}}% |
| 1801 |
\def\pgfplots@tickposchoiceb{\tikzset{below}}% |
| 1802 |
\else |
| 1803 |
\def\pgfplots@tickposchoicea{\tikzset{anchor=north east}}% |
| 1804 |
\def\pgfplots@tickposchoiceb{\tikzset{anchor=south east}}% |
| 1805 |
\fi |
| 1806 |
\fi |
| 1807 |
\fi |
| 1808 |
% |
| 1809 |
% |
| 1810 |
% |
| 1811 |
% suppress this warning. We cannot avoid it currently. |
| 1812 |
\pgfkeysgetvalue{/pgfplots/warning/missing near ticklabel at/.@cmd}\pgfplots@loc@neartickllabel@at |
| 1813 |
\pgfkeysdef{/pgfplots/warning/missing near ticklabel at}{}% |
| 1814 |
% |
| 1815 |
\pgfplots@ticklabel@maxtickdimen@prepare@for@normalvec |
| 1816 |
{#1}% |
| 1817 |
{\pgfplotspointouternormalvectorofticklabelaxis{#1}}% |
| 1818 |
% |
| 1819 |
\pgfkeyslet{/pgfplots/warning/missing near ticklabel at/.@cmd}\pgfplots@loc@neartickllabel@at% |
| 1820 |
}% |
| 1821 |
|
| 1822 |
\newif\ifpgfplots@checkuniform@isfirst |
| 1823 |
% Checks whether the argument to xtick or ytick is a UNIFORM tick |
| 1824 |
% sequence. |
| 1825 |
% |
| 1826 |
% A uniform tick sequence is 0,...,10 and 3,4,5 and -5,-4,-2 but |
| 1827 |
% NOT 0,2,4 or 4,10. |
| 1828 |
% |
| 1829 |
% Furthermore, any NON-integer tick arguments are also assumed to be |
| 1830 |
% NOT uniform. |
| 1831 |
% |
| 1832 |
% INPUT: |
| 1833 |
% #1: a tick argument (i.e. something which can be put to |
| 1834 |
% \foreach \x in {#1}) |
| 1835 |
% |
| 1836 |
% OUTPUT: |
| 1837 |
% \pgfplots@isuniformticktrue |
| 1838 |
% or |
| 1839 |
% \pgfplots@isuniformtickfalse |
| 1840 |
% depending on the check. |
| 1841 |
% This variable will be set globally. |
| 1842 |
\def\pgfplots@checkisuniformLOGtick#1{% |
| 1843 |
\begingroup |
| 1844 |
\global\pgfplots@isuniformticktrue |
| 1845 |
\pgfplots@checkuniform@isfirsttrue |
| 1846 |
\foreach \x in {#1}{% |
| 1847 |
\pgfmathmultiply@\x\reciproclogten |
| 1848 |
\let\cur=\pgfmathresult |
| 1849 |
% check whether |
| 1850 |
% \cur - last == 1 (last = \pgfplots@glob@TMPb) |
| 1851 |
\ifpgfplots@checkuniform@isfirst |
| 1852 |
\global\pgfplots@checkuniform@isfirstfalse |
| 1853 |
\else |
| 1854 |
\pgfmathsubtract@\cur\pgfplots@glob@TMPb% |
| 1855 |
\pgfmathapproxequalto@\pgfmathresult{1.0}% |
| 1856 |
\ifpgfmathcomparison |
| 1857 |
\else |
| 1858 |
\global\pgfplots@isuniformtickfalse |
| 1859 |
\breakforeach |
| 1860 |
\fi |
| 1861 |
\fi |
| 1862 |
\global\let\pgfplots@glob@TMPb=\cur |
| 1863 |
}% |
| 1864 |
\endgroup |
| 1865 |
} |
| 1866 |
|
| 1867 |
% Checks whether the linear tick sequence #1 is a uniform tick. |
| 1868 |
% |
| 1869 |
% It also assigns pgfplots@tick@distance@#1 as the distance. |
| 1870 |
% |
| 1871 |
% see \pgfplots@checkisuniformLOGtick for details. |
| 1872 |
% |
| 1873 |
% #1: a tick sequence (expanded) |
| 1874 |
% #2: a macro which will be filled with the tick distance. This is |
| 1875 |
% only valid if \pgfplots@isuniformticktrue. |
| 1876 |
\def\pgfplots@checkisuniformLINEARtick#1#2{% |
| 1877 |
\begingroup |
| 1878 |
\global\pgfplots@isuniformticktrue |
| 1879 |
\pgfplots@checkuniform@isfirsttrue |
| 1880 |
\global\let\pgfplots@glob@TMPb=\pgfutil@empty |
| 1881 |
\global\def\pgfplots@glob@TMPa{1}% |
| 1882 |
\foreach \x in {#1}{% |
| 1883 |
\ifx\pgfplots@glob@TMPb\pgfutil@empty |
| 1884 |
\else |
| 1885 |
\pgfmathsubtract@\x\pgfplots@glob@TMPb |
| 1886 |
\ifpgfplots@checkuniform@isfirst |
| 1887 |
% remember first distance h = x_1 - x_0 |
| 1888 |
\global\let\pgfplots@glob@TMPa=\pgfmathresult |
| 1889 |
\global\pgfplots@checkuniform@isfirstfalse |
| 1890 |
\else |
| 1891 |
% check whether x_i - x_{i-1} = h |
| 1892 |
\pgfmathapproxequalto@\pgfmathresult\pgfplots@glob@TMPa% |
| 1893 |
\ifpgfmathcomparison |
| 1894 |
\else |
| 1895 |
\global\pgfplots@isuniformtickfalse |
| 1896 |
\breakforeach |
| 1897 |
\fi |
| 1898 |
\fi |
| 1899 |
\fi |
| 1900 |
\global\let\pgfplots@glob@TMPb=\x% |
| 1901 |
}% |
| 1902 |
\endgroup |
| 1903 |
\let#2=\pgfplots@glob@TMPa |
| 1904 |
} |
| 1905 |
|
| 1906 |
% helper method which computes log10*\x foreach \x in {#1}. |
| 1907 |
% The result will be \xdef'ed into #2. |
| 1908 |
% |
| 1909 |
% #1: the ticks |
| 1910 |
% #2: the output macro |
| 1911 |
% #3: the axis |
| 1912 |
\def\pgfplots@compute@tick@times@logten#1\to#2#3{% |
| 1913 |
\global\let#2=\pgfutil@empty |
| 1914 |
\foreach \pgfplots@loc@TMPb in {#1} {% |
| 1915 |
\pgfplotscoordmath{#3}{log to display log}{\pgfplots@loc@TMPb}% |
| 1916 |
\pgfplotscoordmath{#3}{tofixed}{\pgfmathresult}% |
| 1917 |
\ifx#2\pgfutil@empty |
| 1918 |
\xdef#2{\pgfmathresult}% |
| 1919 |
\else |
| 1920 |
\xdef#2{#2,\pgfmathresult}% |
| 1921 |
\fi |
| 1922 |
}% |
| 1923 |
} |
| 1924 |
|
| 1925 |
% This is part of \pgfplots@assign@default@tick@foraxis and relies on |
| 1926 |
% its temporary variables. |
| 1927 |
% |
| 1928 |
% INPUT: |
| 1929 |
% \MIN : the lower axis limit of #1 (a TeX register, in transformed range) |
| 1930 |
% \MAX : same with upper axis limit of #1 |
| 1931 |
% \desirednumticks: the number of ticks to use |
| 1932 |
% OUTPUT: |
| 1933 |
% \H : will contain the (transformed) distance between adjacent ticks |
| 1934 |
% \aftergroup\pgfplots@isuniformticktrue set if it applies |
| 1935 |
% |
| 1936 |
% |
| 1937 |
\def\pgfplots@ticks@compute@tick@distance#1{% |
| 1938 |
% compute step size 'H': |
| 1939 |
\H=\MAX |
| 1940 |
\advance\H by-\MIN |
| 1941 |
\ifdim\H<0pt \H=-1\H \fi |
| 1942 |
%\message{Axis limit #1: [\the\MIN:\the\MAX], diff = \the\H.^^J}% |
| 1943 |
\c@pgf@counta=\desirednumticks |
| 1944 |
\advance\c@pgf@counta by-1 % |
| 1945 |
\divide\H by\c@pgf@counta |
| 1946 |
%\message{determining ticks for #1-axis: Wr := (width/max space between ticks) = \the\Wr, desirednumticks=max(\axisdefaulttryminticks, trunc(Wr)) = \the\desirednumticks, H#1=(axis range/(desirednumticks-1)) = \the\H^^J}% |
| 1947 |
% |
| 1948 |
% SEARCH for the NEXT FEASIBLE H. |
| 1949 |
\edef\Hmacro{\pgf@sys@tonumber\H}% |
| 1950 |
\ifpgfplots@cur@is@linear |
| 1951 |
% CASE LINEAR AXIS |
| 1952 |
\ifpgfplots@is@datascaled |
| 1953 |
% This here works if the scaling trafo is linear. |
| 1954 |
\pgfplotscoordmath{#1}{datascaletrafo noshift inverse}{\Hmacro}% |
| 1955 |
\let\Hmacro=\pgfmathresult |
| 1956 |
\else |
| 1957 |
\pgfmathfloatparsenumber{\Hmacro}% |
| 1958 |
\let\Hmacro=\pgfmathresult |
| 1959 |
\fi |
| 1960 |
%\message{Got T^{-1}(H#1) = \Hmacro^^J}% |
| 1961 |
% |
| 1962 |
\pgfplots@assign@default@tick@foraxis@normalizetickdist#1\Hmacro |
| 1963 |
\let\Hmacro=\pgfmathresult |
| 1964 |
% |
| 1965 |
% Ok, we are ready. |
| 1966 |
% Now, convert everything into the fixed point data |
| 1967 |
% range: |
| 1968 |
\ifpgfplots@is@datascaled |
| 1969 |
\pgfplotscoordmath{#1}{datascaletrafo noshift}{\Hmacro}% |
| 1970 |
\H=\pgfmathresult pt |
| 1971 |
\else |
| 1972 |
\pgfmathfloattofixed\Hmacro |
| 1973 |
\H=\pgfmathresult pt |
| 1974 |
\fi |
| 1975 |
% |
| 1976 |
%\message{snapped-to-nicest = \Hmacro^^J}% |
| 1977 |
\aftergroup\pgfplots@isuniformticktrue |
| 1978 |
\else |
| 1979 |
% CASE LOG AXIS |
| 1980 |
% |
| 1981 |
% search for the "best" H= j* log(10), j an integer. |
| 1982 |
% |
| 1983 |
% And prefer j=1 if that is possible (otherwise minor |
| 1984 |
% ticks are not useful). |
| 1985 |
\pgfmath@basic@multiply@{\Hmacro}{\pgfplots@loc@log@from@display@log@scale}% |
| 1986 |
\let\Hmacrobaseten=\pgfmathresult |
| 1987 |
\expandafter\H\pgfmathresult pt |
| 1988 |
%\message{ [ H / log(10) = \pgfmathresult ]}% |
| 1989 |
\ifdim\H<2pt |
| 1990 |
\H=1pt |
| 1991 |
\else |
| 1992 |
\ifnum\H<1pt |
| 1993 |
\H=1pt |
| 1994 |
\else |
| 1995 |
\expandafter\pgfmathfloor\expandafter{\pgfmathresult}% |
| 1996 |
\expandafter\H\pgfmathresult pt |
| 1997 |
\fi |
| 1998 |
\fi |
| 1999 |
\ifdim\H=1pt |
| 2000 |
\aftergroup\pgfplots@isuniformticktrue |
| 2001 |
\pgfplots@isuniformticktrue |
| 2002 |
\else |
| 2003 |
\aftergroup\pgfplots@isuniformtickfalse |
| 2004 |
\pgfplots@isuniformtickfalse |
| 2005 |
\fi |
| 2006 |
%\message{final H=\pgf@sys@tonumber{\H} * log(10)}% |
| 2007 |
\H=\pgfplots@loc@log@to@display@log@scale\H |
| 2008 |
\fi |
| 2009 |
% |
| 2010 |
} |
| 2011 |
|
| 2012 |
% This is part of \pgfplots@assign@default@tick@foraxis |
| 2013 |
% |
| 2014 |
% It overwrites the internal macros of |
| 2015 |
% \pgfplots@assign@default@tick@foraxis |
| 2016 |
\def\pgfplots@assign@default@tick@foraxis@autoadjust@result#1{% |
| 2017 |
\pgfplots@if{pgfplots@#1islinear}{% |
| 2018 |
\begingroup |
| 2019 |
\def\pgfplots@tick@returnval@ready{1}% |
| 2020 |
\pgfutil@ifundefined{pgfplots@assign@default@tick@foraxis@recurselevel}{% |
| 2021 |
\def\pgfplots@assign@default@tick@foraxis@recurselevel{1}% |
| 2022 |
}{% |
| 2023 |
\pgfplotsutil@advancestringcounter\pgfplots@assign@default@tick@foraxis@recurselevel |
| 2024 |
}% |
| 2025 |
\ifnum\pgfplots@assign@default@tick@foraxis@recurselevel<15 |
| 2026 |
\c@pgf@counta=\axisdefaulttryminticks\relax |
| 2027 |
\advance\c@pgf@counta by1 |
| 2028 |
\edef\axisdefaulttryminticks{\the\c@pgf@counta}% |
| 2029 |
%\message{**TOO FEW TICK LABELS FOR #1. RECURSION with try min ticks=\axisdefaulttryminticks.**^^J}% |
| 2030 |
% recurse. |
| 2031 |
\pgfplots@assign@default@tick@foraxis{#1}% |
| 2032 |
\expandafter\global\expandafter\let\expandafter\pgfplots@glob@TMPa\csname pgfplots@#1tick\endcsname |
| 2033 |
\expandafter\global\expandafter\let\expandafter\pgfplots@glob@TMPb\csname pgfplots@tick@distance@#1\endcsname |
| 2034 |
\else |
| 2035 |
\pgfplotswarning{tick computation failed}{#1}{\axisdefaulttryminticks}\pgfeov% |
| 2036 |
\def\pgfplots@tick@returnval@ready{0}% |
| 2037 |
\fi |
| 2038 |
\pgfmath@smuggleone\pgfplots@tick@returnval@ready |
| 2039 |
\endgroup |
| 2040 |
}{% |
| 2041 |
% Case logarithmic axes and too few ticks. |
| 2042 |
\aftergroup\pgfplots@isuniformtickfalse |
| 2043 |
% ok, do something special. |
| 2044 |
% |
| 2045 |
% The idea is now to place ticks at |
| 2046 |
% 10^{i*h} with properly chosen 'h'. |
| 2047 |
% |
| 2048 |
% So: apply basically the SAME code as above for linear |
| 2049 |
% axis, just everything log 10! And keep in mind that all |
| 2050 |
% coordinates are actually given as natural logarithms. |
| 2051 |
\MIN\csname pgfplots@#1min\endcsname pt |
| 2052 |
\H=\MAX |
| 2053 |
\advance\H by-\MIN |
| 2054 |
\ifdim\H<0pt \H=-1\H \fi |
| 2055 |
\H=\pgfplots@loc@log@from@display@log@scale \H |
| 2056 |
%\message{Axis limit #1: [\the\MIN:\the\MAX], diff/log(10) = \the\H.}% |
| 2057 |
\c@pgf@counta=\desirednumticks\relax |
| 2058 |
\advance\c@pgf@counta by-1 |
| 2059 |
\ifnum\c@pgf@counta>2 |
| 2060 |
% subtract one more. This algorithm here produces more |
| 2061 |
% ticks than the normal one which is designed for 10^i |
| 2062 |
\advance\c@pgf@counta by-1 |
| 2063 |
\fi |
| 2064 |
\divide\H by\c@pgf@counta\relax |
| 2065 |
%\message{determining ticks for #1-axis: Wr := (width/max space between ticks) = \the\Wr, desirednumticks=max(\axisdefaulttryminticks, trunc(Wr)) = \the\desirednumticks, H#1=(axis range/(desirednumticks-1)) = \the\H}% |
| 2066 |
% |
| 2067 |
% SEARCH for the NEXT FEASIBLE H. |
| 2068 |
\edef\Hmacro{\pgf@sys@tonumber\H}% |
| 2069 |
\pgfmathfloatparsenumber{\Hmacro}% |
| 2070 |
\pgfplots@assign@default@tick@foraxis@normalizetickdist#1\pgfmathresult |
| 2071 |
% |
| 2072 |
\expandafter\pgfmathfloattofixed\expandafter{\pgfmathresult}% |
| 2073 |
\let\Hmacro=\pgfmathresult |
| 2074 |
\H=\Hmacro pt % |
| 2075 |
% Ok, our step size h for 10^{i*h} is ready! |
| 2076 |
%\message{determined step size 10^{\Hmacro}}% |
| 2077 |
% Now, we want to activate the Tick set {10^{i*H}, i in \Z} |
| 2078 |
% compute I such that |
| 2079 |
% 10^{min} = 10^{I * H + rest}; |rest| < H |
| 2080 |
% -> I = round(xmin/H) |
| 2081 |
% -> MIN = I * H |
| 2082 |
% BUT EVERYTHING to log(10) basis! |
| 2083 |
\MIN=\pgfplots@loc@log@from@display@log@scale \MIN |
| 2084 |
\pgfmathlog@invoke@expanded\pgfmathdivide@{% |
| 2085 |
{\pgf@sys@tonumber\MIN}% |
| 2086 |
{\Hmacro}% |
| 2087 |
}% |
| 2088 |
\pgfmathsetcount{\c@pgf@counta}{\pgfmathresult}% |
| 2089 |
\ifdim\MIN<0pt |
| 2090 |
% the truncation rounds TOWARDS 0 which is not what I want. |
| 2091 |
\advance\c@pgf@counta by-1 |
| 2092 |
\fi |
| 2093 |
\MIN=\H\relax |
| 2094 |
\multiply\MIN by\c@pgf@counta\relax |
| 2095 |
% |
| 2096 |
% convert back to basis 'e': |
| 2097 |
\MIN=\pgfplots@loc@log@to@display@log@scale\MIN\relax |
| 2098 |
\H=\pgfplots@loc@log@to@display@log@scale\H\relax |
| 2099 |
\MINH=\MIN\relax |
| 2100 |
\advance\MINH by\H\relax |
| 2101 |
}% |
| 2102 |
}% |
| 2103 |
|
| 2104 |
% The key 'xtick distance' can have any value. This routine avoids |
| 2105 |
% 'dimension too large' programmatically |
| 2106 |
\def\pgfplots@assign@default@tick@foraxis@cap#1#2{% |
| 2107 |
\ifpgfplots@is@datascaled |
| 2108 |
\pgfplotscoordmath{#1}{datascaletrafo noshift inverse}{16000}% |
| 2109 |
\let\pgfplots@loc@TMPb=\pgfmathresult |
| 2110 |
\pgfplotscoordmath{#1}{min}{\pgfplots@loc@TMPb}{#2}% |
| 2111 |
\edef\pgfplots@loc@TMPc{#2}% |
| 2112 |
\ifx\pgfplots@loc@TMPc\pgfmathresult |
| 2113 |
\def\pgfplotsretval{0}% |
| 2114 |
\else |
| 2115 |
\def\pgfplotsretval{1}% |
| 2116 |
\fi |
| 2117 |
\else |
| 2118 |
\pgfplotscoordmath{#1}{parsenumber}{16000}% |
| 2119 |
\let\pgfplots@loc@TMPb=\pgfmathresult |
| 2120 |
\pgfplotscoordmath{#1}{parsenumber}{#2}% |
| 2121 |
\let\pgfplots@loc@TMPc=\pgfmathresult |
| 2122 |
\pgfplotscoordmath{#1}{min}{\pgfplots@loc@TMPb}{\pgfplots@loc@TMPc}% |
| 2123 |
% |
| 2124 |
\ifx\pgfplots@loc@TMPc\pgfmathresult |
| 2125 |
\def\pgfplotsretval{0}% |
| 2126 |
\else |
| 2127 |
\def\pgfplotsretval{1}% |
| 2128 |
\fi |
| 2129 |
\fi |
| 2130 |
% |
| 2131 |
\ifx1\pgfplotsretval |
| 2132 |
\pgfplotswarning{dimension too large in ticks}{#1}{#2}{\pgfmathresult}\pgfeov% |
| 2133 |
\fi |
| 2134 |
} |
| 2135 |
|
| 2136 |
% This macro is NECESSARILY part of |
| 2137 |
% \pgfplots@assign@default@tick@foraxis: |
| 2138 |
% |
| 2139 |
% OUTPUT: |
| 2140 |
% \csname pgfplots@#1tick\endcsname |
| 2141 |
% \csname pgfplots@tick@distance@#1\endcsname |
| 2142 |
% FIXME : some \aftergroup trickery... |
| 2143 |
\def\pgfplots@assign@default@tick@foraxis@compute#1{% |
| 2144 |
% Ok, we have either log or linear axis and need default |
| 2145 |
% ticks MIN,MIN+H,...,MAX. |
| 2146 |
\let\MINH=\pgf@xa |
| 2147 |
\let\H=\pgf@xb |
| 2148 |
\let\MAX=\pgf@ya |
| 2149 |
\let\MIN=\pgf@yb |
| 2150 |
% |
| 2151 |
\MAX=\csname pgfplots@#1max\endcsname pt % |
| 2152 |
\advance\MAX by0.001pt % avoid round errors |
| 2153 |
%\expandafter\MIN\the\c@pgf@counta pt |
| 2154 |
\MIN=\csname pgfplots@#1min\endcsname pt % |
| 2155 |
% |
| 2156 |
\pgfkeysgetvalue{/pgfplots/#1tick distance}\Hmacro |
| 2157 |
\ifx\Hmacro\pgfutil@empty |
| 2158 |
\pgfplots@ticks@compute@tick@distance#1% |
| 2159 |
\def\b@pgfplots@ticks@computed@tick@distance@is@final{0}% |
| 2160 |
\else |
| 2161 |
% ah - a user argument. OK, prefer that one over the default: |
| 2162 |
\pgfplotscoordmath{default}{parse}{abs(\Hmacro)}% |
| 2163 |
\let\Hmacro=\pgfmathresult |
| 2164 |
\pgfplots@assign@default@tick@foraxis@cap{#1}{\Hmacro}% |
| 2165 |
\let\Hmacro=\pgfmathresult |
| 2166 |
\ifpgfplots@cur@is@linear |
| 2167 |
\ifpgfplots@is@datascaled |
| 2168 |
\pgfplotscoordmath{#1}{datascaletrafo noshift}{\pgfmathresult}% |
| 2169 |
\else |
| 2170 |
\pgfplotscoordmath{#1}{tofixed}{\pgfmathresult}% |
| 2171 |
\fi |
| 2172 |
\H=\pgfmathresult pt |
| 2173 |
\pgfplots@isuniformticktrue |
| 2174 |
\aftergroup\pgfplots@isuniformticktrue |
| 2175 |
\else |
| 2176 |
\pgfplotscoordmath{#1}{log}{\pgfmathresult}% |
| 2177 |
\let\Hmacro=\pgfmathresult |
| 2178 |
\H=\pgfmathresult pt |
| 2179 |
% |
| 2180 |
% we don't know it. check it. |
| 2181 |
\pgfplots@isuniformtickfalse |
| 2182 |
\aftergroup\pgfplots@isuniformtickfalse |
| 2183 |
\fi |
| 2184 |
\def\b@pgfplots@ticks@computed@tick@distance@is@final{1}% |
| 2185 |
\fi |
| 2186 |
%\message{Got H=\the\H\space(\Hmacro)^^J}% |
| 2187 |
% |
| 2188 |
% OK, now compute MIN/MAX : |
| 2189 |
\ifpgfplots@cur@is@linear |
| 2190 |
% The following code is carried out in floating point |
| 2191 |
% arithmetics because it requires large data ranges. |
| 2192 |
% |
| 2193 |
% I want to compute MIN@new := I*H where I is chosen |
| 2194 |
% such that MIN = I*H + rest with rest < H. |
| 2195 |
% The problem is the possibly large range of MIN. I |
| 2196 |
% can't work completely in the transformed datarange, |
| 2197 |
% so numbers get too large. |
| 2198 |
% |
| 2199 |
% So, compute I := int( MIN / H ) (integer truncation) |
| 2200 |
% in float arithmetics and then MIN@new := I*H |
| 2201 |
\pgfmathfloatdivide@{\csname pgfplots@#1min@unscaled@as@float\endcsname}{\Hmacro}% |
| 2202 |
\pgfmathfloatint@{\pgfmathresult}% |
| 2203 |
\pgfmathfloatmultiply@{\pgfmathresult}{\Hmacro}% |
| 2204 |
\let\MIN@new=\pgfmathresult |
| 2205 |
% |
| 2206 |
% Now, convert everything into the fixed point data |
| 2207 |
% range: |
| 2208 |
\ifpgfplots@is@datascaled |
| 2209 |
\pgfplotscoordmath{#1}{datascaletrafo}{\MIN@new}% |
| 2210 |
\MIN=\pgfmathresult pt |
| 2211 |
\else |
| 2212 |
\pgfmathfloattofixed\MIN@new |
| 2213 |
\MIN=\pgfmathresult pt |
| 2214 |
\fi |
| 2215 |
% |
| 2216 |
% And, since we have used finite precision, I is most |
| 2217 |
% likely to be large. So: subtract one H. In the worst |
| 2218 |
% case, this produces one tick position too much (but |
| 2219 |
% it won't be printed). |
| 2220 |
\advance\MIN by-\H\relax |
| 2221 |
\else |
| 2222 |
% Now, we want to activate the Tick set |
| 2223 |
% {lowest, lowest+H, ..., highest} |
| 2224 |
% |
| 2225 |
% Where |
| 2226 |
% lowest = I * log(10) + rest, |rest| < log(10). |
| 2227 |
% this is conceptionally different from the approach for |
| 2228 |
% linear axes, because H = j*log(10). |
| 2229 |
% |
| 2230 |
% remember the original xmin in MINH: |
| 2231 |
\MINH=\MIN |
| 2232 |
% |
| 2233 |
% and compute I and I*log(10) here: |
| 2234 |
\MIN=\pgfplots@loc@log@from@display@log@scale \MIN |
| 2235 |
\edef\pgfmathresult{\pgf@sys@tonumber{\MIN}}% |
| 2236 |
\pgfmathsetcount{\c@pgf@counta}{\pgfmathresult}% |
| 2237 |
\ifdim\MIN<0pt |
| 2238 |
% the truncation rounds TOWARDS 0 which is not what I want. |
| 2239 |
\advance\c@pgf@counta by-1 |
| 2240 |
\fi |
| 2241 |
\MIN=\pgfplots@loc@log@to@display@log@scale pt |
| 2242 |
\multiply\MIN by\c@pgf@counta |
| 2243 |
\ifpgfplots@isuniformtick |
| 2244 |
\else |
| 2245 |
% This here is a special case to move the first tick |
| 2246 |
% near the lower axis limit. |
| 2247 |
% |
| 2248 |
% "Near" means either directly above or directly below ymin. |
| 2249 |
% |
| 2250 |
% My application example is as follows: |
| 2251 |
% Let H = 2*log(10). |
| 2252 |
% Furthermore, ymin = 3e-6, ymax= 8e-2. That means we can choose either |
| 2253 |
% 10^{-5}, 10^{-3}, 10^{-1} |
| 2254 |
% or |
| 2255 |
% 10^{-4}, 10^{-2} |
| 2256 |
% as ticks. Well, I prefer the first one. |
| 2257 |
% |
| 2258 |
% HEURISTICS: start as near to ymin as possible! |
| 2259 |
% |
| 2260 |
% We check here if we can come nearer to ymin if we |
| 2261 |
% shift the current tick by log(10): |
| 2262 |
% if( ymin - I * log(10) < 0.5*H -> use I+1, that means add log(10). |
| 2263 |
% |
| 2264 |
% that's equivalent to |
| 2265 |
% 2*(ymin - I * log(10)) - H < 0. |
| 2266 |
\advance\MINH by-\MIN |
| 2267 |
\multiply\MINH by2 |
| 2268 |
\advance\MINH by-\H |
| 2269 |
% |
| 2270 |
\ifdim\MINH<0pt |
| 2271 |
\advance\MIN \pgfplots@loc@log@to@display@log@scale pt |
| 2272 |
\fi |
| 2273 |
\fi |
| 2274 |
\fi |
| 2275 |
\MINH=\MIN |
| 2276 |
\advance\MINH by\H |
| 2277 |
% Ok, now it can happen that only ONE tick label is placed in |
| 2278 |
% this range. |
| 2279 |
% That's useless, so check for it. |
| 2280 |
% |
| 2281 |
% That's the case if |
| 2282 |
% MIN < ORIGMIN && MAX < MIN+2 H |
| 2283 |
% MIN < ORIGMIN by construction (ok, MIN <= ORIGMIN by |
| 2284 |
% construction, but I don't care about this case). |
| 2285 |
% So: check only the second condition. |
| 2286 |
%\message{Got MIN=\pgf@sys@tonumber\MIN; H=\pgf@sys@tonumber\H; MAX=\pgf@sys@tonumber\MAX.^^J}% |
| 2287 |
\def\pgfplots@tick@returnval@ready{0}% |
| 2288 |
% |
| 2289 |
\pgfplots@tmpa=\MINH |
| 2290 |
\advance\pgfplots@tmpa by\H |
| 2291 |
\ifdim\MAX<\pgfplots@tmpa |
| 2292 |
\if1\b@pgfplots@ticks@computed@tick@distance@is@final |
| 2293 |
% OK, we cannot auto adjust tick labels -- if if there are |
| 2294 |
% too few of them. |
| 2295 |
\else |
| 2296 |
\pgfplots@assign@default@tick@foraxis@autoadjust@result#1% |
| 2297 |
\fi |
| 2298 |
\fi |
| 2299 |
% |
| 2300 |
% assert that we have at least a minimal tick distance. |
| 2301 |
% FIXME :this minimum might actually be too small... |
| 2302 |
\ifdim\MINH=\MIN |
| 2303 |
\pgfplotsthrow{dimension too small in ticks}{#1}\pgfeov% |
| 2304 |
% |
| 2305 |
% make sure that the compilation succeeds: |
| 2306 |
\H=1pt % |
| 2307 |
\advance\MINH by\H |
| 2308 |
\fi |
| 2309 |
% |
| 2310 |
\if0\pgfplots@tick@returnval@ready |
| 2311 |
\xdef\pgfplots@glob@TMPb{\pgf@sys@tonumber{\H}}% |
| 2312 |
\advance\MAX by0.5\H % avoid rounding inaccuracies: |
| 2313 |
\xdef\pgfplots@glob@TMPa{\pgf@sys@tonumber{\MIN},\pgf@sys@tonumber{\MINH},...,\pgf@sys@tonumber{\MAX}}% |
| 2314 |
\fi |
| 2315 |
%\message{final H=\the\H; returning \pgfplots@glob@TMPa.}% |
| 2316 |
\expandafter\let\csname pgfplots@#1tick\endcsname=\pgfplots@glob@TMPa |
| 2317 |
\expandafter\let\csname pgfplots@tick@distance@#1\endcsname=\pgfplots@glob@TMPb |
| 2318 |
}% |
| 2319 |
|
| 2320 |
% Computes tick positions using the current axis limits. |
| 2321 |
% |
| 2322 |
% Parameters: |
| 2323 |
% /pgfplots/max space between ticks |
| 2324 |
% Determines the maximum space which is not filled by at least one |
| 2325 |
% tick label (approximate, there is some rounding internally) |
| 2326 |
% /pgfplots/try min ticks |
| 2327 |
% see manual |
| 2328 |
% |
| 2329 |
% Idea: |
| 2330 |
% We want ticks at each |
| 2331 |
% { i*H, i in \Z }. |
| 2332 |
% Of course, there shouldn't be TOO MUCH ticks. |
| 2333 |
% |
| 2334 |
% Our heuristics is to set |
| 2335 |
% desirednumticks = round(ACTUAL WIDTH / (max space between ticks) ) |
| 2336 |
% and generate H = (axis range) / (desirednumticks). |
| 2337 |
% |
| 2338 |
% Since not all step sizes H look well, restrict H to a set of allowed |
| 2339 |
% step sizes such as |
| 2340 |
% { 1, 1/2, 1/5, 1/10 }, |
| 2341 |
% or, to be more precise: |
| 2342 |
% { 1*10^e, 2*10^e, 5*10^e } |
| 2343 |
% -> round to the nearest matching number! |
| 2344 |
% This yields H (for example as 2*10^e). Then, compute i*H, i \in \Z |
| 2345 |
% |
| 2346 |
% The data scaling transformation T(x) makes things more complicated. |
| 2347 |
% Now, T(x) = q * x - p and we need to check for problems with large |
| 2348 |
% numbers: |
| 2349 |
% - q* H = ( T(Max) - T(Min) ) / desirednumticks = q * (Max - Min) / desirednumticks. |
| 2350 |
% - Using floating point arithmetics, (Max-Min)/desirednumticks (unscaled!) |
| 2351 |
% is analysed to restrict H to {1*10^e, 2*10^e, 5*10^e}. |
| 2352 |
% - So, we get q * H (we can't use the 'p' shift of the affine trafo here). |
| 2353 |
% - The next problem is to compute { I*H, I in \Z } because |
| 2354 |
% I = trunc( Min / H ) = trunc( ( T(Min) + p ) / (q*H) ). |
| 2355 |
% This can be seen by Min = I*H + rest and thus T(Min) = I*q*H + q*rest -p. |
| 2356 |
% The Problem: (T(min)+p ) / (q*H) can be TOO BIG for pgfmath. |
| 2357 |
% -> for the data scaling case, I will use floating point |
| 2358 |
% arithmetics to compute that last step. |
| 2359 |
% I will acquire \pgfplots@[xy]min@unscaled@as@float here. |
| 2360 |
% |
| 2361 |
% |
| 2362 |
% |
| 2363 |
% |
| 2364 |
% |
| 2365 |
% For log-plots, |
| 2366 |
% H in { j*log(10), j=1,2,3,... } |
| 2367 |
% where the usual case should be j = 1. |
| 2368 |
% |
| 2369 |
% Then, the resulting tick is |
| 2370 |
% TICK={MIN,MIN+H,...,MAX} |
| 2371 |
% where |
| 2372 |
% MIN = I*H |
| 2373 |
% is chosen such that |
| 2374 |
% axis minimum limit = I*H + rest; |rest| < H. |
| 2375 |
% |
| 2376 |
% Again, log plots follow a slightly different approach: here, |
| 2377 |
% MIN = I * log(10) |
| 2378 |
% is chosen such that |
| 2379 |
% axis minimum limit = I*log(10) + rest; |rest| < log(10) |
| 2380 |
% while H = j*log(10), j>=1. |
| 2381 |
% |
| 2382 |
% |
| 2383 |
% PRECONDITION: |
| 2384 |
% - limits are correct |
| 2385 |
% - axis width/height is set correctly |
| 2386 |
% |
| 2387 |
% POSTCONDITION: |
| 2388 |
% - Tick for axis #1 is assigned |
| 2389 |
% - \ifpgfplots@determinedefaultvalues@needs@check@uniformtick is set |
| 2390 |
% |
| 2391 |
% REMARKS: |
| 2392 |
% - this algorithms works also if the data range has been transformed |
| 2393 |
% with a LINEAR transformation. |
| 2394 |
% ATTENTION: as of 2008-05-15, the scaling trafo is AFFINE LINEAR. |
| 2395 |
% That means we have to eliminate the 'affine' shifting before the |
| 2396 |
% algorithms works correctly. |
| 2397 |
\def\pgfplots@assign@default@tick@foraxis#1{% |
| 2398 |
\begingroup |
| 2399 |
% Shortcut-names: |
| 2400 |
\expandafter\let\expandafter\ifpgfplots@is@datascaled\csname ifpgfplots@apply@datatrafo@#1\endcsname |
| 2401 |
% Attention here: use UNSHIFTET scalings, see remark above |
| 2402 |
\expandafter\let\expandafter\ifpgfplots@cur@is@linear\csname ifpgfplots@#1islinear\endcsname |
| 2403 |
% |
| 2404 |
\let\desirednumticks=\c@pgf@countd |
| 2405 |
\let\Wr=\pgf@xc |
| 2406 |
\Wr=\csname pgfplotspoint#1axislength\endcsname\relax |
| 2407 |
% r = max place without ticks in pt -> choose desirednumticks >= W/r |
| 2408 |
\divide\Wr by\axisdefaulttickwidth\relax |
| 2409 |
\afterassignment\pgfplots@gobble@until@relax |
| 2410 |
\desirednumticks=\the\Wr\relax |
| 2411 |
\advance\desirednumticks by1 |
| 2412 |
\ifpgfplots@cur@is@linear |
| 2413 |
\ifnum\axisdefaulttryminticks>\desirednumticks\relax |
| 2414 |
\desirednumticks=\axisdefaulttryminticks\relax |
| 2415 |
\fi |
| 2416 |
\else |
| 2417 |
\ifnum\pgfplots@default@try@minticks@log>\desirednumticks\relax |
| 2418 |
\desirednumticks=\pgfplots@default@try@minticks@log\relax |
| 2419 |
\fi |
| 2420 |
\expandafter\ifx\csname pgfplots@#1tickten\endcsname\pgfutil@empty |
| 2421 |
\else |
| 2422 |
% log plot and tickten-option: provide special processing. |
| 2423 |
\edef\pgfplots@loc@TMPa{\csname pgfplots@#1tickten\endcsname}% |
| 2424 |
\expandafter\pgfplots@compute@tick@times@logten\pgfplots@loc@TMPa\to\pgfplots@glob@TMPa{#1}% |
| 2425 |
\expandafter\let\csname pgfplots@#1tick\endcsname=\pgfplots@glob@TMPa |
| 2426 |
\fi |
| 2427 |
\fi |
| 2428 |
\ifpgfplots@cur@is@linear |
| 2429 |
\else |
| 2430 |
\pgfplotscoordmath{#1}{parsenumber}{1}% |
| 2431 |
\let\pgfplots@loc@TMPa=\pgfmathresult |
| 2432 |
\pgfplotscoordmath{#1}{log from display log}{\pgfplots@loc@TMPa}% |
| 2433 |
\pgfplotscoordmath{#1}{tofixed}{\pgfmathresult}% |
| 2434 |
\let\pgfplots@loc@log@from@display@log@scale=\pgfmathresult |
| 2435 |
% |
| 2436 |
\pgfplotscoordmath{#1}{log to display log}{\pgfplots@loc@TMPa}% |
| 2437 |
\pgfplotscoordmath{#1}{tofixed}{\pgfmathresult}% |
| 2438 |
\let\pgfplots@loc@log@to@display@log@scale=\pgfmathresult |
| 2439 |
\fi |
| 2440 |
% |
| 2441 |
\expandafter\ifx\csname pgfplots@#1tick\endcsname\pgfutil@empty |
| 2442 |
% |
| 2443 |
% OK, automatically compute ticks: |
| 2444 |
\pgfplots@assign@default@tick@foraxis@compute#1% |
| 2445 |
% |
| 2446 |
\expandafter\global\expandafter\let\expandafter\pgfplots@glob@TMPa\csname pgfplots@#1tick\endcsname |
| 2447 |
\expandafter\global\expandafter\let\expandafter\pgfplots@glob@TMPb\csname pgfplots@tick@distance@#1\endcsname |
| 2448 |
\ifpgfplots@isuniformtick |
| 2449 |
\aftergroup\pgfplots@determinedefaultvalues@needs@check@uniformtickfalse |
| 2450 |
\else |
| 2451 |
% in this case, we better check... |
| 2452 |
\aftergroup\pgfplots@determinedefaultvalues@needs@check@uniformticktrue |
| 2453 |
\fi |
| 2454 |
\else |
| 2455 |
\expandafter\global\expandafter\let\expandafter\pgfplots@glob@TMPa\csname pgfplots@#1tick\endcsname |
| 2456 |
\gdef\pgfplots@glob@TMPb{}% will be computed later, in 'check uniform tick' |
| 2457 |
\aftergroup\pgfplots@determinedefaultvalues@needs@check@uniformticktrue |
| 2458 |
\fi |
| 2459 |
\endgroup |
| 2460 |
\expandafter\let\csname pgfplots@#1tick\endcsname=\pgfplots@glob@TMPa |
| 2461 |
\expandafter\let\csname pgfplots@tick@distance@#1\endcsname=\pgfplots@glob@TMPb |
| 2462 |
%\message{pgfplots.sty: #1tick set to \csname pgfplots@#1tick\endcsname [#1min=\csname pgfplots@#1min\endcsname, #1max=\csname pgfplots@#1max\endcsname].}% |
| 2463 |
} |
| 2464 |
|
| 2465 |
% Takes the distance between adjacent ticks as floating point number |
| 2466 |
% and returns a normalized tick distance. |
| 2467 |
% |
| 2468 |
% |
| 2469 |
% The idea is to get "nice" (human readable) distances instead of |
| 2470 |
% strange fractions or real numbers. |
| 2471 |
% |
| 2472 |
% The result will be assigned to \pgfmathresult (in float). |
| 2473 |
% |
| 2474 |
% #1 the axis (x or y or z) |
| 2475 |
% #2 the unnormalized tick distance computed so far |
| 2476 |
% |
| 2477 |
% Example: |
| 2478 |
% \pgfmathfloatparsenumber{x}{1234} |
| 2479 |
% \pgfplots@assign@default@tick@foraxis@normalizetickdist{x}{\pgfmathresult} |
| 2480 |
% \pgfmathfloatotfixed\pgfmathresult |
| 2481 |
% --> |
| 2482 |
% |
| 2483 |
% \pgfmathresult={1200} |
| 2484 |
% or something like that. |
| 2485 |
\def\pgfplots@assign@default@tick@foraxis@normalizetickdist#1#2{% |
| 2486 |
\begingroup |
| 2487 |
\let\H=\pgf@xb |
| 2488 |
\expandafter\pgfmathfloat@decompose#2\relax\pgfmathfloat@a@S\H\pgfmathfloat@a@E |
| 2489 |
% modify the mantisse: |
| 2490 |
\ifdim\H<2pt |
| 2491 |
\ifdim\H<1.5pt |
| 2492 |
\H=1.0pt |
| 2493 |
\else |
| 2494 |
\H=2.0pt |
| 2495 |
\fi |
| 2496 |
\else |
| 2497 |
\ifdim\H<4.9999pt |
| 2498 |
\ifdim\H<3.5pt |
| 2499 |
\H=2.0pt\relax |
| 2500 |
\else |
| 2501 |
\H=5.0pt\relax |
| 2502 |
\fi |
| 2503 |
\else |
| 2504 |
\ifdim\H<7.5pt |
| 2505 |
\H=5.0pt\relax |
| 2506 |
\else |
| 2507 |
\H=1.0pt\relax |
| 2508 |
\advance\pgfmathfloat@a@E by1 |
| 2509 |
\fi |
| 2510 |
\fi |
| 2511 |
\fi |
| 2512 |
\pgfmathfloatcreate{\the\pgfmathfloat@a@S}{\pgf@sys@tonumber{\H}}{\the\pgfmathfloat@a@E}% |
| 2513 |
\pgfmath@smuggleone\pgfmathresult |
| 2514 |
\endgroup |
| 2515 |
}% |
| 2516 |
|
| 2517 |
% Helper method for |
| 2518 |
% \pgfplots@apply@data@scale@trafo@to@options@for |
| 2519 |
% #1: the ticks |
| 2520 |
% #2: the trafo routine (not necessarily a single macro, but should |
| 2521 |
% take one arg) |
| 2522 |
% #3: the output macro name |
| 2523 |
\long\def\pgfplots@apply@data@scale@trafo@to@user@ticks#1#2\to#3{% |
| 2524 |
\pgfplots@transform@csv@list{#1}\to{#3}\with{% |
| 2525 |
\pgfplotscoordmath{float}{parse}{\pgfmathresult}% |
| 2526 |
%\pgfmathfloatparsenumber{\pgfmathresult}% |
| 2527 |
#2{\pgfmathresult}% |
| 2528 |
}% |
| 2529 |
}% |
| 2530 |
|
| 2531 |
% A helper macro which expects a \foreach-list '#1'. applies some transformation '#3' and stores results into a new csv list '#2'. |
| 2532 |
% '#3' is some macro. Its input is '\pgfmathresult', its expected output is '\pgfmathresult' |
| 2533 |
\long\def\pgfplots@transform@csv@list#1\to#2\with#3{% |
| 2534 |
\let#2=\pgfutil@empty |
| 2535 |
\begingroup |
| 2536 |
\pgfkeys{/pgf/fpu,/pgf/fpu/output format=float}% |
| 2537 |
% \pgfplotsforeachungrouped is more powerful than \foreach |
| 2538 |
\pgfplotsforeachungrouped \pgfplots@loc@TMPb in {#1} {% |
| 2539 |
\let\pgfmathresult=\pgfplots@loc@TMPb |
| 2540 |
#3% |
| 2541 |
\ifx#2\pgfutil@empty |
| 2542 |
\xdef#2{\pgfmathresult}% |
| 2543 |
\else |
| 2544 |
\xdef#2{#2,\pgfmathresult}% |
| 2545 |
\fi |
| 2546 |
}% |
| 2547 |
\endgroup |
| 2548 |
% |
| 2549 |
}% |
| 2550 |
|
| 2551 |
% Helper method for |
| 2552 |
% \pgfplots@apply@data@scale@trafo@to@options@for |
| 2553 |
% #1: the ticks ALREADY IN FLOAT FORMAT |
| 2554 |
% #2: the trafo macro name |
| 2555 |
% #3: the output macro name |
| 2556 |
\long\def\pgfplots@apply@data@scale@trafo@to@user@ticks@isfloat#1#2\to#3{% |
| 2557 |
\let#3=\pgfutil@empty |
| 2558 |
\foreach \pgfplots@loc@TMPb in {#1} {% |
| 2559 |
#2{\pgfplots@loc@TMPb}% |
| 2560 |
\ifx#3\pgfutil@empty |
| 2561 |
\xdef#3{\pgfmathresult}% |
| 2562 |
\else |
| 2563 |
\xdef#3{#3,\pgfmathresult}% |
| 2564 |
\fi |
| 2565 |
}% |
| 2566 |
% |
| 2567 |
}% |
| 2568 |
|
| 2569 |
% Adds a further, temporary anchor to every node which will be |
| 2570 |
% processed. The anchor will be named '#2'. It is placed such that |
| 2571 |
% 1. the node's center is on a line in direction of the inwards normal |
| 2572 |
% vector of the #1 ticklabel axis and the 'at' position of the node, |
| 2573 |
% 2. the node does not intrude the axis. |
| 2574 |
% |
| 2575 |
% In effect, one of the node's standard anchors (north, east, ... ) |
| 2576 |
% will be placed on the line |
| 2577 |
% \draw[blue,thick,->] (xticklabel cs:0,0) -- (xticklabel cs:1,0); |
| 2578 |
% |
| 2579 |
% This command is identical to calling |
| 2580 |
% \pgfplotsdeclareborderanchorforaxis{#1}{<three-char-string-of-#1-ticklabel-axis>}{#2} |
| 2581 |
% |
| 2582 |
% @REMARKS: |
| 2583 |
% - it is -by no means- necessary that any ticks or tick labels are |
| 2584 |
% drawn or defined for this method. |
| 2585 |
% - in fact, tick labels use such an anchor (the 'near #1ticklabel' |
| 2586 |
% anchor is defined in this way) |
| 2587 |
\def\pgfplotsdeclareborderanchorforticklabelaxis#1#2{% |
| 2588 |
\pgfplotsdeclareborderanchorforaxis{#1}{\pgfplotsticklabelaxisspec{#1}}{#2}% |
| 2589 |
} |