diff options
Diffstat (limited to 'Master/texmf-dist/tex/generic/pgfplots/pgfplotsticks.code.tex')
-rw-r--r-- | Master/texmf-dist/tex/generic/pgfplots/pgfplotsticks.code.tex | 568 |
1 files changed, 345 insertions, 223 deletions
diff --git a/Master/texmf-dist/tex/generic/pgfplots/pgfplotsticks.code.tex b/Master/texmf-dist/tex/generic/pgfplots/pgfplotsticks.code.tex index 46367c7c43e..de218f8bcb9 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/pgfplotsticks.code.tex +++ b/Master/texmf-dist/tex/generic/pgfplots/pgfplotsticks.code.tex @@ -149,7 +149,7 @@ \def\pgfplots@init@scaled@tick@for#1{% \global\def\pgfplots@glob@TMPa{0}% \begingroup - \ifcase\csname pgfplots@scaled@ticks@#1@choice\endcsname + \ifcase\csname pgfplots@scaled@ticks@#1@choice\endcsname\relax % CASE 0 : scaled #1 ticks=false: do nothing here. \or % CASE 1 : scaled #1 ticks=true: @@ -213,9 +213,9 @@ % x-axis tick labels for #1th tick % #1: the axis (x,y or z) % #2: the value -% #3,#4: coordinates for \pgfplotspointonorientedsurfaceab +% #3,#4+#5: arguments for \pgfplotspointonorientedsurfaceabwithbshift % #5: ticknumber -\def\pgfplots@show@ticklabel#1#2(#3,#4)#5{% +\def\pgfplots@show@ticklabel#1#2(#3,#4+#5)#6{% \begingroup% \csname ifpgfplots@#1ticklabel@interval\endcsname % Special case for the INTERVAL feature: @@ -240,18 +240,19 @@ \let\pgfplots@show@ticklabel@coord@y=\pgfmathresult% \let\ticknum=\pgfplots@show@ticklabel@num\relax% \let\tick=\pgfplots@show@ticklabel@tick% - \pgfplots@show@ticklabel@@{#1}{\pgfplotspointonorientedsurfaceab{\pgfplots@show@ticklabel@coord@x}{\pgfplots@show@ticklabel@coord@y}}% + \pgfplots@show@ticklabel@@{#1} + {\pgfplotspointonorientedsurfaceabwithbshift{\pgfplots@show@ticklabel@coord@x}{\pgfplots@show@ticklabel@coord@y}{#5}}% \fi \xdef\pgfplots@show@ticklabel@LASTTICK{% \noexpand\def\noexpand\pgfplots@show@ticklabel@tick{\nexttick}% \noexpand\def\noexpand\pgfplots@show@ticklabel@coord@x{\pgfplots@show@ticklabel@coord@x@new}% \noexpand\def\noexpand\pgfplots@show@ticklabel@coord@y{\pgfplots@show@ticklabel@coord@y@new}% - \noexpand\edef\noexpand\pgfplots@show@ticklabel@num{#5}% + \noexpand\edef\noexpand\pgfplots@show@ticklabel@num{#6}% }% \else - \let\ticknum=#5\relax% + \let\ticknum=#6\relax% \pgfplots@show@ticklabel@{#1}{#2}% - \pgfplots@show@ticklabel@@{#1}{\pgfplotspointonorientedsurfaceab{#3}{#4}}% + \pgfplots@show@ticklabel@@{#1}{\pgfplotspointonorientedsurfaceabwithbshift{#3}{#4}{#5}}% \fi \endgroup } @@ -469,7 +470,7 @@ % #2: tick value. \def\pgfplots@show@ticklabel@#1#2{% \csname ifpgfplots@apply@datatrafo@#1\endcsname - \csname pgfplots@inverse@datascaletrafo@#1\endcsname{#2}% + \pgfplotscoordmath{#1}{datascaletrafo inverse}{#2}% \ifcase\csname pgfplots@scaled@ticks@#1@choice\endcsname \or \expandafter\pgfmathfloatshift@\expandafter{\pgfmathresult}{\csname pgfplots@tick@scale@#1\endcsname}% @@ -480,7 +481,12 @@ \or % scaled #1 ticks=manual. Invoke manual tick scaling code: \expandafter\let\expandafter\pgfplots@loc@TMPa\csname pgfplots@tick@scale@#1\endcsname + \begingroup + \pgfkeys{/pgf/fpu=true}% \expandafter\pgfplots@loc@TMPa\expandafter{\pgfmathresult}% + \pgfmath@smuggleone\pgfmathresult + \endgroup + \pgfmathfloatparsenumber\pgfmathresult% \fi % .. and this here provides \tick as fixed point repr: \expandafter\pgfmathfloattofixed\expandafter{\pgfmathresult}% @@ -590,10 +596,10 @@ }% % Fills the macros -% \pgfplots@tick@beg@a \pgfplots@tick@end@a -% \pgfplots@tick@beg@b \pgfplots@tick@end@b +% \pgfplots@tick@LOWER@b \pgfplots@tick@end@a +% \pgfplots@tick@UPPER@b \pgfplots@tick@end@b % with coordinates such that -% (\pgfplots@tick@beg@a,\pgfplots@tmpa) -- (\pgfplots@tick@end@a,\pgfplots@tmpa) +% (\pgfplots@tick@LOWER@b,\pgfplots@tmpa) -- (\pgfplots@tick@end@a,\pgfplots@tmpa) % produces a correct tick line. % % The '@b' variant is only used in case of \pgfplots@ytickposnum = 0 @@ -602,56 +608,65 @@ % #2 : the current tick width % \def\pgfplots@prepare@tick@offsets@for@#1#2{% + % % FIXME : this stuff was ok for 2D. % For 3D, it works only for the cases of boxed axes or centered % axis lines. \ifcase\csname pgfplots@#1tickposnum\endcsname\relax % both %(\pgfplots@xcoordminTEX-\pgfplots@tick@offset, \pgfplots@tmpa) -- ++( #2, 0pt) - \edef\pgfplots@tick@beg@a{\csname pgfplots@\pgfplotspointonorientedsurfaceB min\endcsname}% - \pgfmathsubtract@{\pgfplots@tick@beg@a}{\pgfplots@tick@offset}% - \let\pgfplots@tick@beg@a=\pgfmathresult - \pgfmathadd@{\pgfplots@tick@beg@a}{#2}% - \let\pgfplots@tick@end@a=\pgfmathresult + \edef\pgfplots@tick@LOWER@b{\csname pgfplots@\pgfplotspointonorientedsurfaceB min\endcsname}% % %(\pgfplots@xcoordmaxTEX+\pgfplots@tick@offset, \pgfplots@tmpa) -- ++(-#2, 0pt) - \edef\pgfplots@tick@beg@b{\csname pgfplots@\pgfplotspointonorientedsurfaceB max\endcsname}% - \pgfmathadd@{\pgfplots@tick@beg@b}{\pgfplots@tick@offset}% - \let\pgfplots@tick@beg@b=\pgfmathresult - \pgfmathsubtract@{\pgfplots@tick@beg@b}{#2}% - \let\pgfplots@tick@end@b=\pgfmathresult% + \edef\pgfplots@tick@UPPER@b{\csname pgfplots@\pgfplotspointonorientedsurfaceB max\endcsname}% \or % left % (\pgfplots@xcoordminTEX-\pgfplots@tick@offset, \pgfplots@tmpa) -- ++( #2, 0pt); - \edef\pgfplots@tick@beg@a{\csname pgfplots@\pgfplotspointonorientedsurfaceB min\endcsname}% - \pgfmathsubtract@{\pgfplots@tick@beg@a}{\pgfplots@tick@offset}% - \let\pgfplots@tick@beg@a=\pgfmathresult - \pgfmathadd@{\pgfplots@tick@beg@a}{#2}% - \let\pgfplots@tick@end@a=\pgfmathresult + \edef\pgfplots@tick@LOWER@b{\csname pgfplots@\pgfplotspointonorientedsurfaceB min\endcsname}% \or % center % (\pgfplots@ZERO@x -\pgfplots@tick@offset, \pgfplots@tmpa) -- ++( #2, 0pt); - \pgfmathsubtract@{\csname pgfplots@logical@ZERO@\pgfplotspointonorientedsurfaceB \endcsname}{\pgfplots@tick@offset}% - \let\pgfplots@tick@beg@a=\pgfmathresult - \pgfmathadd@{\pgfplots@tick@beg@a}{#2}% - \let\pgfplots@tick@end@a=\pgfmathresult% + \edef\pgfplots@tick@LOWER@b{\csname pgfplots@logical@ZERO@\pgfplotspointonorientedsurfaceB \endcsname}% \or % right % (\pgfplots@xcoordmaxTEX+\pgfplots@tick@offset, \pgfplots@tmpa) -- ++(-#2, 0pt); - \edef\pgfplots@tick@beg@b{\csname pgfplots@\pgfplotspointonorientedsurfaceB max\endcsname}% - \pgfmathadd@{\pgfplots@tick@beg@b}{\pgfplots@tick@offset}% - \let\pgfplots@tick@beg@b=\pgfmathresult - \pgfmathsubtract@{\pgfplots@tick@beg@b}{#2}% - \let\pgfplots@tick@end@b=\pgfmathresult% + \edef\pgfplots@tick@UPPER@b{\csname pgfplots@\pgfplotspointonorientedsurfaceB max\endcsname}% \else % FALL BACK. never used, I guess? % (\pgfplots@xcoordminTEX-\pgfplots@tick@offset, \pgfplots@tmpa) -- ++( #2, 0pt); - \edef\pgfplots@tick@beg@a{\csname pgfplots@\pgfplotspointonorientedsurfaceB min\endcsname}% - \pgfmathsubtract@{\pgfplots@tick@beg@a}{\pgfplots@tick@offset}% - \let\pgfplots@tick@beg@a=\pgfmathresult - \pgfmathadd@{\pgfplots@tick@beg@a}{#2}% - \let\pgfplots@tick@end@a=\pgfmathresult + \edef\pgfplots@tick@LOWER@b{\csname pgfplots@\pgfplotspointonorientedsurfaceB min\endcsname}% \fi + % + \ifcase\csname pgfplots@#1tickalignnum\endcsname\relax + \def\pgfplots@tick@offset{0}% + \or + \edef\pgfplots@tick@offset{#2}% + \or + \pgfmathmultiply@{0.5}{#2}% + \let\pgfplots@tick@offset=\pgfmathresult% + \fi + % + \edef\pgfplots@tick@LOWER@shiftbeg{-\pgfplots@tick@offset}% + \pgfmathadd@{\pgfplots@tick@LOWER@shiftbeg}{#2}% + \let\pgfplots@tick@LOWER@shiftend=\pgfmathresult + % + \edef\pgfplots@tick@UPPER@shiftbeg{\pgfplots@tick@offset}% + \pgfmathsubtract@{\pgfplots@tick@UPPER@shiftbeg}{#2}% + \let\pgfplots@tick@UPPER@shiftend=\pgfmathresult + % + % Assemble the \pgfplots@drawticklines@for@placecomputedtick + % command. + \def\pgfplots@drawticklines@for@placecomputedtick{% + \if\pgfplots@drawticklines@for@placecomputedtick@LOWEROK1% + \pgfpathmoveto{\pgfplotspointonorientedsurfaceabwithbshift{\pgfplots@curtickpos}{\pgfplots@tick@LOWER@b}{\pgfplots@tick@LOWER@shiftbeg pt}}% + \pgfpathlineto{\pgfplotspointonorientedsurfaceabwithbshift{\pgfplots@curtickpos}{\pgfplots@tick@LOWER@b}{\pgfplots@tick@LOWER@shiftend pt}}% + \fi + \if\pgfplots@drawticklines@for@placecomputedtick@UPPEROK1% + \pgfpathmoveto{\pgfplotspointonorientedsurfaceabwithbshift{\pgfplots@curtickpos}{\pgfplots@tick@UPPER@b}{\pgfplots@tick@UPPER@shiftbeg pt}}% + \pgfpathlineto{\pgfplotspointonorientedsurfaceabwithbshift{\pgfplots@curtickpos}{\pgfplots@tick@UPPER@b}{\pgfplots@tick@UPPER@shiftend pt}}% + \fi + }% +%\message{place computed tick: LOWEROK=\pgfplots@drawticklines@for@placecomputedtick@LOWEROK; UPPEROK=\pgfplots@drawticklines@for@placecomputedtick@UPPEROK.}% }% @@ -771,11 +786,17 @@ \def\pgfplots@scaled@ticks@z@choice{0}% \csname pgfplots@#1minorticksfalse\endcsname \csname pgfplots@#1minorgridsfalse\endcsname + \expandafter\let\expandafter\pgfplots@ticklabel@pos@orig\csname pgfplots@#1ticklabel@pos\endcsname% \expandafter\let\expandafter\axis@TMP\csname pgfplots@extra@#1ticklabel\endcsname \expandafter\let\csname pgfplots@#1ticklabel\endcsname=\axis@TMP % \pgfplotsset{/pgfplots/every extra #1 tick}% % use a scope here such that line width and draw color can be set. \scope[/pgfplots/.cd,/pgfplots/every extra #1 tick] + \expandafter\let\expandafter\pgfplots@ticklabel@pos@\csname pgfplots@#1ticklabel@pos\endcsname + \ifx\pgfplots@ticklabel@pos@\pgfplots@ticklabel@pos@orig + \else + \pgfplots@init@ticklabelaxisspec + \fi \pgfplots@prepare@tick@coordlists@for{#1}{#2}% \pgfplots@drawgridlines@onorientedsurf% \pgfplots@drawticklines@onorientedsurf% @@ -789,8 +810,8 @@ % and % \pgfplots@prepared@tick@positions@minor@x. % -% The major tick list contains tuples (canvas position,logical position) -% while the minor tick list contains just the canvas position. +% Both lists contain entries of the form {<index>}{<logical position>} +% @see \pgfplots@prepared@tick@pos@unpack % % #1: the axis % #2: the tick list. @@ -814,16 +835,10 @@ % of \foreach statements. And, yes: I have also added a TeX group % on my own (but that's not the problem). \global\pgfplotslistnewempty\pgfplots@prepared@tick@positions@major - \global\pgfplotslistnewempty\pgfplots@prepared@tick@positions@major@tickindices + %\global\pgfplotslistnewempty\pgfplots@prepared@tick@positions@major@tickindices \global\pgfplotslistnewempty\pgfplots@prepared@tick@positions@minor % - \afterassignment\pgfplots@gobble@until@relax - \pgfplots@tmpa=\pgfkeysvalueof{/pgfplots/#1tick placement tolerance}pt\relax - \pgfplots@tmpa=\csname pgfplots@#1@inverseveclength\endcsname\pgfplots@tmpa - \edef\pgfplots@loc@tick@placement@tolerance{\the\pgfplots@tmpa}% - % - \advance\csname pgfplots@#1min@reg\endcsname by-\pgfplots@tmpa - \advance\csname pgfplots@#1max@reg\endcsname by\pgfplots@tmpa + \pgfplots@prepare@tick@coordlists@for@handletolerance#1% % \edef\pgfplots@loc@TMPa{#2}% \ifx\pgfplots@loc@TMPa\pgfutil@empty @@ -837,9 +852,15 @@ \pgfplots@needsminorloopfalse \fi \fi + \pgfkeysgetvalue{/pgfplots/minor #1tick}\pgfplots@minor@tick@list + \ifx\pgfplots@minor@tick@list\pgfutil@empty + \else + \pgfplots@needsminorloopfalse + \fi + % \ifpgfplots@needsminorloop \ifpgfplots@islinear - \expandafter\let\expandafter\pgfplots@minor@tick@num\csname pgfplots@minor@#1tick@num\endcsname + \pgfkeysgetvalue{/pgfplots/minor #1 tick num}\pgfplots@minor@tick@num \begingroup \c@pgf@counta=\pgfplots@minor@tick@num\relax \advance\c@pgf@counta by1\relax @@ -860,18 +881,14 @@ \else \expandafter\def\expandafter\pgfplots@checktickminmax\expandafter{% \pgfplots@checktickminmax - \ifdim\pgfplots@tmpa<\csname pgfplots@#1tickmin\endcsname pt - \pgfplots@tickshowfalse - \fi + \pgfplots@prepare@tick@coordlists@for@checktickmin#1% }% \fi \expandafter\ifx\csname pgfplots@#1tickmax\endcsname\pgfutil@empty \else \expandafter\def\expandafter\pgfplots@checktickminmax\expandafter{% \pgfplots@checktickminmax - \ifdim\pgfplots@tmpa>\csname pgfplots@#1tickmax\endcsname pt - \pgfplots@tickshowfalse - \fi + \pgfplots@prepare@tick@coordlists@for@checktickmax#1% }% \fi % @@ -880,47 +897,39 @@ \foreach \x in {#2} {% \let\pgfplots@ticknum=\pgfplots@glob@TMPa % - \pgfplots@tmpa=\x pt % + \pgfplots@prepare@tick@coordlists@for@assign\pgfplots@tmpa=\x \csname pgfplots@#1tick@check@tickshow\endcsname + \pgfplots@prepare@tick@coordlists@for@checkdatalimits#1% \pgfplots@checktickminmax % \ifpgfplots@tickshow - \ifdim\pgfplots@tmpa<\csname pgfplots@#1min@reg\endcsname - \else - \ifdim\pgfplots@tmpa>\csname pgfplots@#1max@reg\endcsname - \else - \expandafter\pgfplotslistpushbackglobal\x\to\pgfplots@prepared@tick@positions@major - \expandafter\pgfplotslistpushbackglobal\pgfplots@ticknum\to\pgfplots@prepared@tick@positions@major@tickindices - \fi - \fi + \edef\x{{\pgfplots@ticknum}{\x}}% + \expandafter\pgfplotslistpushbackglobal\x\to\pgfplots@prepared@tick@positions@major + %\expandafter\pgfplotslistpushbackglobal\pgfplots@ticknum\to\pgfplots@prepared@tick@positions@major@tickindices \fi % X-Axis ticks bottom and top - % in log: - % log( i*10^k ) = log\pgfplots@i + k\log10 -> draw ticks for i=1..9 \ifpgfplots@needsminorloop + % SEE BELOW for the 'minor #1tick' feature -- it has a + % separate loop. \foreach \pgfplots@i in {1,...,\pgfplots@minor@tick@num} {% - \begingroup \ifpgfplots@islinear - \pgfplots@tmpa=\pgfplots@minor@tick@dist pt % - \pgfplots@tmpa=\pgfplots@i\pgfplots@tmpa + \pgfmathmultiply@{\pgfplots@i}{\pgfplots@minor@tick@dist}% \else - \pgfplots@tmpa=\csname pgfplotsmathlogi@#1\endcsname\pgfplots@i pt % + % in log: + % log( i*10^k ) = log\pgfplots@i + k\log10 -> draw ticks for i=1..9 + \pgfplotscoordmath{#1}{log unsigned int}{\pgfplots@i}% + \pgfplotscoordmath{#1}{tofixed}{\pgfmathresult}% \fi - \edef\pgfmathresult{\the\pgfplots@tmpa}% - \pgfmath@smuggleone\pgfmathresult - \endgroup - \advance\pgfplots@tmpa by\pgfmathresult\relax + \pgfplots@prepare@tick@coordlists@for@advance\pgfplots@tmpa by\pgfmathresult \pgfplots@tickshowtrue + \pgfplots@prepare@tick@coordlists@for@checkdatalimits#1% \pgfplots@checktickminmax \ifpgfplots@tickshow - \ifdim\pgfplots@tmpa<\csname pgfplots@#1min@reg\endcsname - \else - \ifdim\pgfplots@tmpa>\csname pgfplots@#1max@reg\endcsname - \else - \edef\pgfmathresult{\pgf@sys@tonumber{\pgfplots@tmpa}}% - \expandafter\pgfplotslistpushbackglobal\pgfmathresult\to\pgfplots@prepared@tick@positions@minor - \fi - \fi + \pgfplots@prepare@tick@coordlists@for@tofixed\pgfplots@tmpa + \c@pgf@counta=\pgfplots@ticknum\relax + \advance\c@pgf@counta by\pgfplots@i\relax + \edef\x{{\the\c@pgf@counta}{\pgfmathresult}}% + \expandafter\pgfplotslistpushbackglobal\x\to\pgfplots@prepared@tick@positions@minor \fi }% \fi @@ -928,16 +937,99 @@ % carry \ticknum outside of this scope: \global\let\pgfplots@glob@TMPa=\pgfplots@ticknum }% + % + \ifx\pgfplots@minor@tick@list\pgfutil@empty + \else + % handle the 'minor #1tick' feature: + \def\pgfplots@loc@TMPa{\foreach \x in }% + \expandafter\pgfplots@loc@TMPa\expandafter{\pgfplots@minor@tick@list} {% + \let\pgfplots@ticknum=\pgfplots@glob@TMPa + % + \pgfplots@prepare@tick@coordlists@for@assign\pgfplots@tmpa=\x + \pgfplots@tickshowtrue + \pgfplots@prepare@tick@coordlists@for@checkdatalimits#1% + \pgfplots@checktickminmax + \ifpgfplots@tickshow + \edef\x{{\pgfplots@ticknum}{\x}}% + \expandafter\pgfplotslistpushbackglobal\x\to\pgfplots@prepared@tick@positions@minor + \fi + \pgfplotsutil@advancestringcounter\pgfplots@ticknum + % carry \ticknum outside of this scope: + \global\let\pgfplots@glob@TMPa=\pgfplots@ticknum + }% + \fi \fi \endgroup \expandafter\let\csname pgfplots@prepared@tick@positions@minor@#1\endcsname=\pgfplots@prepared@tick@positions@minor \expandafter\let\csname pgfplots@prepared@tick@positions@major@#1\endcsname=\pgfplots@prepared@tick@positions@major - \expandafter\let\csname pgfplots@prepared@tick@positions@major@tickindices@#1\endcsname=\pgfplots@prepared@tick@positions@major@tickindices + %\expandafter\let\csname pgfplots@prepared@tick@positions@major@tickindices@#1\endcsname=\pgfplots@prepared@tick@positions@major@tickindices \global\let\pgfplots@prepared@tick@positions@major=\relax - \global\let\pgfplots@prepared@tick@positions@major@tickindices=\relax + %\global\let\pgfplots@prepared@tick@positions@major@tickindices=\relax \global\let\pgfplots@prepared@tick@positions@minor=\relax }% +% The following set of macros can be used to replace the TeX register +% arithmetics used to speed up the computations inside of +% \pgfplots@prepare@tick@coordlists@for by something different. +% +% FIXME : that is no clean programming! Perhaps a new math class +% should be used here, and implemented during the complete tick +% preparation!? +% +% Keep in mind that these tick positions are in "transformed +% range", i.e. they are expected to be in the range -16000...16000. At +% the time of this modification, only the smithchart lib needs special +% handling here... does this justify a re-design? +\def\pgfplots@prepare@tick@coordlists@for@assign#1=#2{% + #1=#2pt +}% +\def\pgfplots@prepare@tick@coordlists@for@advance#1by#2{% + \advance#1 by#2 pt % +}% +\def\pgfplots@prepare@tick@coordlists@for@tofixed#1{% + \edef\pgfmathresult{\pgf@sys@tonumber{#1}}% +}% +\def\pgfplots@prepare@tick@coordlists@for@handletolerance#1{% + \afterassignment\pgfplots@gobble@until@relax + \pgfplots@tmpa=\pgfkeysvalueof{/pgfplots/#1tick placement tolerance}pt\relax + \pgfplots@tmpa=\csname pgfplots@#1@inverseveclength\endcsname\pgfplots@tmpa + \edef\pgfplots@loc@tick@placement@tolerance{\the\pgfplots@tmpa}% + % + \advance\csname pgfplots@#1min@reg\endcsname by-\pgfplots@tmpa + \advance\csname pgfplots@#1max@reg\endcsname by\pgfplots@tmpa +}% +\def\pgfplots@prepare@tick@coordlists@for@checktickmin#1{% + \ifdim\pgfplots@tmpa<\csname pgfplots@#1tickmin\endcsname pt + \pgfplots@tickshowfalse + \fi +}% +\def\pgfplots@prepare@tick@coordlists@for@checktickmax#1{% + \ifdim\pgfplots@tmpa>\csname pgfplots@#1tickmax\endcsname pt + \pgfplots@tickshowfalse + \fi +}% +\def\pgfplots@prepare@tick@coordlists@for@checkdatalimits#1{% + \ifdim\pgfplots@tmpa<\csname pgfplots@#1min@reg\endcsname + \pgfplots@tickshowfalse + \else + \ifdim\pgfplots@tmpa>\csname pgfplots@#1max@reg\endcsname + \pgfplots@tickshowfalse + \fi + \fi +}% + +% Unpacks entries of the \pgfplots@prepared@tick@positions@* lists. +% +% Defines \pgfplots@tick to be the actual tick position and +% \pgfplots@ticknum to be its index. +% +% Usage: +% \expandafter\pgfplots@prepared@tick@pos@unpack\entry +\def\pgfplots@prepared@tick@pos@unpack#1#2{% + \def\pgfplots@tick{#2}% + \def\pgfplots@ticknum{#1}% +} + % Draws grid lines at the a-positions of the currently set oriented % surface. % @@ -965,7 +1057,7 @@ \pgfplots@if{pgfplots@#1minorgrids}{\pgfplots@loop@CONTINUEtrue}{}% \ifpgfplots@loop@CONTINUE \scope - \pgfplots@drawtickgridlines@INSTALLCLIP@onorientedsurf#1 + \pgfplots@drawgridlines@INSTALLCLIP@onorientedsurf#1% % \pgfplots@if{pgfplots@#1minorgrids}{% \draw[% @@ -975,8 +1067,8 @@ /pgfplots/every minor #1 grid]% \pgfextra \pgfplotslistforeach\pgfplots@prepared@tick@positions@minor@\as\pgfplots@curgridpos{% - \pgfpathmoveto{\pgfplotspointonorientedsurfaceab{\pgfplots@curgridpos}{\csname pgfplots@\pgfplotspointonorientedsurfaceB min\endcsname}}% - \pgfpathlineto{\pgfplotspointonorientedsurfaceab{\pgfplots@curgridpos}{\csname pgfplots@\pgfplotspointonorientedsurfaceB max\endcsname}}% + \expandafter\pgfplots@prepared@tick@pos@unpack\pgfplots@curgridpos + \pgfplots@drawgridlines@onorientedsurf@fromto\pgfplots@tick }% \endpgfextra; }{}% @@ -989,8 +1081,8 @@ /pgfplots/every major #1 grid]% \pgfextra \pgfplotslistforeach\pgfplots@prepared@tick@positions@major@\as\pgfplots@curgridpos{% - \pgfpathmoveto{\pgfplotspointonorientedsurfaceab{\pgfplots@curgridpos}{\csname pgfplots@\pgfplotspointonorientedsurfaceB min\endcsname}}% - \pgfpathlineto{\pgfplotspointonorientedsurfaceab{\pgfplots@curgridpos}{\csname pgfplots@\pgfplotspointonorientedsurfaceB max\endcsname}}% + \expandafter\pgfplots@prepared@tick@pos@unpack\pgfplots@curgridpos + \pgfplots@drawgridlines@onorientedsurf@fromto\pgfplots@tick }% \endpgfextra; }{}% @@ -1002,6 +1094,16 @@ }% } +% Should draw a single grid line on the actual oriented surface. +% #1 the value of the grid line. +% +% PRECONDITION +% \pgfplots@ticknum contains the index of the current tick. +\def\pgfplots@drawgridlines@onorientedsurf@fromto#1{% + \pgfpathmoveto{\pgfplotspointonorientedsurfaceab{#1}{\csname pgfplots@\pgfplotspointonorientedsurfaceB min\endcsname}}% + \pgfpathlineto{\pgfplotspointonorientedsurfaceab{#1}{\csname pgfplots@\pgfplotspointonorientedsurfaceB max\endcsname}}% +}% + % Draws ticks on the currently active "oriented surface". % % The oriented surface is two dimensional and has been initialised @@ -1040,26 +1142,27 @@ \expandafter\pgfplots@drawticklines@onorientedsurf@\pgfplotspointonorientedsurfaceA }% +\def\pgfplots@drawticklines@INSTALLCLIP@onorientedsurf#1{% + \pgfplots@drawtickgridlines@INSTALLCLIP@onorientedsurf{#1}% +}% +\def\pgfplots@drawgridlines@INSTALLCLIP@onorientedsurf#1{% + \pgfplots@drawtickgridlines@INSTALLCLIP@onorientedsurf{#1}% +}% % Avoids tick lines which are too thick by introducing a clipping % region. Tick lines (and grid lines) won't extend to the left or % right of axis #1. \def\pgfplots@drawtickgridlines@INSTALLCLIP@onorientedsurf#1{% \pgfinterruptboundingbox% \begingroup - \pgf@xa=5cm - \edef\pgfplots@loc@TMPc{\pgf@sys@tonumber{\pgf@xa}}% % the case ||e_b|| == 0 should never happen here! Should be % caught before entering this routine. - \pgfmathmultiply@{\pgfplots@loc@TMPc}{\csname pgfplots@\pgfplotspointonorientedsurfaceB @inverseveclength\endcsname}% \let\pgfplots@loc@LENGTH=\pgfmathresult - \pgfmathsubtract@{\csname pgfplots@\pgfplotspointonorientedsurfaceB min\endcsname}{\pgfplots@loc@LENGTH}% - \let\pgfplots@loc@MIN=\pgfmathresult - \pgfmathadd@{\csname pgfplots@\pgfplotspointonorientedsurfaceB max\endcsname}{\pgfplots@loc@LENGTH}% - \let\pgfplots@loc@MAX=\pgfmathresult - \pgfpathmoveto{\pgfplotspointonorientedsurfaceab{\csname pgfplots@#1min\endcsname}{\pgfplots@loc@MIN}}% - \pgfpathlineto{\pgfplotspointonorientedsurfaceab{\csname pgfplots@#1max\endcsname}{\pgfplots@loc@MIN}}% - \pgfpathlineto{\pgfplotspointonorientedsurfaceab{\csname pgfplots@#1max\endcsname}{\pgfplots@loc@MAX}}% - \pgfpathlineto{\pgfplotspointonorientedsurfaceab{\csname pgfplots@#1min\endcsname}{\pgfplots@loc@MAX}}% + \expandafter\let\expandafter\pgfplots@loc@MIN\csname pgfplots@\pgfplotspointonorientedsurfaceB min\endcsname + \expandafter\let\expandafter\pgfplots@loc@MAX\csname pgfplots@\pgfplotspointonorientedsurfaceB max\endcsname + \pgfpathmoveto{\pgfplotspointonorientedsurfaceabwithbshift{\csname pgfplots@#1min\endcsname}{\pgfplots@loc@MIN}{-5cm}}% + \pgfpathlineto{\pgfplotspointonorientedsurfaceabwithbshift{\csname pgfplots@#1max\endcsname}{\pgfplots@loc@MIN}{-5cm}}% + \pgfpathlineto{\pgfplotspointonorientedsurfaceabwithbshift{\csname pgfplots@#1max\endcsname}{\pgfplots@loc@MAX}{5cm}}% + \pgfpathlineto{\pgfplotspointonorientedsurfaceabwithbshift{\csname pgfplots@#1min\endcsname}{\pgfplots@loc@MAX}{5cm}}% \pgfusepath{clip}% \endgroup \endpgfinterruptboundingbox% @@ -1112,24 +1215,9 @@ % never used? \def\pgfplots@drawticklines@for@placecomputedtick@UPPEROK{0}% \fi - \begingroup - % Assemble the \pgfplots@drawticklines@for@placecomputedtick - % command. - \let\E=\noexpand - \xdef\pgfplots@drawticklines@for@placecomputedtick{% - \if\pgfplots@drawticklines@for@placecomputedtick@LOWEROK1% - \E\pgfpathmoveto{\E\pgfplotspointonorientedsurfaceab{\E\pgfplots@curtickpos}{\E\pgfplots@tick@beg@a}}% - \E\pgfpathlineto{\E\pgfplotspointonorientedsurfaceab{\E\pgfplots@curtickpos}{\E\pgfplots@tick@end@a}}% - \fi - \if\pgfplots@drawticklines@for@placecomputedtick@UPPEROK1% - \E\pgfpathmoveto{\E\pgfplotspointonorientedsurfaceab{\E\pgfplots@curtickpos}{\E\pgfplots@tick@beg@b}}% - \E\pgfpathlineto{\E\pgfplotspointonorientedsurfaceab{\E\pgfplots@curtickpos}{\E\pgfplots@tick@end@b}}% - \fi - }% - \endgroup \expandafter\let\expandafter\pgfplots@prepared@tick@positions@major@\csname pgfplots@prepared@tick@positions@major@#1\endcsname \expandafter\let\expandafter\pgfplots@prepared@tick@positions@minor@\csname pgfplots@prepared@tick@positions@minor@#1\endcsname - \pgfplots@drawtickgridlines@INSTALLCLIP@onorientedsurf#1 + \pgfplots@drawticklines@INSTALLCLIP@onorientedsurf#1 % \pgfplots@if{pgfplots@#1minorticks}{% \draw[% @@ -1140,19 +1228,13 @@ \pgfextra \pgfmathparse{\pgfplots@subtickwidth}% \let\pgfplots@subtickwidth@=\pgfmathresult - \pgfmathmultiply@{\pgfplots@subtickwidth@}{\csname pgfplots@\pgfplotspointonorientedsurfaceB @inverseveclength\endcsname}% \let\pgfplots@subtickwidth@=\pgfmathresult \let\pgfplots@subtickwidth=\pgfmathresult - \ifcase\csname pgfplots@#1tickalignnum\endcsname\relax - \def\pgfplots@tick@offset{0}% - \or - \let\pgfplots@tick@offset=\pgfplots@subtickwidth@% - \or - \pgfmathmultiply@{0.5}{\pgfplots@subtickwidth@}% - \let\pgfplots@tick@offset=\pgfmathresult% - \fi \pgfplots@prepare@tick@offsets@for@{#1}{\pgfplots@subtickwidth@}% \pgfplotslistforeach\pgfplots@prepared@tick@positions@minor@\as\pgfplots@curtickpos{% + \expandafter\pgfplots@prepared@tick@pos@unpack\pgfplots@curtickpos + \let\pgfplots@curtickpos=\pgfplots@tick + \pgfplotspointouternormalvectorofaxissetv{}{\pgfplots@curtickpos}% \pgfplots@drawticklines@for@placecomputedtick }% \endpgfextra; @@ -1167,19 +1249,13 @@ \pgfextra \pgfmathparse{\pgfplots@tickwidth}% \let\pgfplots@tickwidth@=\pgfmathresult - \pgfmathmultiply@{\pgfplots@tickwidth@}{\csname pgfplots@\pgfplotspointonorientedsurfaceB @inverseveclength\endcsname}% \let\pgfplots@tickwidth@=\pgfmathresult \let\pgfplots@tickwidth=\pgfmathresult - \ifcase\csname pgfplots@#1tickalignnum\endcsname\relax - \def\pgfplots@tick@offset{0}% - \or - \let\pgfplots@tick@offset=\pgfplots@tickwidth@% - \or - \pgfmathmultiply@{0.5}{\pgfplots@tickwidth@}% - \let\pgfplots@tick@offset=\pgfmathresult% - \fi \pgfplots@prepare@tick@offsets@for@{#1}{\pgfplots@tickwidth@}% \pgfplotslistforeach\pgfplots@prepared@tick@positions@major@\as\pgfplots@curtickpos{% + \expandafter\pgfplots@prepared@tick@pos@unpack\pgfplots@curtickpos + \let\pgfplots@curtickpos=\pgfplots@tick + \pgfplotspointouternormalvectorofaxissetv{}{\pgfplots@curtickpos}% \pgfplots@drawticklines@for@placecomputedtick }% \endpgfextra; @@ -1263,7 +1339,7 @@ \fi \let\pgfplots@tick@offset=\pgfmathresult \pgfplots@ticklabel@maxtickdimen@extrashift{#1}{\pgfplots@tick@offset}% - \pgfmathmultiply@{\pgfplots@tick@offset}{\csname pgfplots@\pgfplotspointonorientedsurfaceB @inverseveclength\endcsname}% + %\pgfmathmultiply@{\pgfplots@tick@offset}{\csname pgfplots@\pgfplotspointonorientedsurfaceB @inverseveclength\endcsname}% \let\pgfplots@tick@offset=\pgfmathresult }% % @@ -1277,38 +1353,50 @@ \pgfmathmultiply{-1}{\pgfplots@tick@offset}% \let\pgfplots@tick@offset=\pgfmathresult \fi - \pgfmathsubtract@{\pgfplots@tick@origin}{\pgfplots@tick@offset}% + \edef\pgfplots@tick@offset{-\pgfplots@tick@offset}% + %\pgfmathsubtract@{\pgfplots@tick@origin}{\pgfplots@tick@offset}% \else \if0\pgfplots@ticklabelside \expandafter\let\expandafter\pgfplots@tick@origin\csname pgfplots@\pgfplotspointonorientedsurfaceB min\endcsname% \pgfplots@tickposchoiceb - \pgfmathsubtract@{\pgfplots@tick@origin}{\pgfplots@tick@offset}% + %\pgfmathsubtract@{\pgfplots@tick@origin}{\pgfplots@tick@offset}% + \edef\pgfplots@tick@offset{-\pgfplots@tick@offset}% \else \if1\pgfplots@ticklabelside \expandafter\let\expandafter\pgfplots@tick@origin\csname pgfplots@\pgfplotspointonorientedsurfaceB max\endcsname% \pgfplots@tickposchoicea - \pgfmathadd@{\pgfplots@tick@origin}{\pgfplots@tick@offset}% + %\pgfmathadd@{\pgfplots@tick@origin}{\pgfplots@tick@offset}% \else - % Should never happen. - \pgfplots@error{Internal logic error during tick label placement (got placement character '\pgfplots@ticklabelside'). - Please report this as a bug or verify your input arguments to #1ticklabel pos.}% - \expandafter\let\expandafter\pgfplots@tick@origin\csname pgfplots@\pgfplotspointonorientedsurfaceB min\endcsname% + \expandafter\let\expandafter\pgfplots@tick@origin\csname pgfplots@logical@ZERO@\pgfplotspointonorientedsurfaceB\endcsname% + % FIXME : is that correct!? \pgfplots@tickposchoiceb - \pgfmathsubtract@{\pgfplots@tick@origin}{\pgfplots@tick@offset}% + %\pgfmathsubtract@{\pgfplots@tick@origin}{\pgfplots@tick@offset}% + %\edef\pgfplots@tick@offset{-\pgfplots@tick@offset}% + % + \if2\pgfplots@ticklabelside + \else + % Should never happen. + \pgfplots@error{Internal logic error during tick label placement (got placement character '\pgfplots@ticklabelside'). + Please report this as a bug or verify your input arguments to #1ticklabel pos.}% + \fi \fi \fi \fi + %\let\pgfplots@tick@origin=\pgfmathresult% + \edef\pgfplots@tick@offset{\pgfplots@tick@offset pt}% % % make sure the \pgfmathlogtologten method works even for % non-standard 'log basis #1': - \expandafter\let\expandafter\pgfmathlogtologten@\csname pgfplotsmathlogtologten@#1@\endcsname + \def\pgfmathlogtologten@{\pgfplotscoordmath{#1}{log to log 10}}% % - \let\pgfplots@tick@origin=\pgfmathresult% \xdef\pgfplots@show@ticklabel@LASTTICK{}% \pgfplotslistforeachungrouped\pgfplots@prepared@tick@positions@major@\as\pgfplots@curtickpos{% - \expandafter\pgfplotslistpopfront\csname pgfplots@prepared@tick@positions@major@tickindices@#1\endcsname\to\pgfplots@ticknum + \expandafter\pgfplots@prepared@tick@pos@unpack\pgfplots@curtickpos + \let\pgfplots@curtickpos=\pgfplots@tick + %\expandafter\pgfplotslistpopfront\csname pgfplots@prepared@tick@positions@major@tickindices@#1\endcsname\to\pgfplots@ticknum + \pgfplotspointouternormalvectorofaxissetv{}{\pgfplots@curtickpos}% \pgfplots@show@ticklabel - {#1}{\pgfplots@curtickpos}(\pgfplots@curtickpos,\pgfplots@tick@origin)% + {#1}{\pgfplots@curtickpos}(\pgfplots@curtickpos,\pgfplots@tick@origin+\pgfplots@tick@offset)% {\pgfplots@ticknum}% }% \pgfplots@ticklabel@maxtickdimen@finish{#1}% @@ -1394,9 +1482,21 @@ \let\pgfplots@loc@TMPc=\pgfmathresult \ifx\pgfplots@loc@TMPc\pgfutil@empty \else - \pgftransformshift{% - \pgfplotspointouternormalvectorofticklabelaxis{#1}% - \pgfqpointscale{-\pgfplots@loc@TMPc}{}% + \pgfplotspointouternormalvectorofaxis@ifdependson@v{\pgfplotsticklabelaxisspec{#1}}{% + \tikzset{every node/.append code={% + \tikz@addtransform{% + \pgftransformshift{% + \pgfplotspointouternormalvectorofticklabelaxis{#1}% + \pgfqpointscale{-\pgfplots@loc@TMPc}{}% + }% + }% + }% + }% + }{% + \pgftransformshift{% + \pgfplotspointouternormalvectorofticklabelaxis{#1}% + \pgfqpointscale{-\pgfplots@loc@TMPc}{}% + }% }% \fi % @@ -1520,7 +1620,8 @@ \def\pgfplots@compute@tick@times@logten#1\to#2#3{% \global\let#2=\pgfutil@empty \foreach \pgfplots@loc@TMPb in {#1} {% - \pgfmathmultiply@{\pgfplots@loc@TMPb}{\csname pgfplots@log@scale@todisplaylog@#3\endcsname}% + \pgfplotscoordmath{#3}{log to display log}{\pgfplots@loc@TMPb}% + \pgfplotscoordmath{#3}{tofixed}{\pgfmathresult}% \ifx#2\pgfutil@empty \xdef#2{\pgfmathresult}% \else @@ -1611,8 +1712,6 @@ % Shortcut-names: \expandafter\let\expandafter\ifpgfplots@is@datascaled\csname ifpgfplots@apply@datatrafo@#1\endcsname % Attention here: use UNSHIFTET scalings, see remark above - \expandafter\let\expandafter\pgfplots@data@scale@trafo\csname pgfplots@datascaletrafo@#1@noshift\endcsname - \expandafter\let\expandafter\pgfplots@data@scale@inverse@trafo\csname pgfplots@inverse@datascaletrafo@#1@noshift\endcsname \expandafter\let\expandafter\ifpgfplots@cur@is@linear\csname ifpgfplots@#1islinear\endcsname % \let\desirednumticks=\c@pgf@countd @@ -1639,6 +1738,18 @@ \expandafter\let\csname pgfplots@#1tick\endcsname=\pgfplots@glob@TMPa \fi \fi + \ifpgfplots@cur@is@linear + \else + \pgfplotscoordmath{#1}{parsenumber}{1}% + \let\pgfplots@loc@TMPa=\pgfmathresult + \pgfplotscoordmath{#1}{log from display log}{\pgfplots@loc@TMPa}% + \pgfplotscoordmath{#1}{tofixed}{\pgfmathresult}% + \let\pgfplots@loc@log@from@display@log@scale=\pgfmathresult + % + \pgfplotscoordmath{#1}{log to display log}{\pgfplots@loc@TMPa}% + \pgfplotscoordmath{#1}{tofixed}{\pgfmathresult}% + \let\pgfplots@loc@log@to@display@log@scale=\pgfmathresult + \fi % \expandafter\ifx\csname pgfplots@#1tick\endcsname\pgfutil@empty % Ok, we have either log or linear axis and need default @@ -1648,12 +1759,13 @@ \let\MAX=\pgf@ya \let\MIN=\pgf@yb % compute step size 'H': - \expandafter\MAX\csname pgfplots@#1max\endcsname pt % + \MAX=\csname pgfplots@#1max\endcsname pt % \advance\MAX by0.001pt % avoid round errors %\expandafter\MIN\the\c@pgf@counta pt - \expandafter\MIN\csname pgfplots@#1min\endcsname pt % + \MIN=\csname pgfplots@#1min\endcsname pt % \H=\MAX \advance\H by-\MIN + \ifdim\H<0pt \H=-1\H \fi %\message{Axis limit #1: [\the\MIN:\the\MAX], diff = \the\H.}% \c@pgf@counta=\desirednumticks \advance\c@pgf@counta by-1 % @@ -1666,40 +1778,18 @@ % CASE LINEAR AXIS \ifpgfplots@is@datascaled % This here works if the scaling trafo is linear. - \expandafter\pgfplots@data@scale@inverse@trafo\expandafter{\Hmacro}% + \pgfplotscoordmath{#1}{datascaletrafo noshift inverse}{\Hmacro}% \let\Hmacro=\pgfmathresult \else \pgfmathfloatparsenumber{\Hmacro}% \let\Hmacro=\pgfmathresult \fi - \expandafter\pgfmathfloat@decompose\pgfmathresult\relax\pgfmathfloat@a@S\H\pgfmathfloat@a@E %\message{Got T^{-1}(H#1) = \Hmacro}% - % modify the mantisse: - \ifdim\H<2pt - \ifdim\H<1.5pt - \H=1.0pt - \else - \H=2.0pt - \fi - \else - \ifdim\H<4.9999pt - \ifdim\H<3.5pt - \H=2.0pt\relax - \else - \H=5.0pt\relax - \fi - \else - \ifdim\H<7.5pt - \H=5.0pt\relax - \else - \H=1.0pt\relax - \advance\pgfmathfloat@a@E by1 - \fi - \fi - \fi - \aftergroup\pgfplots@isuniformticktrue - \pgfmathfloatcreate{\the\pgfmathfloat@a@S}{\pgf@sys@tonumber{\H}}{\the\pgfmathfloat@a@E}% + % + \pgfplots@assign@default@tick@foraxis@normalizetickdist#1\Hmacro \let\Hmacro=\pgfmathresult + % + \aftergroup\pgfplots@isuniformticktrue % The following code is carried out in floating point % arithmetics because it requires large data ranges. % @@ -1719,9 +1809,9 @@ % Now, convert everything into the fixed point data % range: \ifpgfplots@is@datascaled - \csname pgfplots@datascaletrafo@#1\endcsname{\MIN@new}% + \pgfplotscoordmath{#1}{datascaletrafo}{\MIN@new}% \MIN=\pgfmathresult pt - \pgfplots@data@scale@trafo\Hmacro + \pgfplotscoordmath{#1}{datascaletrafo noshift}{\Hmacro}% \H=\pgfmathresult pt \else \pgfmathfloattofixed\MIN@new @@ -1742,7 +1832,7 @@ % % And prefer j=1 if that is possible (otherwise minor % ticks are not useful). - \pgfmathmultiply@{\Hmacro}{\csname pgfplots@log@scale@todisplaylog@#1@inv\endcsname}% + \pgfmath@basic@multiply@{\Hmacro}{\pgfplots@loc@log@from@display@log@scale}% \let\Hmacrobaseten=\pgfmathresult \expandafter\H\pgfmathresult pt %\message{ [ H / log(10) = \pgfmathresult ]}% @@ -1764,7 +1854,7 @@ \pgfplots@isuniformtickfalse \fi %\message{final H=\pgf@sys@tonumber{\H} * log(10)}% - \H=\csname pgfplots@log@scale@todisplaylog@#1\endcsname\H\relax + \H=\pgfplots@loc@log@to@display@log@scale\H % Now, we want to activate the Tick set % {lowest, lowest+H, ..., highest} % @@ -1777,14 +1867,14 @@ \MINH=\MIN % % and compute I and I*log(10) here: - \MIN=\csname pgfplots@log@scale@todisplaylog@#1@inv\endcsname\MIN\relax + \MIN=\pgfplots@loc@log@from@display@log@scale \MIN \edef\pgfmathresult{\pgf@sys@tonumber{\MIN}}% \pgfmathsetcount{\c@pgf@counta}{\pgfmathresult}% \ifdim\MIN<0pt % the truncation rounds TOWARDS 0 which is not what I want. \advance\c@pgf@counta by-1 \fi - \MIN=\csname pgfplots@log@scale@todisplaylog@#1\endcsname pt + \MIN=\pgfplots@loc@log@to@display@log@scale pt \multiply\MIN by\c@pgf@counta \ifpgfplots@isuniformtick \else @@ -1814,7 +1904,7 @@ \advance\MINH by-\H % \ifdim\MINH<0pt - \advance\MIN \csname pgfplots@log@scale@todisplaylog@#1\endcsname pt + \advance\MIN \pgfplots@loc@log@to@display@log@scale pt \fi \fi \fi @@ -1846,6 +1936,7 @@ \expandafter\global\expandafter\let\expandafter\pgfplots@glob@TMPb\csname pgfplots@tick@distance@#1\endcsname \endgroup }{% + % Case logarithmic axes and too few ticks. \aftergroup\pgfplots@isuniformtickfalse % ok, do something special. % @@ -1855,10 +1946,11 @@ % So: apply basically the SAME code as above for linear % axis, just everything log 10! And keep in mind that all % coordinates are actually given as natural logarithms. - \expandafter\MIN\csname pgfplots@#1min\endcsname pt + \MIN\csname pgfplots@#1min\endcsname pt \H=\MAX \advance\H by-\MIN - \H=\csname pgfplots@log@scale@todisplaylog@#1@inv\endcsname\H + \ifdim\H<0pt \H=-1\H \fi + \H=\pgfplots@loc@log@from@display@log@scale \H %\message{Axis limit #1: [\the\MIN:\the\MAX], diff/log(10) = \the\H.}% \c@pgf@counta=\desirednumticks\relax \advance\c@pgf@counta by-1 @@ -1873,31 +1965,8 @@ % SEARCH for the NEXT FEASABLE H. \edef\Hmacro{\pgf@sys@tonumber\H}% \pgfmathfloatparsenumber{\Hmacro}% - \expandafter\pgfmathfloat@decompose\pgfmathresult\relax\pgfmathfloat@a@S\H\pgfmathfloat@a@E - % Determine properly snapped mantisse... - \ifdim\H<2pt - \ifdim\H<1.5pt - \H=1.0pt - \else - \H=2.0pt - \fi - \else - \ifdim\H<4.9999pt - \ifdim\H<3.5pt - \H=2.0pt\relax - \else - \H=5.0pt\relax - \fi - \else - \ifdim\H<7.5pt - \H=5.0pt\relax - \else - \H=1.0pt\relax - \advance\pgfmathfloat@a@E by1 - \fi - \fi - \fi - \pgfmathfloatcreate{\the\pgfmathfloat@a@S}{\pgf@sys@tonumber{\H}}{\the\pgfmathfloat@a@E}% + \pgfplots@assign@default@tick@foraxis@normalizetickdist#1\pgfmathresult + % \expandafter\pgfmathfloattofixed\expandafter{\pgfmathresult}% \let\Hmacro=\pgfmathresult \H=\Hmacro pt % @@ -1909,7 +1978,7 @@ % -> I = round(xmin/H) % -> MIN = I * H % BUT EVERYTHING to log(10) basis! - \MIN=\csname pgfplots@log@scale@todisplaylog@#1@inv\endcsname \MIN\relax + \MIN=\pgfplots@loc@log@from@display@log@scale \MIN \pgfmathlog@invoke@expanded\pgfmathdivide@{% {\pgf@sys@tonumber\MIN}% {\Hmacro}% @@ -1923,8 +1992,8 @@ \multiply\MIN by\c@pgf@counta\relax % % convert back to basis 'e': - \MIN=\csname pgfplots@log@scale@todisplaylog@#1\endcsname\MIN\relax - \H=\csname pgfplots@log@scale@todisplaylog@#1\endcsname\H\relax + \MIN=\pgfplots@loc@log@to@display@log@scale\MIN\relax + \H=\pgfplots@loc@log@to@display@log@scale\H\relax \MINH=\MIN\relax \advance\MINH by\H\relax }% @@ -1947,16 +2016,69 @@ %\message{pgfplots.sty: #1tick set to \csname pgfplots@#1tick\endcsname [#1min=\csname pgfplots@#1min\endcsname, #1max=\csname pgfplots@#1max\endcsname].}% } +% Takes the distance between adjacent ticks as floating point number +% and returns a normalized tick distance. +% +% +% The idea is to get "nice" (human readable) distances instead of +% strange fractions or real numbers. +% +% The result will be assigned to \pgfmathresult (in float). +% +% #1 the axis (x or y or z) +% #2 the unnormalized tick distance computed so far +% +% Example: +% \pgfmathfloatparsenumber{x}{1234} +% \pgfplots@assign@default@tick@foraxis@normalizetickdist\pgfmathresult +% \pgfmathfloatotfixed\pgfmathresult +% --> +% +% \pgfmathresult={1200} +% or something like that. +\def\pgfplots@assign@default@tick@foraxis@normalizetickdist#1#2{% + \begingroup + \let\H=\pgf@xb + \expandafter\pgfmathfloat@decompose#2\relax\pgfmathfloat@a@S\H\pgfmathfloat@a@E + % modify the mantisse: + \ifdim\H<2pt + \ifdim\H<1.5pt + \H=1.0pt + \else + \H=2.0pt + \fi + \else + \ifdim\H<4.9999pt + \ifdim\H<3.5pt + \H=2.0pt\relax + \else + \H=5.0pt\relax + \fi + \else + \ifdim\H<7.5pt + \H=5.0pt\relax + \else + \H=1.0pt\relax + \advance\pgfmathfloat@a@E by1 + \fi + \fi + \fi + \pgfmathfloatcreate{\the\pgfmathfloat@a@S}{\pgf@sys@tonumber{\H}}{\the\pgfmathfloat@a@E}% + \pgfmath@smuggleone\pgfmathresult + \endgroup +}% + % Helper method for % \pgfplots@apply@data@scale@trafo@to@options@for % #1: the ticks -% #2: the trafo macro name +% #2: the trafo routine (not necessarily a single macro, but should +% take one arg) % #3: the output macro name \long\def\pgfplots@apply@data@scale@trafo@to@user@ticks#1#2\to#3{% \let#3=\pgfutil@empty \foreach \pgfplots@loc@TMPb in {#1} {% \pgfmathfloatparsenumber{\pgfplots@loc@TMPb}% - \expandafter#2\expandafter{\pgfmathresult}% + #2{\pgfmathresult}% \ifx#3\pgfutil@empty \xdef#3{\pgfmathresult}% \else |