| 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 2009 by Nick Papior Andersen. |
| 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@group@sharedlabels |
| 28 |
|
| 29 |
\def\pgfplots@group@xticklabels{} |
| 30 |
\def\pgfplots@group@yticklabels{} |
| 31 |
\def\pgfplots@group@xlabels{} |
| 32 |
\def\pgfplots@group@ylabels{} |
| 33 |
\def\pgfplots@group@totalplots{1} |
| 34 |
\def\pgfplots@group@columns{1} |
| 35 |
\def\pgfplots@group@rows{1} |
| 36 |
\def\pgfplots@group@name{group} |
| 37 |
\def\pgfplots@group@style{} |
| 38 |
\gdef\pgfplots@group@rmopts{} |
| 39 |
\newcount\pgfplots@group@current@plot |
| 40 |
\newcount\pgfplots@group@current@row |
| 41 |
\newcount\pgfplots@group@current@column |
| 42 |
|
| 43 |
\usetikzlibrary{calc} |
| 44 |
|
| 45 |
\pgfkeys{ |
| 46 |
/pgfplots/group/.is family, |
| 47 |
/pgfplots/group style/.store in=\pgfplots@group@style, |
| 48 |
/pgfplots/group/horizontal sep/.initial=1cm, |
| 49 |
/pgfplots/group/vertical sep/.initial=1cm, |
| 50 |
/pgfplots/group/group size/.style args={#1 by #2}{/pgfplots/group/columns=#1,/pgfplots/group/rows=#2}, |
| 51 |
/pgfplots/group/group size/.default={1 by 1}, |
| 52 |
/pgfplots/group/columns/.store in=\pgfplots@group@columns, |
| 53 |
/pgfplots/group/rows/.store in=\pgfplots@group@rows, |
| 54 |
/pgfplots/group/every plot/.style=, |
| 55 |
/pgfplots/group/shared labels/.is if=pgfplots@group@sharedlabels, |
| 56 |
/pgfplots/group/shared labels=false, |
| 57 |
/pgfplots/group/xticklabels at/.is choice, |
| 58 |
/pgfplots/group/xticklabels at/all/.code=\def\pgfplots@group@xticklabels{all}, |
| 59 |
/pgfplots/group/xticklabels at/edge top/.code=\def\pgfplots@group@xticklabels{top}, |
| 60 |
/pgfplots/group/xticklabels at/edge bottom/.code=\def\pgfplots@group@xticklabels{lower}, |
| 61 |
/pgfplots/group/xticklabels at/edge left/.code=\def\pgfplots@group@xticklabels{left}, % TODO |
| 62 |
/pgfplots/group/xticklabels at/edge right/.code=\def\pgfplots@group@xticklabels{right}, % TODO |
| 63 |
/pgfplots/group/xticklabels at=all, |
| 64 |
/pgfplots/group/yticklabels at/.is choice, |
| 65 |
/pgfplots/group/yticklabels at/all/.code=\def\pgfplots@group@yticklabels{all}, |
| 66 |
/pgfplots/group/yticklabels at/edge left/.code=\def\pgfplots@group@yticklabels{left}, |
| 67 |
/pgfplots/group/yticklabels at/edge right/.code=\def\pgfplots@group@yticklabels{right}, |
| 68 |
/pgfplots/group/yticklabels at/edge top/.code=\def\pgfplots@group@yticklabels{top}, % TODO |
| 69 |
/pgfplots/group/yticklabels at/edge bottom/.code=\def\pgfplots@group@yticklabels{bottom}, % TODO |
| 70 |
/pgfplots/group/yticklabels at=all, |
| 71 |
/pgfplots/group/xlabels at/.is choice, |
| 72 |
/pgfplots/group/xlabels at/all/.code=\def\pgfplots@group@xlabels{all}, |
| 73 |
/pgfplots/group/xlabels at/edge top/.code=\def\pgfplots@group@xlabels{top}, |
| 74 |
/pgfplots/group/xlabels at/edge bottom/.code=\def\pgfplots@group@xlabels{lower}, |
| 75 |
/pgfplots/group/xlabels at/edge right/.code=\def\pgfplots@group@xlabels{right}, % TODO |
| 76 |
/pgfplots/group/xlabels at/edge left/.code=\def\pgfplots@group@xlabels{left},% TODO |
| 77 |
/pgfplots/group/xlabels at=all, |
| 78 |
/pgfplots/group/ylabels at/.is choice, |
| 79 |
/pgfplots/group/ylabels at/all/.code=\def\pgfplots@group@ylabels{all}, |
| 80 |
/pgfplots/group/ylabels at/edge left/.code=\def\pgfplots@group@ylabels{left}, |
| 81 |
/pgfplots/group/ylabels at/edge right/.code=\def\pgfplots@group@ylabels{right}, |
| 82 |
/pgfplots/group/ylabels at/edge top/.code=\def\pgfplots@group@ylabels{top}, % TODO |
| 83 |
/pgfplots/group/ylabels at/edge bottom/.code=\def\pgfplots@group@ylabels{bottom}, % TODO |
| 84 |
/pgfplots/group/ylabels at=all, |
| 85 |
/pgfplots/group/x descriptions at/.is choice, |
| 86 |
/pgfplots/group/x descriptions at/all/.style={ |
| 87 |
/pgfplots/group/xlabels at=all, |
| 88 |
/pgfplots/group/xticklabels at=all |
| 89 |
}, |
| 90 |
/pgfplots/group/x descriptions at/edge bottom/.style={ |
| 91 |
/pgfplots/group/xlabels at=edge bottom, |
| 92 |
/pgfplots/group/xticklabels at=edge bottom |
| 93 |
}, |
| 94 |
/pgfplots/group/x descriptions at/edge top/.style={ |
| 95 |
/pgfplots/group/xlabels at=edge top, |
| 96 |
/pgfplots/group/xticklabels at=edge top |
| 97 |
}, |
| 98 |
/pgfplots/group/y descriptions at/.is choice, |
| 99 |
/pgfplots/group/y descriptions at/all/.style={ |
| 100 |
/pgfplots/group/ylabels at=all, |
| 101 |
/pgfplots/group/yticklabels at=all |
| 102 |
}, |
| 103 |
/pgfplots/group/y descriptions at/edge left/.style={ |
| 104 |
/pgfplots/group/ylabels at=edge left, |
| 105 |
/pgfplots/group/yticklabels at=edge left |
| 106 |
}, |
| 107 |
/pgfplots/group/y descriptions at/edge right/.style={ |
| 108 |
/pgfplots/group/ylabels at=edge right, |
| 109 |
/pgfplots/group/yticklabels at=edge right |
| 110 |
}, |
| 111 |
/pgfplots/group/group name/.store in=\pgfplots@group@name, |
| 112 |
/pgfplots/group/empty plot/.style={/pgfplots/hide axis=true}, |
| 113 |
/pgfplots/trim axis group left/.code={% |
| 114 |
\pgfutil@ifundefined{pgfsettrimleft}{% |
| 115 |
\pgfplots@error{Sorry, the 'trim axis group left' requires a more recent PGF version.}% |
| 116 |
}{% |
| 117 |
\pgfkeysalso{/tikz/trim left={(group c1r1.south west)}}% |
| 118 |
}% |
| 119 |
},% |
| 120 |
/tikz/trim axis group left/.style={/pgfplots/trim axis group left}, |
| 121 |
/pgfplots/trim axis group right/.code={% |
| 122 |
\pgfutil@ifundefined{pgfsettrimleft}{% |
| 123 |
\pgfplots@error{Sorry, the 'trim axis group right' requires a more recent PGF version.}% |
| 124 |
}{% |
| 125 |
\pgfkeysalso{/pgfplots/trim axis right}% |
| 126 |
}% |
| 127 |
},% |
| 128 |
/tikz/trim axis group right/.style={/pgfplots/trim axis group right}, |
| 129 |
} |
| 130 |
\pgfkeys{ |
| 131 |
/pgfplots/warning/groupplots/too many plots/.code 2 args={% |
| 132 |
\pgfplotsthrow@warning{You are adding more plots than you specified, current plots=#1\space vs. total allowed |
| 133 |
plots=#2.}% |
| 134 |
}, |
| 135 |
} |
| 136 |
|
| 137 |
\def\nextgroupplot{% |
| 138 |
\pgfutil@ifnextchar[{\pgfplots@group@nextplot}{\pgfplots@group@nextplot[]}%} |
| 139 |
} |
| 140 |
|
| 141 |
% |
| 142 |
% The actual addition of the new plots |
| 143 |
% |
| 144 |
\def\pgfplots@group@nextplot[#1]{% |
| 145 |
% Check if it legal to produce another plot |
| 146 |
\ifnum\pgfplots@group@current@plot=\pgfplots@group@totalplots\relax |
| 147 |
\pgfplotswarning{groupplots/too many plots}{\the\pgfplots@group@current@plot}{\pgfplots@group@totalplots}\pgfeov |
| 148 |
\else |
| 149 |
% |
| 150 |
% If there has been other plots before then end the plot |
| 151 |
% |
| 152 |
\ifnum0<\pgfplots@group@current@plot\relax |
| 153 |
% DEBUG: \message{DEBUG: Ending plot} |
| 154 |
\endpgfplots@environment@opt |
| 155 |
\fi |
| 156 |
% Prepare for next plot, increment plot, row and column |
| 157 |
\pgfplots@group@increment@numbers |
| 158 |
% DEBUG: \message{DEBUG: Cur. Plot: \the\pgfplots@group@current@plot. Current Row: \the\pgfplots@group@current@row. Current Column: \the\pgfplots@group@current@column.} |
| 159 |
% Creation of the new axis environment |
| 160 |
\pgfplots@group@environment@create{#1} |
| 161 |
\fi |
| 162 |
} |
| 163 |
% |
| 164 |
% This creates an environment according to which plots that have been typeset. |
| 165 |
% The code utilizes previous plots anchor points to position themselves, unless it's the |
| 166 |
% first plot. |
| 167 |
% Using the figure below to describe the code implementation: |
| 168 |
% ____ ____ ____ |
| 169 |
%| | | | | | |
| 170 |
%| 1 | | 2 | | 3 | |
| 171 |
%|___| |___| |___| |
| 172 |
% ____ ____ ____ |
| 173 |
%| | | | | | |
| 174 |
%| 4 | | 5 | | 6 | |
| 175 |
%|___| |___| |___| |
| 176 |
% ____ ____ ____ |
| 177 |
%| | | | | | |
| 178 |
%| 7 | | 8 | | 9 | |
| 179 |
%|___| |___| |___| |
| 180 |
% |
| 181 |
% The plots anchors are as follows: |
| 182 |
% 1: plot is typeset normally |
| 183 |
% 2: the "1" plot anchor "east" is anchored to "west" |
| 184 |
% 3: the "2" plot anchor "east" is anchored to "west" |
| 185 |
% 4: the "1" plot anchor "south" is anchored to "north" |
| 186 |
% 5: the "2" plot anchor "south" is anchored to "north" |
| 187 |
% 6: the "3" plot anchor "south" is anchored to "north" |
| 188 |
% 7: the "4" plot anchor "south" is anchored to "north" |
| 189 |
% 8: the "5" plot anchor "south" is anchored to "north" |
| 190 |
% 9: the "6" plot anchor "south" is anchored to "north" |
| 191 |
% |
| 192 |
\def\pgfplots@group@environment@create#1{% |
| 193 |
\ifnum1=\pgfplots@group@current@row\relax |
| 194 |
\ifnum1=\pgfplots@group@current@column\relax |
| 195 |
\pgfplots@environment@opt[name={\pgfplots@group@name\space c\the\pgfplots@group@current@column r\the\pgfplots@group@current@row},% |
| 196 |
/pgfplots/group/every plot,% |
| 197 |
/pgfplots/group/plot c\the\pgfplots@group@current@column r\the\pgfplots@group@current@row,% |
| 198 |
#1] |
| 199 |
\else |
| 200 |
\pgfplotsgroupplotsmath@decrease\pgfplots@group@current@column |
| 201 |
\xdef\pgfplots@glob@TMPb{\pgfplots@group@name\space c\pgfmathresult r\the\pgfplots@group@current@row} |
| 202 |
\pgfplots@environment@opt[name={\pgfplots@group@name\space c\the\pgfplots@group@current@column r\the\pgfplots@group@current@row},% |
| 203 |
/pgfplots/group/every plot,% |
| 204 |
/pgfplots/group/plot c\the\pgfplots@group@current@column r\the\pgfplots@group@current@row,% |
| 205 |
at={($(\pgfplots@[email protected])+(\pgfkeysvalueof{/pgfplots/group/horizontal sep},0)$)},anchor=west,% |
| 206 |
#1] |
| 207 |
\fi |
| 208 |
\else |
| 209 |
\pgfplotsgroupplotsmath@decrease\pgfplots@group@current@row |
| 210 |
\xdef\pgfplots@glob@TMPb{\pgfplots@group@name\space c\the\pgfplots@group@current@column r\pgfmathresult} |
| 211 |
\pgfplots@environment@opt[name={\pgfplots@group@name\space c\the\pgfplots@group@current@column r\the\pgfplots@group@current@row},% |
| 212 |
/pgfplots/group/every plot,% |
| 213 |
/pgfplots/group/plot c\the\pgfplots@group@current@column r\the\pgfplots@group@current@row,% |
| 214 |
at={($(\pgfplots@[email protected])-(0,\pgfkeysvalueof{/pgfplots/group/vertical sep})$)},anchor=north,% |
| 215 |
#1]% |
| 216 |
\fi% |
| 217 |
} |
| 218 |
|
| 219 |
% |
| 220 |
% Determine the labels of both x and y. |
| 221 |
% |
| 222 |
\def\pgfplots@group@determine@labels{% |
| 223 |
\def\pgfplots@loc@TMPa{all}% |
| 224 |
\def\pgfplots@loc@TMPb{lower}% |
| 225 |
\ifx\pgfplots@loc@TMPa\pgfplots@group@xlabels% |
| 226 |
% xlabels at=all |
| 227 |
% Do nothing as all should have xlabels |
| 228 |
\fi |
| 229 |
\gdef\pgfplots@glob@TMPa{}% |
| 230 |
\ifx\pgfplots@loc@TMPb\pgfplots@group@xlabels% |
| 231 |
% xlabels at=lower |
| 232 |
\ifnum1<\pgfplots@group@rows\relax |
| 233 |
\foreach \pgfplots@column in {1,...,\pgfplots@group@columns} {% |
| 234 |
\foreach \pgfplots@row in {1,...,\pgfplots@group@rows} {% |
| 235 |
\ifnum\pgfplots@row=\pgfplots@group@rows\relax% |
| 236 |
\else |
| 237 |
\expandafter\xdef\expandafter\pgfplots@glob@TMPa\expandafter{% |
| 238 |
\pgfplots@glob@TMPa,/pgfplots/group/plot c\pgfplots@column r\pgfplots@row/.append style={% |
| 239 |
/pgfplots/xlabel={},% |
| 240 |
\ifpgfplots@units@use/pgfplots/x unit={}\fi |
| 241 |
}% |
| 242 |
}% |
| 243 |
\fi |
| 244 |
}% |
| 245 |
}% |
| 246 |
\fi% |
| 247 |
\else |
| 248 |
\def\pgfplots@loc@TMPb{top}% |
| 249 |
\ifx\pgfplots@loc@TMPb\pgfplots@group@xlabels% |
| 250 |
% xlabels at=top |
| 251 |
\ifnum1<\pgfplots@group@rows\relax |
| 252 |
\foreach \pgfplots@column in {1,...,\pgfplots@group@columns} {% |
| 253 |
\foreach \pgfplots@row in {1,...,\pgfplots@group@rows} {% |
| 254 |
\ifnum\pgfplots@row=1 % |
| 255 |
\expandafter\xdef\expandafter\pgfplots@glob@TMPa\expandafter{% |
| 256 |
\pgfplots@glob@TMPa,/pgfplots/group/plot c\pgfplots@column r\pgfplots@row/.append style={/pgfplots/xticklabel pos=upper}}% |
| 257 |
\else |
| 258 |
\expandafter\xdef\expandafter\pgfplots@glob@TMPa\expandafter{% |
| 259 |
\pgfplots@glob@TMPa,/pgfplots/group/plot c\pgfplots@column r\pgfplots@row/.append style={% |
| 260 |
/pgfplots/xlabel={},% |
| 261 |
\ifpgfplots@units@use/pgfplots/x unit={}\fi% |
| 262 |
}% |
| 263 |
}% |
| 264 |
\fi |
| 265 |
}% |
| 266 |
}% |
| 267 |
\fi% |
| 268 |
\fi |
| 269 |
\fi |
| 270 |
% |
| 271 |
% Defining styles for the y's |
| 272 |
% |
| 273 |
\ifx\pgfplots@loc@TMPa\pgfplots@group@ylabels% |
| 274 |
% ylabels at=all |
| 275 |
% Do nothing as all should have ylabels |
| 276 |
\else |
| 277 |
\def\pgfplots@loc@TMPb{left}% |
| 278 |
\ifx\pgfplots@loc@TMPb\pgfplots@group@ylabels% |
| 279 |
% ylabels at=left |
| 280 |
\ifnum1<\pgfplots@group@columns\relax |
| 281 |
\foreach \pgfplots@row in {1,...,\pgfplots@group@rows} {% |
| 282 |
\foreach \pgfplots@column in {2,...,\pgfplots@group@columns} {% |
| 283 |
\expandafter\xdef\expandafter\pgfplots@glob@TMPa\expandafter{% |
| 284 |
\pgfplots@glob@TMPa,/pgfplots/group/plot c\pgfplots@column r\pgfplots@row/.append style={% |
| 285 |
/pgfplots/ylabel={},% |
| 286 |
\ifpgfplots@units@use/pgfplots/y unit={}\fi% |
| 287 |
}% |
| 288 |
}% |
| 289 |
}% |
| 290 |
}% |
| 291 |
\fi% |
| 292 |
\else |
| 293 |
\def\pgfplots@loc@TMPb{right}% |
| 294 |
\ifx\pgfplots@loc@TMPb\pgfplots@group@ylabels% |
| 295 |
% ylabels at=right |
| 296 |
\ifnum1<\pgfplots@group@columns\relax |
| 297 |
\foreach \pgfplots@row in {1,...,\pgfplots@group@rows} {% |
| 298 |
\foreach \pgfplots@column in {1,...,\pgfplots@group@columns} {% |
| 299 |
\ifnum\pgfplots@column=\pgfplots@group@columns\relax |
| 300 |
\expandafter\xdef\expandafter\pgfplots@glob@TMPa\expandafter{% |
| 301 |
\pgfplots@glob@TMPa,/pgfplots/group/plot c\pgfplots@column r\pgfplots@row/.append style={/pgfplots/yticklabel pos=upper}}% |
| 302 |
\else |
| 303 |
\expandafter\xdef\expandafter\pgfplots@glob@TMPa\expandafter{% |
| 304 |
\pgfplots@glob@TMPa,/pgfplots/group/plot c\pgfplots@column r\pgfplots@row/.append style={% |
| 305 |
/pgfplots/ylabel={},% |
| 306 |
\ifpgfplots@units@use/pgfplots/y unit={}\fi% |
| 307 |
}% |
| 308 |
}% |
| 309 |
\fi |
| 310 |
}% |
| 311 |
}% |
| 312 |
\fi |
| 313 |
\fi% |
| 314 |
\fi |
| 315 |
\fi |
| 316 |
\expandafter\pgfkeys\expandafter{\pgfplots@glob@TMPa}% |
| 317 |
} |
| 318 |
|
| 319 |
% |
| 320 |
% Determine the ticklabels of both x and y. |
| 321 |
% |
| 322 |
\def\pgfplots@group@determine@ticklabels{% |
| 323 |
\def\pgfplots@loc@TMPa{all}% |
| 324 |
\def\pgfplots@loc@TMPb{top}% |
| 325 |
\def\pgfplots@loc@TMPc{lower}% |
| 326 |
\ifx\pgfplots@loc@TMPa\pgfplots@group@xticklabels% |
| 327 |
% Do nothing as all should have xticklabels |
| 328 |
\fi |
| 329 |
\gdef\pgfplots@glob@TMPa{} |
| 330 |
\ifx\pgfplots@loc@TMPb\pgfplots@group@xticklabels% |
| 331 |
\foreach \pgfplots@column in {1,...,\pgfplots@group@columns} {% |
| 332 |
\expandafter\xdef\expandafter\pgfplots@glob@TMPa\expandafter{% |
| 333 |
\pgfplots@glob@TMPa,/pgfplots/group/plot c\pgfplots@column r1/.append style={% |
| 334 |
xticklabel pos=upper}}% |
| 335 |
\ifnum1<\pgfplots@group@rows\relax |
| 336 |
\foreach \pgfplots@row in {2,...,\pgfplots@group@rows} {% |
| 337 |
\expandafter\xdef\expandafter\pgfplots@glob@TMPa\expandafter{% |
| 338 |
\pgfplots@glob@TMPa,/pgfplots/group/plot c\pgfplots@column r\pgfplots@row/.append style={% |
| 339 |
/pgfplots/xticklabels={},/pgfplots/xtick scale label code/.code={}}}% |
| 340 |
}% |
| 341 |
\fi% |
| 342 |
}% |
| 343 |
\fi |
| 344 |
\ifx\pgfplots@loc@TMPc\pgfplots@group@xticklabels% |
| 345 |
\foreach \pgfplots@column in {1,...,\pgfplots@group@columns} {% |
| 346 |
\expandafter\xdef\expandafter\pgfplots@glob@TMPa\expandafter{% |
| 347 |
\pgfplots@glob@TMPa,/pgfplots/group/plot c\pgfplots@column r\pgfplots@group@rows/.append style={% |
| 348 |
xticklabel pos=lower}}% |
| 349 |
\ifnum1<\pgfplots@group@rows\relax |
| 350 |
\pgfplotsgroupplotsmath@decrease\pgfplots@group@rows |
| 351 |
\foreach \pgfplots@row in {1,...,\pgfmathresult} {% |
| 352 |
\expandafter\xdef\expandafter\pgfplots@glob@TMPa\expandafter{% |
| 353 |
\pgfplots@glob@TMPa,/pgfplots/group/plot c\pgfplots@column r\pgfplots@row/.append style={% |
| 354 |
/pgfplots/xticklabels={},/pgfplots/xtick scale label code/.code={}}}% |
| 355 |
}% |
| 356 |
\fi% |
| 357 |
}% |
| 358 |
\fi% |
| 359 |
% |
| 360 |
% Defining styles for the ytick's |
| 361 |
% |
| 362 |
\def\pgfplots@loc@TMPa{all}% |
| 363 |
\def\pgfplots@loc@TMPb{left}% |
| 364 |
\def\pgfplots@loc@TMPc{right}% |
| 365 |
\ifx\pgfplots@loc@TMPa\pgfplots@group@yticklabels% |
| 366 |
% Do nothing as all should have yticklabels |
| 367 |
\fi |
| 368 |
\ifx\pgfplots@loc@TMPb\pgfplots@group@yticklabels% |
| 369 |
\foreach \pgfplots@row in {1,...,\pgfplots@group@rows} {% |
| 370 |
\expandafter\xdef\expandafter\pgfplots@glob@TMPa\expandafter{% |
| 371 |
\pgfplots@glob@TMPa,/pgfplots/group/plot c1r\pgfplots@row/.append style={yticklabel pos=left}}% |
| 372 |
\ifnum1<\pgfplots@group@columns\relax |
| 373 |
\foreach \pgfplots@column in {2,...,\pgfplots@group@columns} {% |
| 374 |
\expandafter\xdef\expandafter\pgfplots@glob@TMPa\expandafter{% |
| 375 |
\pgfplots@glob@TMPa,/pgfplots/group/plot c\pgfplots@column r\pgfplots@row/.append style={% |
| 376 |
/pgfplots/yticklabels={}, /pgfplots/ytick scale label code/.code={}}}% |
| 377 |
}% |
| 378 |
\fi% |
| 379 |
}% |
| 380 |
\fi |
| 381 |
\ifx\pgfplots@loc@TMPc\pgfplots@group@yticklabels% |
| 382 |
\foreach \pgfplots@row in {1,...,\pgfplots@group@rows} {% |
| 383 |
\expandafter\xdef\expandafter\pgfplots@glob@TMPa\expandafter{% |
| 384 |
\pgfplots@glob@TMPa,/pgfplots/group/plot c\pgfplots@group@columns r\pgfplots@row/.append style={% |
| 385 |
yticklabel pos=right}}% |
| 386 |
\ifnum1<\pgfplots@group@columns\relax |
| 387 |
\pgfplotsgroupplotsmath@decrease\pgfplots@group@columns |
| 388 |
\foreach \pgfplots@column in {1,...,\pgfmathresult} {% |
| 389 |
\expandafter\xdef\expandafter\pgfplots@glob@TMPa\expandafter{% |
| 390 |
\pgfplots@glob@TMPa,/pgfplots/group/plot c\pgfplots@column r\pgfplots@row/.append style={% |
| 391 |
/pgfplots/yticklabels={}, /pgfplots/ytick scale label code/.code={}}}% |
| 392 |
}% |
| 393 |
\fi% |
| 394 |
}% |
| 395 |
\fi% |
| 396 |
\expandafter\pgfkeys\expandafter{\pgfplots@glob@TMPa}% |
| 397 |
} |
| 398 |
|
| 399 |
% |
| 400 |
% The counters which are used to determine the current plot: |
| 401 |
% \pgfplots@group@current@plot |
| 402 |
% \pgfplots@group@current@column |
| 403 |
% \pgfplots@group@current@row |
| 404 |
% gets incremented according to the scheme below: |
| 405 |
% ____ ____ ____ |
| 406 |
%| | | | | | |
| 407 |
%| 1 | | 2 | | 3 | |
| 408 |
%|___| |___| |___| |
| 409 |
% ____ ____ ____ |
| 410 |
%| | | | | | |
| 411 |
%| 4 | | 5 | | 6 | |
| 412 |
%|___| |___| |___| |
| 413 |
% ____ ____ ____ |
| 414 |
%| | | | | | |
| 415 |
%| 7 | | 8 | | 9 | |
| 416 |
%|___| |___| |___| |
| 417 |
% where the number matches the plot number. |
| 418 |
% |
| 419 |
\def\pgfplots@group@increment@numbers{% |
| 420 |
\advance\pgfplots@group@current@plot by1 |
| 421 |
\ifnum\pgfplots@group@current@column=\pgfplots@group@columns\relax |
| 422 |
\ifnum1=\pgfplots@group@current@plot\relax |
| 423 |
\else |
| 424 |
\advance\pgfplots@group@current@row by1 |
| 425 |
\fi |
| 426 |
\pgfplots@group@current@column=1 |
| 427 |
\else |
| 428 |
\advance\pgfplots@group@current@column by1 |
| 429 |
\fi |
| 430 |
} |
| 431 |
|
| 432 |
\def\pgfplots@group@get@plot@name#1,#2\in#3{% |
| 433 |
\edef#3{c#1r#2}% |
| 434 |
} |
| 435 |
|
| 436 |
|
| 437 |
% |
| 438 |
% Setting up all possible styles in current plot |
| 439 |
% I.e. Setting: |
| 440 |
% /pgfplots/group/plot c1r1/.style= |
| 441 |
% /pgfplots/group/plot c2r1/.style= |
| 442 |
% ... |
| 443 |
% /pgfplots/group/plot c<columns>r<rows>/.style= |
| 444 |
% |
| 445 |
\def\pgfplots@group@individual@setup{% |
| 446 |
\gdef\pgfplots@glob@TMPa{} |
| 447 |
\foreach \pgfplots@column in {1,...,\pgfplots@group@columns} {% |
| 448 |
\foreach \pgfplots@row in {1,...,\pgfplots@group@rows} {% |
| 449 |
\expandafter\xdef\expandafter\pgfplots@glob@TMPa\expandafter{% |
| 450 |
\pgfplots@glob@TMPa,/pgfplots/group/plot c\pgfplots@column r\pgfplots@row/.style=}% |
| 451 |
}% |
| 452 |
}% |
| 453 |
\expandafter\pgfkeys\expandafter{\pgfplots@glob@TMPa}% |
| 454 |
} |
| 455 |
|
| 456 |
|
| 457 |
|
| 458 |
% |
| 459 |
% Implementation of the environment {groupplots} |
| 460 |
\def\pgfplots@environment@groupplot{% |
| 461 |
\pgfutil@ifnextchar[{\pgfplots@@environment@groupplot}{\pgfplots@@environment@groupplot[\pgfutil@empty]}% |
| 462 |
} |
| 463 |
|
| 464 |
\def\endpgfplots@environment@groupplot{% |
| 465 |
\endpgfplots@environment@opt |
| 466 |
% |
| 467 |
% transport some items beyond this \endgroup: |
| 468 |
\pgf@remember@layerlist@globally |
| 469 |
\aftergroup\pgf@restore@layerlist@from@global |
| 470 |
\endgroup |
| 471 |
% |
| 472 |
% ... and transport them beyond the next \endgroup as well (LaTeX |
| 473 |
% introduces one for \end{groupplot}): |
| 474 |
\aftergroup\pgf@restore@layerlist@from@global |
| 475 |
\aftergroup\pgfplots@cell@picture@remembered |
| 476 |
} |
| 477 |
|
| 478 |
\def\pgfplots@@environment@groupplot[#1]{% |
| 479 |
\begingroup% |
| 480 |
% Only find the keys column and row |
| 481 |
% the following things appear to be complete... ? |
| 482 |
\pgfkeysinstallkeyfilterhandler{/pgf/key filter handlers/append filtered to}{\pgfplots@group@rmopts}% |
| 483 |
\let\pgfplots@group@rmopts=\pgfutil@empty |
| 484 |
\pgfkeysinstallkeyfilter{/pgf/key filters/equals}{/pgfplots/group style}% |
| 485 |
\pgfkeysinstallkeyfilter{/pgf/key filters/is descendant of}{/pgfplots/group}% |
| 486 |
\pgfqkeysfiltered{/pgfplots}{#1}% |
| 487 |
\edef\pgfplots@loc@TMPa{% |
| 488 |
\noexpand\pgfkeys{/pgfplots/group/.cd,\pgfplots@group@style}% |
| 489 |
}\pgfplots@loc@TMPa |
| 490 |
% |
| 491 |
\let\pgfplots@set@options@sanitizemode@old=\pgfplots@set@options@sanitizemode |
| 492 |
\let\pgfplots@set@options@sanitize@old=\pgfplots@set@options@sanitize |
| 493 |
\let\pgfplots@set@options@sanitize=\relax |
| 494 |
\let\pgfplots@set@options@sanitizemode=\relax |
| 495 |
\expandafter\pgfplots@set@options\expandafter{\pgfplots@group@rmopts}% |
| 496 |
\let\pgfplots@set@options@sanitize=\pgfplots@set@options@sanitize@old |
| 497 |
\let\pgfplots@set@options@sanitizemode=\pgfplots@set@options@sanitizemode@old |
| 498 |
% |
| 499 |
\pgfplots@group@individual@setup |
| 500 |
\pgfplots@group@determine@ticklabels |
| 501 |
\pgfplots@group@determine@labels |
| 502 |
\pgfplots@group@current@plot=0 % |
| 503 |
\pgfplots@group@current@row=1 % |
| 504 |
\pgfplots@group@current@column=0 % |
| 505 |
\begingroup |
| 506 |
\c@pgf@counta=\pgfplots@group@rows\relax |
| 507 |
\multiply \c@pgf@counta by\pgfplots@group@columns\relax |
| 508 |
\edef\pgfmathresult{\the\c@pgf@counta}% |
| 509 |
\pgfmath@smuggleone\pgfmathresult |
| 510 |
\endgroup |
| 511 |
\edef\pgfplots@group@totalplots{\pgfmathresult}% |
| 512 |
%DEBUG: \message{TEST: \pgfplots@group@totalplots, rows=\pgfplots@group@rows, columns=\pgfplots@group@columns}% |
| 513 |
} |
| 514 |
|
| 515 |
% Assigns \pgfmathresult as #1-1 (in integer arithmetics) |
| 516 |
% |
| 517 |
% #1 an integer (a register or something which expands to an integer). |
| 518 |
\def\pgfplotsgroupplotsmath@decrease#1{% |
| 519 |
\begingroup |
| 520 |
\c@pgf@counta=#1\relax |
| 521 |
\advance\c@pgf@counta by-1 |
| 522 |
\edef\pgfmathresult{\the\c@pgf@counta}% |
| 523 |
\pgfmath@smuggleone\pgfmathresult |
| 524 |
\endgroup |
| 525 |
} |
| 526 |
|
| 527 |
\tikzaddtikzonlycommandshortcutlet\groupplot\pgfplots@environment@groupplot |
| 528 |
\tikzaddtikzonlycommandshortcutlet\endgroupplot\endpgfplots@environment@groupplot |
| 529 |
|
| 530 |
\endinput |