Debian Codegraph @

texmf-dist/tex/generic/pgfplots/libs/tikzlibrarypgfplots.polar.code.tex

raw
1 %--------------------------------------------
2 %
3 % Package pgfplots, library for polar coordinates.
4 %
5 % Copyright 2010 by Christian Feuersänger.
6 %
7 % This program is free software: you can redistribute it and/or modify
8 % it under the terms of the GNU General Public License as published by
9 % the Free Software Foundation, either version 3 of the License, or
10 % (at your option) any later version.
11 %
12 % This program is distributed in the hope that it will be useful,
13 % but WITHOUT ANY WARRANTY; without even the implied warranty of
14 % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 % GNU General Public License for more details.
16 %
17 % You should have received a copy of the GNU General Public License
18 % along with this program. If not, see <http://www.gnu.org/licenses/>.
19 %
20 % A polar axis lives in (ANGLE,LENGTH).
21 % That is
22 % x == ANGLE
23 % y == LENGTH
24 %
25 %
26
27 \pgfplotsdefineaxistype[polar]{polar}{%
28 \pgfplots@polaraxis@activate
29 }%
30
31 \newif\ifpgfplots@polaraxis@rellimits
32
33 \pgfplotsset{
34 /pgfplots/every polar axis/.style={
35 grid=major,
36 xtick pos=right,
37 ytick pos=right,
38 every axis title shift=1.2\baselineskip,
39 legend style={anchor=center},
40 /pgfplots/polar labels,
41 },
42 /pgfplots/polar labels/.code={
43 % this is equivalent to 'use units=false'. But that key is only available if the units lib is loaded.
44 \pgfplots@units@usefalse
45 \if1\b@pgfplots@polaraxis@fix@positioning
46 \pgfkeysalso{%
47 every axis x label/.style={
48 at={(xticklabel cs:0.125)},
49 sloped={at position=45},
50 anchor=near ticklabel,
51 near ticklabel at=45,
52 },
53 every axis y label/.style={
54 at={(yticklabel cs:0.5)},
55 anchor=near ticklabel,
56 },
57 }%
58 \else
59 \pgfkeysalso{%
60 % is this a good choice? No, it is not.
61 % In fact, I believe that neither xlabel nor ylabel is a good idea for a polar plot.
62 % BUT: if we simply leave the defaults, they will be placed outside of the circle - and
63 % this will confuse the units library which (for some reason) always generates labels.
64 every axis x label/.style={
65 at={(rel axis cs:0,0.5)},
66 anchor=north,
67 },
68 every axis y label/.style={
69 at={(0.2,0.85)},
70 anchor=center,
71 },
72 }%
73 \fi
74 },
75 /pgfplots/polar labels style/.style={%
76 /pgfplots/polar labels/.append style={#1}%
77 },%
78 /pgfplots/xticklabel in circle/.style={
79 xtick align=inside,
80 xticklabel style={
81 rotate=90,
82 sloped like x axis={%
83 execute for upside down={\tikzset{anchor=north east}},
84 %allow upside down,
85 reset nontranslations=false},
86 anchor=south west,
87 %font=\tiny,
88 }
89 },
90 }
91
92 \def\pgfplots@polaraxis@activate{%
93 % FIXME : activating it results in strange output:
94 \pgfplots@LUA@backend@supportedfalse
95 %
96 \let\pgfplotsqpointxy@cart=\pgfplotsqpointxy
97 \let\pgfplotsqpointxy=\pgfplotsqpointxy@polaraxis
98 \let\pgfplotsqpointxy@orthogonal=\pgfplotsqpointxy
99 \if1\b@pgfplots@polaraxis@fix@positioning
100 % this is needed in order to let
101 % \pgfplotspointonorientedsurfaceab work
102 \def\pgfplotsqpointxyz##1##2##3{%
103 % ignore z here.
104 \pgfplotsqpointxy{##1}{##2}%
105 }%
106 \fi
107 \let\pgfplotspointouternormalvectorofaxis@=\pgfplotspointouternormalvectorofaxis@polaraxis
108 \def\pgfplotspointouternormalvectorofaxis@ifdependson@v##1##2##3{##2}%
109 \def\pgfplots@drawtickgridlines@INSTALLCLIP@onorientedsurf##1{}%
110 \let\pgfplots@clippath@prepare@for@axistype=\pgfplots@clippath@prepare@for@axistype@polaraxis
111 \let\pgfplots@handle@invalid@range@defaultlimits=\pgfplots@handle@invalid@range@defaultlimits@polar%
112 \let\pgfplots@check@invalid@range=\pgfplots@check@invalid@range@polar
113 \let\pgfplotspointonorientedsurfaceabwithbshift=\pgfplotspointonorientedsurfaceabwithbshift@polaraxis
114 \let\pgfplots@drawgridlines@onorientedsurf@fromto=\pgfplots@drawgridlines@onorientedsurf@fromto@polar
115 \let\pgfplotspoint@initialisation@axes=\pgfplotspoint@initialisation@axes@polar%
116 \let\pgfplotspoint@initialisation@units=\pgfplotspoint@initialisation@units@polar
117 \let\pgfplotsaxisifcontainspoint=\pgfplotsaxisifcontainspoint@polar
118 \let\pgfplots@prepare@axis@API=\pgfplots@prepare@axis@API@polar
119 \def\axisdefaultheight{\axisdefaultwidth}%
120 \let\pgfplots@initsizes=\pgfplots@initsizes@polar
121 \let\pgfplots@BB@for@plotbox@get@unit@scales@for@limits=\pgfplots@BB@for@plotbox@get@unit@scales@for@limits@polar
122 \let\pgfplots@limits@ready=\pgfplots@limits@ready@polar
123 \let\pgfplots@assign@default@tick@foraxis@normalizetickdist=\pgfplots@assign@default@tick@foraxis@normalizetickdist@polar
124 \let\pgfplots@show@ticklabel@=\pgfplots@show@ticklabel@@polar
125 \let\pgfplots@transformshift@along@outer@normal@on@line@of@oriented@surf=\pgfplots@transformshift@along@outer@normal@on@line@of@oriented@surf@polar
126 \let\pgfplots@enlarge@limit@for=\pgfplots@enlarge@limit@for@polar
127 \let\pgfplotstransformtoaxisdirection@=\pgfplotstransformtoaxisdirection@@polar
128 \def\pgfplots@xtick@disable@last@tick{0}%
129 \let\pgfplots@xtick@check@tickshow=\pgfplots@xtick@check@tickshow@polar%
130 \let\pgfplots@set@options@sanitize=\relax
131 \let\pgfplots@set@options@sanitizemode=\relax
132 \let\pgfplotscoordmathnotifydatascalesetfor=\pgfplotscoordmathnotifydatascalesetfor@polar
133 %
134 % this here is set *before* 'every polar axis' is invoked.
135 \pgfplotsset{
136 enlarge x limits=false,
137 }%
138 \expandafter\def\expandafter\pgfplots@notify@options@are@set\expandafter{%
139 \pgfplots@notify@options@are@set
140 \pgfplotsset{separate axis lines}%
141 }%
142 \def\pgfplots@xticklabel@pos{}%
143 \def\pgfplots@yticklabel@pos{}%
144 \def\pgfplots@zticklabel@pos{}%
145 \def\pgfplots@init@ticklabelaxisspecfor##1##2{}%
146 \def\pgfplots@init@ticklabelaxisspec@twodim@for##1##2{}%
147 \def\pgfplots@xticklabelaxisspec{v10}%
148 \def\pgfplots@yticklabelaxisspec{0v0}%
149 \def\pgfplots@zticklabelaxisspec{00v}%
150 %
151 % cartesian cs
152 \tikzdeclarecoordinatesystem{cartesian}{\edef\pgfplots@loc@TMPa{##1}\expandafter\pgfplotspointcartesian@\pgfplots@loc@TMPa\pgfplots@coord@end}%
153 %
154 }%
155
156 \let\pgfplots@prepare@axis@API@orig=\pgfplots@prepare@axis@API
157 \def\pgfplots@prepare@axis@API@polar{%
158 \pgfplots@prepare@axis@API@orig
159 \let\pgfplotsaxisupdatelimitsforcoordinatetwodim=\pgfplotsaxisupdatelimitsforcoordinatetwodim@polar
160 \let\pgfplotsaxisupdatelimitsforcoordinatethreedim=\pgfplotsaxisupdatelimitsforcoordinatetwodim@polar
161 }%
162
163 \let\pgfplotstransformtoaxisdirection@@orig=\pgfplotstransformtoaxisdirection@
164 \def\pgfplotstransformtoaxisdirection@@polar[#1]#2{%
165 \if#2y%
166 \pgfplotstransformtoaxisdirection@@orig[#1]{#2}%
167 \else
168 % ah, the angle. Treat it with special care.
169 \pgfplots@sloped@allowupsidedownfalse
170 \pgfplots@sloped@resets@nontranslationstrue
171 %
172 \def\pgfplots@loc@TMPa{#1}%
173 \ifx\pgfplots@loc@TMPa\pgfutil@empty
174 \else
175 \pgfqkeys{/pgfplots/sloped}{#1}%
176 \fi
177 \ifpgfplots@sloped
178 %
179 \ifpgfplots@sloped@resets@nontranslations
180 \pgftransformresetnontranslations
181 \fi
182 %
183 \pgfkeysgetvalue{/pgfplots/sloped/at position}\pgfplots@loc@TMPd
184 \ifx\pgfplots@loc@TMPd\pgfutil@empty
185 \def\pgfplots@loc@TMPd{90}%
186 \else
187 \pgfmathparse{90+\pgfplots@loc@TMPd}%
188 \let\pgfplots@loc@TMPd=\pgfmathresult
189 \fi
190 \pgfpointpolar{\pgfplots@loc@TMPd}{1pt}%
191 %
192 \ifdim\pgf@x<0pt%
193 % oh. upside down.
194 \pgfkeysvalueof{/pgfplots/sloped/execute for upside down}%
195 \ifpgfplots@sloped@allowupsidedown
196 \else
197 % do not allow upside down labels:
198 \global\pgf@x=-\pgf@x%
199 \global\pgf@y=-\pgf@y%
200 \fi
201 \fi%
202 %
203 \pgf@ya=-\pgf@y%
204 % set up rotation matrix
205 % [ cos(alpha) sin(alpha);
206 % -sin(alpha) cos(alpha) ]
207 % where cos(alpha) = n_x and sin(alpha) = n_y:
208 \pgftransformcm%
209 {\pgf@sys@tonumber{\pgf@x}}{\pgf@sys@tonumber{\pgf@y}}%
210 {\pgf@sys@tonumber{\pgf@ya}}{\pgf@sys@tonumber{\pgf@x}}{\pgfpointorigin}%
211 \fi
212 \fi
213 }
214
215 \def\pgfplotsaxisupdatelimitsforcoordinatetwodim@polar#1#2#3{%
216 %
217 %
218 % Update limits:
219 % I do not respect x limits (since they are periodic).
220 % Consequently, I do not respect the clip limits options here (I
221 % suppose it is useless)
222 %
223 % for y (radius) limits, I always use the ABSOLUTE value:
224 \pgfmathfloatabs@{#2}%
225 \let\pgfplots@loc@limit=\pgfmathresult
226 %
227 \ifpgfplots@autocompute@ymax
228 \ifpgfplots@yislinear
229 \pgfplotsmathfloatmax{\pgfplots@ymax}{\pgfplots@loc@limit}%
230 \global\let\pgfplots@ymax=\pgfmathresult
231 \else
232 \pgfplotsmathmax{\pgfplots@ymax}{\pgfplots@loc@limit}%
233 \global\let\pgfplots@ymax=\pgfmathresult
234 \fi
235 \fi
236 %
237 % Compute data range:
238 \pgfplotsmathfloatmin{\pgfplots@data@xmin}{#1}%
239 \global\let\pgfplots@data@xmin=\pgfmathresult
240 \pgfplotsmathfloatmax{\pgfplots@data@xmax}{#1}%
241 \global\let\pgfplots@data@xmax=\pgfmathresult
242 \pgfplotsmathfloatmin{\pgfplots@data@ymin}{#2}%
243 \global\let\pgfplots@data@ymin=\pgfmathresult
244 \pgfplotsmathfloatmax{\pgfplots@data@ymax}{#2}%
245 \global\let\pgfplots@data@ymax=\pgfmathresult
246 %\pgfplots@message{Updated limits: (\pgfplots@xmin,\pgfplots@ymin) rectangle (\pgfplots@xmax,\pgfplots@ymax).}%
247 %
248 %\tracingmacros=0\tracingcommands=0
249 }%
250 \def\pgfplotsaxisifcontainspoint@polar#1#2{%
251 \begingroup
252 \pgfmath@basic@mod@{\pgfplots@current@point@x}{360}%
253 \pgf@xa=\pgfmathresult pt %
254 %
255 \pgf@ya=\pgfplots@current@point@y pt %
256 \ifdim\pgf@ya<0pt
257 % absolute value:
258 \pgf@ya=-\pgf@ya
259 \fi
260 %\message{ifcontainspoint(\the\pgf@xa,\pgfplots@current@point@y) limits = [\pgfplots@xmin@mod:\pgfplots@xmax@mod] x [\the\pgfplots@ymin@reg,\the\pgfplots@ymax@reg]^^J}%
261 %
262 % I assume that \pgfplots@[xyz]min@reg and min@reg are registers
263 % containing the limits.
264 \pgfplots@loop@CONTINUEfalse
265 \ifdim\pgf@ya<\pgfplots@ymin@reg
266 \else
267 \ifdim\pgf@ya>\pgfplots@ymax@reg
268 \else
269 \if1\b@pgfplots@polar@limit@around@zero
270 % check condition
271 % x <= max || x >= min
272 % <=> ! (x > max && x < min)
273 \pgfplots@loop@CONTINUEtrue
274 \ifdim\pgf@xa>\pgfplots@xmax@mod pt %
275 \ifdim\pgf@xa<\pgfplots@xmin@mod pt %
276 \pgfplots@loop@CONTINUEfalse
277 \fi
278 \fi
279 \else
280 \ifdim\pgf@xa<\pgfplots@xmin@mod pt %
281 \else
282 \ifdim\pgf@xa>\pgfplots@xmax@mod pt %
283 \else
284 \pgfplots@loop@CONTINUEtrue
285 \fi
286 \fi
287 \fi
288 \fi
289 \fi
290 \ifpgfplots@loop@CONTINUE
291 \def\pgfplots@loc@TMPa{#1}%
292 \else
293 \def\pgfplots@loc@TMPa{#2}%
294 \fi
295 \expandafter\endgroup\pgfplots@loc@TMPa%
296 }
297
298 \def\pgfplots@check@invalid@range@polar{%
299 %
300 % A polar axis allows \addplot3, but it ignores the third
301 % coordinate.
302 \pgfplots@threedimfalse
303 %
304 \pgfplots@limits@are@computedtrue
305 \ifx\pgfplots@xmin\pgfplots@invalidrange@xmin
306 \pgfplotscoordmath{x}{zero}%
307 \let\pgfplots@xmin=\pgfmathresult
308 \fi
309 \ifx\pgfplots@xmax\pgfplots@invalidrange@xmax
310 \pgfplotscoordmath{x}{parsenumber}{360}%
311 \let\pgfplots@xmax=\pgfmathresult
312 \fi
313 \ifx\pgfplots@ymin\pgfplots@invalidrange@ymin
314 \pgfplotscoordmath{y}{zero}%
315 \let\pgfplots@ymin=\pgfmathresult
316 \fi
317 \ifx\pgfplots@ymax\pgfplots@invalidrange@ymax
318 \pgfplots@limits@are@computedfalse
319 \fi
320 \ifpgfplots@limits@are@computed
321 \ifx\pgfplots@data@xmin\pgfplots@invalidrange@xmin
322 \global\let\pgfplots@data@xmin=\pgfplots@xmin
323 \fi
324 \ifx\pgfplots@data@xmin\pgfplots@invalidrange@xmax
325 \global\let\pgfplots@data@xmax=\pgfplots@xmax
326 \fi
327 \ifx\pgfplots@data@ymin\pgfplots@invalidrange@ymin
328 \global\let\pgfplots@data@ymin=\pgfplots@ymin
329 \fi
330 \ifx\pgfplots@data@ymin\pgfplots@invalidrange@ymax
331 \global\let\pgfplots@data@ymax=\pgfplots@ymax
332 \fi
333 \ifpgfplots@clip@limits@x
334 \else
335 % there is a rare change that min > max.
336 % Handle that ...
337 \pgfplotscoordmath{x}{min}{\pgfplots@xmin}{\pgfplots@xmax}%
338 \global\let\pgfplots@xmin=\pgfmathresult
339 \pgfplotscoordmath{x}{max}{\pgfplots@xmin}{\pgfplots@xmax}%
340 \global\let\pgfplots@xmax=\pgfmathresult
341 \fi
342 \ifpgfplots@clip@limits@y
343 \else
344 %
345 \pgfplotscoordmath{y}{min}{\pgfplots@ymin}{\pgfplots@ymax}%
346 \global\let\pgfplots@ymin=\pgfmathresult
347 \pgfplotscoordmath{y}{max}{\pgfplots@ymin}{\pgfplots@ymax}%
348 \global\let\pgfplots@ymax=\pgfmathresult
349 %
350 \fi
351 \ifpgfplots@clip@limits@z
352 \else
353 \ifpgfplots@threedim
354 \pgfplotscoordmath{z}{min}{\pgfplots@zmin}{\pgfplots@zmax}%
355 \global\let\pgfplots@zmin=\pgfmathresult
356 \pgfplotscoordmath{z}{max}{\pgfplots@zmin}{\pgfplots@zmax}%
357 \global\let\pgfplots@zmax=\pgfmathresult
358 \fi
359 \fi
360 \else
361 \pgfplots@handle@invalid@range
362 \fi
363 }%
364
365 \def\pgfplotspointcartesian@#1,#2\pgfplots@coord@end{%
366 \pgfpointxy@orig{#1}{#2}%
367 }%
368 \def\pgfplotscoordmathnotifydatascalesetfor@polar#1{%
369 \def\pgfplotscoordmathnotifydatascalesetfor##1{}%
370 \edef\pgfplotscoordmathnotifydatascalesetfor@{#1}%
371 \def\pgfplotscoordmathnotifydatascalesetfor@@{x}%
372 \ifx\pgfplotscoordmathnotifydatascalesetfor@@\pgfplotscoordmathnotifydatascalesetfor@
373 \pgfplotscoordmath{#1}{datascaletrafo set params}{0}{0}%
374 \else
375 \def\pgfplotscoordmathnotifydatascalesetfor@@{y}%
376 \ifx\pgfplotscoordmathnotifydatascalesetfor@@\pgfplotscoordmathnotifydatascalesetfor@
377 \pgfplotscoordmath{#1}{datascaletrafo set shift}{0}%
378 \fi
379 \fi
380 \let\pgfplotscoordmathnotifydatascalesetfor=\pgfplotscoordmathnotifydatascalesetfor@polar
381 }%
382
383 % #1: the "a" value on the oriented surf
384 % #2: the "b" value.
385 % #3: the shift along the normal.
386 %
387 \def\pgfplotspointonorientedsurfaceabwithbshift@polaraxis#1#2#3{%
388 % implement the shift in "b" direction explicitly:
389 %
390 \pgfplotspointonorientedsurfaceab{#1}{#2}%
391 \edef\pgfplots@loc@TMPe{\pgf@x=\the\pgf@x\space\pgf@y=\the\pgf@y\space}%
392 \pgfpointadd
393 {\pgfplots@loc@TMPe}%
394 {%
395 \begingroup
396 % I need a '-' here because for polaraxis axes, the "b" axis
397 % points to the *outside* instead of the inside.
398 \pgf@xa=-#3\relax
399 \if r\pgfkeysvalueof{/pgfplots/\pgfplotspointonorientedsurfaceB\space dir/value}%
400 % oh. a reversed axis.
401 \pgf@xa=-\pgf@xa
402 \fi
403 \edef\pgfmathresult{\pgf@sys@tonumber\pgf@xa}%
404 \pgfmath@smuggleone\pgfmathresult
405 \endgroup
406 \let\pgfplots@loc@TMPa=\pgfmathresult
407 \pgfqpointscale{\pgfplots@loc@TMPa}{%
408 \if x\pgfplotspointonorientedsurfaceB
409 % the angle.
410 % FIXME : datascaling!
411 % FIXME : aspect ratios!
412 \pgfmath@basic@sin@{#2}%
413 \pgf@x=-\pgfmathresult pt
414 \pgfmath@basic@cos@{#2}%
415 \pgf@y=\pgfmathresult pt
416 \else
417 % the length.
418 % FIXME : datascaling!
419 % FIXME : aspect ratios!
420 % perhaps pgfpointpolarxy?
421 \if y\pgfplotspointonorientedsurfaceB
422 \if r\pgfkeysvalueof{/pgfplots/\pgfplotspointonorientedsurfaceA\space dir/value}%
423 \pgfqpointpolar{-#1}{-1pt}%
424 \else
425 \pgfqpointpolar{#1}{1pt}%
426 \fi
427 \else
428 \pgfpointorigin
429 \fi
430 \fi
431 }%
432 }%
433 }
434
435
436 \def\pgfplotsqpointxy@polaraxis#1#2{%
437 \pgf@process{%
438 \pgfplotsmathpoltocartbasic{#1}{#2}\x\y
439 \pgfqpointxy@orig\x\y
440 %\message{pgfplotsqpointxy{#1}{#2} ---> (\x,\y) ---> (\the\pgf@x,\the\pgf@y)}%
441 }%
442 }%
443 \def\pgfplots@clippath@prepare@for@axistype@polaraxis{%
444 \def\pgfplots@clippath@install##1{%
445 \pgfpathmoveto
446 {\pgfplotsqpointxy\pgfplots@xmin\pgfplots@ymax}%
447 \pgfpatharcaxes{\pgfplots@xmin}{\pgfplots@xmax}
448 {\pgfqpointxy@orig{\pgfplots@ymax}{0}}%
449 {\pgfqpointxy@orig{0}{\pgfplots@ymax}}%
450 \if1\pgfplots@xtick@disable@last@tick
451 % we have min angle = max angle.
452 \ifdim\pgfplots@ymin pt=0pt
453 \else
454 \pgfseteorule
455 \pgfpathmoveto
456 {\pgfplotsqpointxy\pgfplots@xmin\pgfplots@ymin}%
457 \pgfpatharcaxes{\pgfplots@xmin}{\pgfplots@xmax}
458 {\pgfqpointxy@orig{\pgfplots@ymin}{0}}%
459 {\pgfqpointxy@orig{0}{\pgfplots@ymin}}%
460 \fi
461 \else
462 % we have min angle != max angle.
463 \ifdim\pgfplots@ymin pt=0pt
464 % Ok, then pass through origin:
465 \pgfpathlineto\pgfplotspointaxisorigin
466 \else
467 % complicated special case.
468 \pgfpathlineto
469 {\pgfplotsqpointxy\pgfplots@xmax\pgfplots@ymin}%
470 \pgfpatharcaxes{\pgfplots@xmax}{\pgfplots@xmin}
471 {\pgfqpointxy@orig{\pgfplots@ymin}{0}}%
472 {\pgfqpointxy@orig{0}{\pgfplots@ymin}}%
473 \fi
474 \pgfpathclose
475 \fi
476 \pgfplots@clippath@use@{##1}%
477 }%
478 }%
479
480 \def\pgfplotspointouternormalvectorofaxis@polaraxis#1#2#3\relax{%
481 \if v#1%
482 % ah, we want to find the outer normal for an ANGLE.
483 %
484 % That's tricky because we need the current value! What if we
485 % do not have one?
486 \pgfplotspointouternormalvectorofaxisgetv{#1#2#3}%
487 % in direction of the length.
488 \ifx\pgfplotsretval\pgfutil@empty
489 \pgfplotswarning{missing near ticklabel at}{}\pgfeov%
490 % oh, what a mess. We do not know the angle!
491 % this means the alignment will be wrong (most likely...)
492 \def\pgfplotsretval{0}%
493 \fi
494 % FIXME : datascaling!
495 % FIXME : aspect ratios!
496 % perhaps pgfpointpolarxy?
497 \if r\pgfkeysvalueof{/pgfplots/x dir/value}%
498 \pgfqpointpolar{-\pgfplotsretval}{-1pt}%
499 \else
500 \pgfqpointpolar{\pgfplotsretval}{1pt}%
501 \fi
502 \else
503 \if v#2%
504 \if#10%
505 \def\pgfplotsretval{\pgfplots@xmin}%
506 \else
507 \def\pgfplotsretval{\pgfplots@xmax}%
508 \fi
509 % in direction of the angle.
510 % FIXME : datascaling!
511 % FIXME : aspect ratios!
512 \pgfmath@basic@sin@{\pgfplotsretval}%
513 \pgf@x=-\pgfmathresult pt
514 \pgfmath@basic@cos@{\pgfplotsretval}%
515 \pgf@y=\pgfmathresult pt
516 \else
517 \pgfqpoint{0pt}{1pt}%
518 \fi
519 \fi
520 %\pgf@process{\pgfpointnormalised{}}%
521 \pgf@process{}%
522 \endgroup
523 }%
524
525 \def\pgfplotspoint@initialisation@axes@polar{%
526 %
527 \begingroup
528 \pgfplotsqpointxy{\pgfplots@xmin}{\pgfplots@ymin}%
529 \xdef\pgfplotspointminminmin{\noexpand\pgf@x=\the\pgf@x\space\noexpand\pgf@y=\the\pgf@y\space}%
530 %
531 \pgfplotsqpointxy{\pgfplots@xmax}{\pgfplots@ymax}%
532 \xdef\pgfplotspointxaxis{\noexpand\pgf@x=\the\pgf@x\space\noexpand\pgf@y=\the\pgf@y\space}%
533 %
534 % the length of the "angle" axis is 2*pi*r .
535 % The radius, however, is the length of (0,ymax) which is (0pt,\pgf@xx*ymax):
536 \pgfmath@basic@multiply@{\pgf@sys@tonumber\pgf@xx}{\pgfplots@ymax}%
537 \pgfmathmultiply@{\pgfmathresult}{6.28318530717959}% 2*pi * r
538 \if0\pgfplots@xtick@disable@last@tick
539 % oh: minangle != maxangle. We have a partial circle.
540 % compute the arc length (<360 deg)
541 \pgf@xa=\pgfplots@xmax pt
542 \advance\pgf@xa by-\pgfplots@xmin pt
543 \divide\pgf@xa by360
544 \ifdim\pgf@xa<1pt
545 \edef\pgfplots@loc@TMPa{\pgf@sys@tonumber\pgf@xa}%
546 \pgfmathmultiply@{\pgfmathresult}{\pgfplots@loc@TMPa}%
547 \fi
548 \fi
549 \xdef\pgfplotspointxaxislength{\pgfmathresult pt}%
550 %
551 \pgfpointdiff
552 {\pgfplotsqpointxy{\pgfplots@xmax}{\pgfplots@ymin}}%
553 {\pgfplotsqpointxy{\pgfplots@xmax}{\pgfplots@ymax}}%
554 \xdef\pgfplotspointyaxis{\noexpand\pgf@x=\the\pgf@x\space\noexpand\pgf@y=\the\pgf@y\space}%
555 \pgfmathveclen{\pgf@x}{\pgf@y}%
556 \xdef\pgfplotspointyaxislength{\pgfmathresult pt}%
557 %
558 \global\let\pgfplotspointzaxis=\pgfpointorigin
559 \gdef\pgfplotspointzaxislength{0pt}%
560 \endgroup
561 %
562 }
563 \let\pgfplotspoint@initialisation@units@orig=\pgfplotspoint@initialisation@units
564 \def\pgfplotspoint@initialisation@units@polar{%
565 \def\pgfplotspointunitx{%
566 \pgfplotspointouternormalvectorofaxisgetv{v10}% angle varying, radius at outer pos
567 \ifx\pgfplotsretval\pgfutil@empty
568 \def\pgfplotsretval{0}%
569 \fi
570 \if r\pgfkeysvalueof{/pgfplots/x dir/value}%
571 \edef\pgfplotsretval{-\pgfplotsretval}%
572 \fi
573 \pgfmath@basic@sin@{\pgfplotsretval}%
574 \pgf@x=-\pgfmathresult pt
575 \pgfmath@basic@cos@{\pgfplotsretval}%
576 \pgf@y=\pgfmathresult pt
577 }%
578 \def\pgfplotsunitxlength{1}%
579 \def\pgfplotsunitxinvlength{1}%
580 %
581 \def\pgfplotspointunity{%
582 % FIXME : what about 'x dir=reverse' !?
583 \pgfqpointpolar{\pgfplots@xmin}{1pt}%
584 }%
585 \def\pgfplotsunitylength{1}%
586 \def\pgfplotsunityinvlength{1}%
587 }%
588
589 \def\pgfplots@transformshift@along@outer@normal@on@line@of@oriented@surf@polar#1#2{%
590 \if v#1%
591 \let\pgfplots@loc@TMPa=\pgfplotspointonorientedsurfaceA%
592 \if v#2%
593 \pgfplots@error{Exactly one of '#1' or '#2' must be 'v', not both}%
594 \fi
595 \else
596 \if v#2%
597 \let\pgfplots@loc@TMPa=\pgfplotspointonorientedsurfaceB%
598 \else
599 \pgfplots@error{One of '#1' or '#2' must be 'v'}%
600 \fi
601 \fi
602 %
603 \if x\pgfplots@loc@TMPa
604 \else
605 \pgfplots@transformshift@along@outer@normal@on@line@of@oriented@surf@orig{#1}{#2}%
606 \fi
607 }%
608 \def\pgfplots@drawgridlines@onorientedsurf@fromto@polar#1{%
609 \if x\pgfplotspointonorientedsurfaceA
610 \pgfpathmoveto{\pgfplotspointonorientedsurfaceab{#1}{\csname pgfplots@\pgfplotspointonorientedsurfaceB min\endcsname}}%
611 \pgfpathlineto{\pgfplotspointonorientedsurfaceab{#1}{\csname pgfplots@\pgfplotspointonorientedsurfaceB max\endcsname}}%
612 \else
613 \if y\pgfplotspointonorientedsurfaceA\relax
614 \pgfpathmoveto{\pgfplotspointonorientedsurfaceab{#1}{\csname pgfplots@\pgfplotspointonorientedsurfaceB min\endcsname}}%
615 \pgf@x=#1\pgf@xx
616 \pgf@y=#1\pgf@yy
617 \edef\pgfplots@loc@TMPa{\the\pgf@x\space and \the\pgf@y}%
618 \def\pgfplots@loc@TMPb{\pgfpatharc{\pgfplots@xmin}{\pgfplots@xmax}}%
619 \expandafter\pgfplots@loc@TMPb\expandafter{\pgfplots@loc@TMPa}%
620 \else
621 \fi
622 \fi
623 }%
624
625 \let\pgfplots@initsizes@original=\pgfplots@initsizes
626
627 \def\pgfplots@initsizes@polar{%
628 % I copy-pasted most of this code, up to just one position where
629 % I introduced the modified scaling for polar axes
630 %----------------------------------
631 % INIT.
632 %
633 %
634 \pgfmath@basic@mod@{\pgfplots@xmin}{360}%
635 \let\pgfplots@xmin@mod=\pgfmathresult
636 \pgfmath@basic@mod@{\pgfplots@xmax}{360}%
637 \let\pgfplots@xmax@mod=\pgfmathresult
638 \ifdim\pgfplots@xmax@mod pt>\pgfplots@xmin@mod pt
639 \def\b@pgfplots@polar@limit@around@zero{0}%
640 \else
641 \def\b@pgfplots@polar@limit@around@zero{1}%
642 \fi
643 %
644 \pgfplots@initsizes@original
645 }%
646
647 \def\pgfplots@BB@for@plotbox@get@unit@scales@for@limits@polar#1#2#3{%
648 % #1 is the angle ... and that does not need to be squeezed into
649 % the box.
650 %
651 % use only y (the radius).
652 \if1\b@pgfplots@plotbox@yisunit
653 % we do not need to compute max-min as for standard axes (because the inner part
654 % characterized by ymin does not enter the scaling).
655 %
656 % However, we have to keep in mind that our range is TWICE as
657 % large because [0,ymax] is just a radius, and we have to
658 % scale for the diameter.
659 \pgfplotscoordmath{\pgfplots@compat@scaling@coordmath}{parsenumber}{2}%
660 \let\pgfplots@loc@TMPa=\pgfmathresult
661 %
662 \let\pgfmathresult=\pgfplots@ymax
663 \pgfplotscoordmath{\pgfplots@compat@scaling@coordmath}{parsenumber}{\pgfmathresult}%
664 \pgfplotscoordmath{\pgfplots@compat@scaling@coordmath}{op}{multiply}{{\pgfmathresult}{\pgfplots@loc@TMPa}}%
665 \pgfplotscoordmath{\pgfplots@compat@scaling@coordmath}{tofixed}{\pgfmathresult}%
666 \else
667 \def\pgfmathresult{2}% not 1: the factor 2 is for 2*radius
668 \fi
669 \let#1=\pgfmathresult
670 \let#2=\pgfmathresult
671 \def#3{1}% FIXME : z ?
672 }%
673
674 \def\pgfplots@handle@invalid@range@defaultlimits@polar{%
675 \def\pgfplots@loc@TMPa{0}%
676 \ifx\pgfplots@xmin\pgfplots@invalidrange@xmin
677 \def\pgfplots@loc@TMPa{1}%
678 \fi
679 \ifx\pgfplots@xmax\pgfplots@invalidrange@xmax
680 \def\pgfplots@loc@TMPa{1}%
681 \fi
682 \if\pgfplots@loc@TMPa1%
683 \pgfplotscoordmath{x}{parsenumber}{0}%
684 \global\let\pgfplots@xmin=\pgfmathresult
685 \pgfplotscoordmath{x}{parsenumber}{360}%
686 \global\let\pgfplots@xmax=\pgfmathresult
687 \global\let\pgfplots@data@xmin=\pgfplots@xmin
688 \global\let\pgfplots@data@xmax=\pgfplots@xmax
689 \fi
690 %
691 \pgfplotscoordmath{y}{parsenumber}{0}%
692 \global\let\pgfplots@ymin=\pgfmathresult
693 \pgfplotscoordmath{y}{parsenumber}{1}%
694 \global\let\pgfplots@ymax=\pgfmathresult
695 \global\let\pgfplots@data@ymin=\pgfplots@ymin
696 \global\let\pgfplots@data@ymax=\pgfplots@ymax
697 }
698
699 \let\pgfplots@show@ticklabel@@orig=\pgfplots@show@ticklabel@
700 \def\pgfplots@show@ticklabel@@polar#1#2{%
701 \def\pgfmathresult{#2}%
702 \if#1x%
703 \ifdim#2pt>360pt
704 \pgfmath@basic@mod@{#2}{360}%
705 \fi
706 \fi
707 \def\pgfplots@loc@TMPa{\pgfplots@show@ticklabel@@orig{#1}}%
708 \expandafter\pgfplots@loc@TMPa\expandafter{\pgfmathresult}%
709 }%
710
711 \let\pgfplots@xtick@check@tickshow@orig=\pgfplots@xtick@check@tickshow%
712 \def\pgfplots@xtick@check@tickshow@polar{%
713 \if1\pgfplots@xtick@disable@last@tick
714 \pgfplotsmath@ifapproxequal@dim
715 {\pgfplots@tmpa}{\pgfplots@xmax pt}
716 {\pgfplots@loc@tick@placement@tolerance}
717 {%
718 \pgfplots@tickshowfalse
719 }{%
720 \pgfplots@xtick@check@tickshow@orig
721 }%
722 \else
723 \pgfplots@xtick@check@tickshow@orig
724 \fi
725 }
726
727 \let\pgfplots@enlarge@limit@for@orig=\pgfplots@enlarge@limit@for
728 \def\pgfplots@enlarge@limit@for@polar#1{%
729 \if#1x%
730 % ignore 'enlarge x limits' (degrees).
731 \else
732 % allow 'enlarge y limits', but only for UPPER radius
733 \def\bool@pgfplots@loc@enlargelimits@min{0}%
734 \pgfplots@enlarge@limit@for@orig{#1}%
735 \fi
736 }%
737
738 \let\pgfplots@assign@default@tick@foraxis@normalizetickdist@orig=\pgfplots@assign@default@tick@foraxis@normalizetickdist
739 \def\pgfplots@assign@default@tick@foraxis@normalizetickdist@polar#1#2{%
740 \if#1x%
741 % special handling for the angles:
742 \begingroup
743 \pgfmathfloattofixed{#2}%
744 \let\H=\pgf@xb
745 \H=\pgfmathresult pt
746 % only allow step sizes of
747 % 90, 45, 30, 15, 10, 5.
748 %
749 % Prefer the LARGER step size during the snap-to-nearest.
750 % The following decision boundaries are heuristics and have no
751 % mathematical foundation.
752 \ifdim\H>67pt
753 \H=90pt
754 \else
755 \ifdim\H>30pt
756 \H=45pt
757 \else
758 \ifdim\H>18pt
759 \H=30pt
760 \else
761 \ifdim\H>10pt
762 \H=15pt
763 \else
764 \ifdim\H>6pt
765 \H=10pt
766 \else
767 \H=5pt
768 \fi
769 \fi
770 \fi
771 \fi
772 \fi
773 \edef\pgfplots@loc@TMPa{\pgf@sys@tonumber\H}%
774 \pgfmathfloatparsenumber{\pgfplots@loc@TMPa}%
775 \pgfmath@smuggleone\pgfmathresult
776 \endgroup
777 \else
778 \pgfplots@assign@default@tick@foraxis@normalizetickdist@orig{#1}{#2}%
779 \fi
780 }%
781
782 \let\pgfplots@limits@ready@orig=\pgfplots@limits@ready
783 \def\pgfplots@limits@ready@polar{%
784 \pgfplots@limits@ready@orig
785 %
786 % Avoid tick labels at upper *and* lower angle range if both are the
787 % same:
788 \pgfmath@basic@subtract@{\pgfplots@xmax}{\pgfplots@xmin}%
789 \pgfmath@basic@mod@{\pgfmathresult}{360}%
790 \pgfplotsmath@ifapproxequal@dim
791 {\pgfmathresult pt}{0pt}%
792 {0.002pt}
793 {%
794 \def\pgfplots@xtick@disable@last@tick{1}%
795 }{%
796 }%
797 %
798 }%
799 \endinput