summaryrefslogtreecommitdiff
path: root/tex/.texmf/tex/generic/pgfplots/pgfplotscore.code.tex
blob: c2ed44a36b773d0742cc9674e1c85dac30a963d2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
%--------------------------------------------
%
% Package pgfplots
%
% Provides a user-friendly interface to create function plots (normal
% plots, semi-logplots and double-logplots).
% 
% It is based on Till Tantau's PGF package.
%
% Copyright 2007-2014 by Christian Feuersänger.
%
% This program is free software: you can redistribute it and/or modify
% it under the terms of the GNU General Public License as published by
% the Free Software Foundation, either version 3 of the License, or
% (at your option) any later version.
% 
% This program is distributed in the hope that it will be useful,
% but WITHOUT ANY WARRANTY; without even the implied warranty of
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
% GNU General Public License for more details.
% 
% You should have received a copy of the GNU General Public License
% along with this program.  If not, see <http://www.gnu.org/licenses/>.
%
%--------------------------------------------

\def\pgfplotsset#{\pgfqkeys{/pgfplots}}

% This is *identical* to \pgfutil@IfUndefined . I copied it here
% because pgf up to and including version 2.10 does not contain it.
\def\pgfplotsutil@IfUndefined#1{%
  \begingroup\expandafter\expandafter\expandafter\endgroup
  \expandafter\ifx\csname#1\endcsname\relax
    \expandafter\pgfutil@firstoftwo
  \else
    \expandafter\pgfutil@secondoftwo
  \fi
}
\pgfplotsutil@IfUndefined{pgfutil@IfUndefined}{\let\pgfutil@IfUndefined=\pgfplotsutil@IfUndefined}{}

\newif\ifpgfplots@LUA@supported
\pgfutil@IfUndefined{directlua}{%
	\pgfplots@LUA@supportedfalse
}{%
	\pgfplots@LUA@supportedtrue
}%

% this is an emergency key which allows to switch off LUA support in
% pgfplots early at boot time. 
%
% use \def\pgfplotsenablelua{0} to switch it off. '1' switches it on
% (or uncommenting the line).
\pgfutil@IfUndefined{pgfplotsenablelua}{}{%
	\def\pgfplots@glob@TMPc{1}%
	\ifx\pgfplots@glob@TMPc\pgfplotsenablelua
	\else
		\pgfplots@LUA@supportedfalse
	\fi
}%

\pgfkeys{
	/pgfplots/lua support/.is choice,
	/pgfplots/lua support/true/.code={\pgfplots@LUA@supportedtrue},%
	/pgfplots/lua support/false/.code={\pgfplots@LUA@supportedfalse},%
	/pgfplots/lua support/auto/.code={%
		\pgfutil@IfUndefined{directlua}{%
			\pgfplots@LUA@supportedfalse
		}{%
			\pgfplots@LUA@supportedtrue
		}%
	},%
	%/pgfplots/lua support/auto,% this is the default anyway
}

\def\pgfplotsloglevel{4}%

\def\pgfplots@log#1#2{%
	\ifnum#1>\pgfplotsloglevel\relax
	\else
		\ifnum\inputlineno=1
			\pgfutil@IfUndefined{@currenvline}{%
				\def\pgfplots@log@tmp{}%
			}{%
				\let\pgfplots@log@tmp=\@currenvline
			}%
		\else
			\def\pgfplots@log@tmp{ on input line \the\inputlineno}%
		\fi
		\immediate\write-1{Package pgfplots info\pgfplots@log@tmp: #2}%
	\fi
}%
\def\pgfplots@error#1{\PackageError{pgfplots}{#1}{}}%
\def\pgfplotstable@error@pkg#1{\PackageError{pgfplotstable}{#1}{}}%
% DO NOT USE THIS METHOD DIRECTLY: use \pgfplotswarning{<warning name>}<args>\pgfeov
\pgfplotsutil@IfUndefined{PackageWarning}{%
	\def\pgfplots@warning#1{\pgfplots@message{! Package pgfplots Warning:
#1}}%
}{%
	\def\pgfplots@warning#1{\PackageWarning{pgfplots}{#1}{}}%
}%

\def\pgfplots@message#1{%
	\immediate\write16{#1}%
}%

\pgfutil@IfUndefined{pgfkeys}{%
	\pgfplots@error{It seems your version of PGF/Tikz is older than 2.00. Unfortunately, pgfplots requires at least version 2.00 ... you may need to update your TeX-Distribution or install PGF manually, sorry}%
}{\relax}

% Throws exception `#1' with arguments `#2'.
%
% #1 : the exception name
% #2: all what comes after the exception name is considered to be argument
%    (or arguments) for the exception '#1'.
%    the \pgfeov is IMPORTANT as it delimits the argument.
%
% Note that all standard pgfplots exceptions provide a feature to
% exchange the error message text: define \pgfplotsexceptionmsg
% set a replacement.
\def\pgfplotsthrow#1#2\pgfeov{%
	\def\pgfkeyscurrentkey{/pgfplots/exception/#1}%
	\pgfkeysvalueof{/pgfplots/exception/#1/.@cmd}#2\pgfeov
}%
\let\pgfplotsthrow@orig=\pgfplotsthrow

% Generates warning `#1' with argument(s) `#2'.
%
% It works in exactly the same way as \pgfplotsthrow.
\def\pgfplotswarning#1#2\pgfeov{%
	\def\pgfkeyscurrentkey{/pgfplots/warning/#1}%
	\pgfkeysvalueof{/pgfplots/warning/#1/.@cmd}#2\pgfeov
}%

\def\pgfplotsthrow@warning#1{%
	\pgfplots@warning{#1}%
	\immediate\write-1{ [warning \pgfkeyscurrentkey]}%
}%

\def\pgfplots@assert@not@zero#1#2{%
	\ifdim#1=0sp %
		\pgfplotsthrow{invalid argument}{\pgfplots@loc@TMPa}{#2}\pgfeov
	\fi
}%

% A primitive try #1 catch #2 end  block.
%
% It tries code #1. If any exception occurs within, it suppresses the
% exception and tries to continue. It then invokes #2 as soon as it
% can.
%
% You can use \pgfplotsrethrow in #2.
%
% ATTENTION: this is a simple attempt to simulate error control. Don't
% rely on it too heavily! In the moment, I am not even sure if it can
% be nested (perhaps you need to introduce extra scopes since
% \pgfplotstry doesn't).
\long\def\pgfplotstry#1\catch#2\endpgfplotstry{%
	\global\let\pgfplotstry@exception\pgfutil@empty
	\def\pgfplotsthrow##1##2\pgfeov{\gdef\pgfplotstry@exception{{##1}{##2}}}%
	#1\relax%
	\let\pgfplotsthrow=\pgfplotsthrow@orig
	\ifx\pgfplotstry@exception\pgfutil@empty
	\else
		#2%
	\fi
	\global\let\pgfplotstry@exception\pgfutil@empty
}%
\def\pgfplotsrethrow{\expandafter\pgfplotsthrow\pgfplotstry@exception\pgfeov}%

\pgfkeys{
	% #1: the argument which should have been assigned.
	% #2: an error message. 
	/pgfplots/exception/invalid argument/.code 2 args={%
		\ifx\pgfplotsexceptionmsg\relax
			\pgfplots@error{#2}%
		\else
			\pgfplots@error{\pgfplotsexceptionmsg}%
		\fi
		\let#1=\pgfutil@empty
	},%
	% #1 : the layer name
	% #2 : additional context information (message)
	/pgfplots/exception/inactive layer/.code 2 args={%
		\ifx\pgfplotsexceptionmsg\relax
			\pgfplots@error{Sorry, the layer '#1' has not been activated but it is referenced in #2. Perhaps you misspelled it? Each referenced layer must be activated (expect for layer 'discard').}%
		\else
			\pgfplots@error{\pgfplotsexceptionmsg}%
		\fi
	},%
	% #1: the argument which should have been assigned.
	% #2: an error message. 
	/pgfplots/exception/no such element/.code 2 args={%
		\ifx\pgfplotsexceptionmsg\relax
			\pgfplots@error{#2}%
		\else
			\pgfplots@error{\pgfplotsexceptionmsg}%
		\fi
		\let#1=\pgfutil@empty
	},%
	/pgfplots/exception/invalid color component/.code 2 args={%
		\ifx\pgfplotsexceptionmsg\relax
			\pgfplots@error{#2}%
		\else
			\pgfplots@error{\pgfplotsexceptionmsg}%
		\fi
		\let#1=\pgfutil@empty
	},%
	% #1: an error message
	/pgfplots/exception/unsupported operation/.code={%
		\ifx\pgfplotsexceptionmsg\relax
			\pgfplots@error{#1}%
		\else
			\pgfplots@error{\pgfplotsexceptionmsg}%
		\fi
	},%
	% #1: the argument which should have been assigned.
	% #2: the file name
	% #3: the error message
	/pgfplots/exception/no such table file/.code args={#1#2#3}{%
		\ifx\pgfplotsexceptionmsg\relax
			\pgfplots@error{#3}%
		\else
			\pgfplots@error{\pgfplotsexceptionmsg}%
		\fi
		\let#1=\relax
	},
	%
	%
	%
	%
	% Generated if you say 'ymin=0' in a log axis.
	% #1: the user argument ('ymin')
	% #2: the offending value.
	/pgfplots/warning/illegal user argument in log axis/.code args={#1#2}{%
		\pgfplotsthrow@warning{Ignoring illegal input argument #1=#2: cannot apply log.}%
	},
	/pgfplots/warning/plot without coordinates/.code={%
		\pgfplotsthrow@warning{the current plot has no coordinates (or all have been filtered away)}%
	},
	/pgfplots/warning/log basis required/.code 2 args={%
		\pgfplotsthrow@warning{Some input argument (#2) explicitly relies on the log basis of #1 (which is e). Please verify that this is intended and set 'log basis #1=10' otherwise. This warning will be shown only once per document.}%
	},
	/pgfplots/warning/no such legend to name/.code={%
		\pgfplotsthrow@warning{There is no `legend to name=#1', sorry. I am skipping it}%
	},
	/pgfplots/warning/no such colorbar to name/.code={%
		\pgfplotsthrow@warning{There is no `colorbar to name=#1', sorry. I am skipping it}%
	},
	/pgfplots/warning/no such addplot label/.code={%
		\pgfplotsthrow@warning{There is no \string\addplot\space label `#1', sorry. I am skipping it}%
	},
	/pgfplots/warning/enlargelimits respects figure size failed/.code={%
		\pgfplotsthrow@warning{enlargelimits respects figure size=true: could not respect the prescribed width/height (\pgfplotsretval). The size and/or aspect ratio of your image will be different than expected. You can try to modify BOTH width and height.}%
	},
	% #1: the axis
	/pgfplots/warning/empty range cleared axis/.code={%
		\pgfplotsthrow@warning{You have an axis with empty range (in direction #1). Replacing it with a default range and clearing all plots.}%
	},
	/pgfplots/warning/approx empty range enlarged/.code args={#1#2#3}{%
		\pgfplotsthrow@warning{Axis range for axis #1 is approximately empty; enlarging it (it is [#2:#3])}%
	},
	/pgfplots/warning/lossy colormap rgb conversion/.code 2 args={%
		\pgfplotsthrow@warning{I am about to convert colormap '#1' from #2\space to rgb (which might be lossy). Perhaps the choice 'colorbar sampled={surf,shader=interp}' yields better results since it supports #2.}%
	},
	/pgfplots/warning/colorbar uninitialised/.code={%
		\pgfplotsthrow@warning{Sorry, the colorbar is uninitialised - your axis has no color data. Consider using 'point meta=f(x)' or something like that. I am using a color range of [0,1] for the colorbar.}%
	},
	/pgfplots/warning/colorbar CMYK unsupported/.code={%
		\pgfplotsthrow@warning{colorbar remark: The colormap '#1' has a CMYK colorspace which is not (yet) supported by PGF. I switched colorbar styles automatically to the visually equivalent 'colorbar sampled={surf,shader=interp}' to generate a proper CMYK colorbar. This has less support in some previewers. Use \string\pgfplotscolorbarCMYKworkaroundfalse\space to disable this improvement. [This message won't be replicated for '#1']}%
	},
	/pgfplots/warning/ticklabel anchor undetermined/.code args={#1#2#3#4}{%
		\pgfplotsthrow@warning{the ticklabel anchor cannot be determined, the normal vector -(#2) and the unit #1 vector (#3) are almost parallel (abs(cos(angle)) = #4)!}%
	},
	/pgfplots/warning/point meta unbounded/.code 2 args={%
		\pgfplotsthrow@warning{The per point meta data `#1' (#2) (and probably others as well) is unbounded - using the minimum value instead.}%
	},
	/pgfplots/warning/gnuplot -V impossible/.code={%
		\pgfplotsthrow@warning{Sorry, I could not determine 'gnuplot -V' to check whether gnuplot and logscale writes results in log() or not. Please set `/pgfplots/gnuplot writes logscale=true|false' manually.}%
	},
	/pgfplots/warning/gnuplot -V format unknown/.code={%
		\pgfplotsthrow@warning{Sorry, I can't reliably check which version of gnuplot is available. I guess it is gnuplot < 4.4. Please set `/pgfplots/gnuplot writes logscale=true|false' manually if anything fails.}%
	},
	/pgfplots/warning/plot3 graphics compatibility mode/.code={%
		\pgfplotsthrow@warning{plot3 graphics is running in backwards compatibility mode. %
					Use \string\pgfplotsset{compat=1.6} or higher to benefit from upgraded scaling capabilites.}%
	},
	/pgfplots/warning/plot3 graphics too few inner anchors/.code={%
		\pgfplotsthrow@warning{plot graphics in 3D axis has just two inner anchors (those with '(x,y,z)=>(imgx,imgy)'). You should provide a third one such that I can check for correct scaling.}%
	},
	/pgfplots/warning/scatter classes no such class/.code={%
		\pgfplotsthrow@warning{scatter/classes: can't find class for '#1'!? Please make sure you have specified 'scatter src=explicit symbolic'. Ignoring class '#1' (this message will not come again).}%
	},
	/pgfplots/warning/lua colormap unavailable/.code={%
		\pgfplotsthrow@warning{there is no LUA colormap representation for #1. Using TeX arithmetics.}%
	},
	/pgfplots/warning/interior colormap inefficient/.code={%
		\pgfplotsthrow@warning{the combination 'shader=interp,interior colormap name' is inefficient (it uses 'shader=faceted interp,faceted color=none') and may slow down the *display* of your document}%
	},
	/pgfplots/warning/matrix delinearize uses sqrt/.code args={#1#2#3#4}{%
		\pgfplotsthrow@warning{%
									mesh processing did not find '[mesh/rows=<N>]' or '[mesh/cols=<N>]'. 
									Assuming [mesh/rows=#1,mesh/cols=#2] 
									as sqrt(num points) = sqrt(#3) [ = #4].}%
	},
	/pgfplots/warning/matrix check/.code args={#1#2#3#4#5}{%
		#1{the arguments of [mesh/rows=#2,mesh/cols=#3] assume  #5\space points, but I got actually N = #4\space points! The data matrix appears to be incomplete or overcomplete!? [Use mesh/check=false to disable this message]}%
	},
	/pgfplots/warning/tick computation failed/.code 2 args={%
		\pgfplotsthrow@warning{Tick computation for direction #1 failed; there are always too few tick labels (try min ticks has already been advanced to #2)}%
	},
	/pgfplots/warning/scale uniformly unsupported/.code={%
		\pgfplotsthrow@warning{Sorry, 'scale uniformly' failed because its actual implementation works only if y_x = 0 and x_y = 0 (for 2d axes) or if z_x = 0 (for 3d axes). The result will not fill the prescribed dimensions. Falling back to 'scale uniformly strategy=units only. (use scale uniformly warning=false to disable this warning)}%
	},
	/pgfplots/warning/axis equal incompatible change/.code={%
		\pgfplotsthrow@warning{the content of your 3d axis has changed compared to previous versions of pgfplots. please review it. ^^J   %
		[continued]   explanation: you have a 3d axis with 'axis equal' and/or 'unit vector ratio' which has (probably) been optimized for an older version of pgfplots. any version older than 1.6 produced wrong output.^^J   %
	[continued]	  to remove this warning, write \string\pgfplotsset{compat=1.6} (or newer) in your preamble (may change all figures in your document) or by adding that to the affected axis.}%
	},
	/pgfplots/warning/unit vector ratio axis undetermined/.code={%
		\pgfplotsthrow@warning{The algorithm to implement 'unit vector ratio' failed! It could not determine the axis which shall be scaled and decided to use 'unit vector ratio axis=#1'.}%
	},
	/pgfplots/warning/linear system singular/.code={%
		\pgfplotsthrow@warning{Linear system is singular up to machine precision! Continuing with small threshold.}%
	},
	/pgfplots/warning/center lines upgrade required/.code={%
		\pgfplotsthrow@warning{Please use '\string\pgfplotsset{compat=1.8}' to enable correct label placement for 3d axes (at least compat/labels=1.8).}%
	},
	/pgfplots/warning/empty column name/.code 2 args={%
		\pgfplotsthrow@warning{Table '#1' has an empty column name; replacing it by '#2'}%
	},
}
\let\pgfplotsexceptionmsg=\relax

\def\pgfplots@EOI{\pgfplots@EOI}%

\newif\ifpgfplots@loc@tmp
\newtoks\t@pgfplots@toka
\newtoks\t@pgfplots@tokb
\newtoks\t@pgfplots@tokc
\newdimen\pgfplots@tmpa
\newcount\c@pgfplots@coordindex
\newcount\c@pgfplots@scanlineindex
\pgfutil@IfUndefined{r@pgf@reada}{%
	\csname newread\endcsname\r@pgfplots@reada
}{%
	\let\r@pgfplots@reada=\r@pgf@reada
}

% use these macros for GLOBAL temporary assignments.
% you can NEVER rely on their values unless you know exactly what you are doing.
\gdef\pgfplots@glob@TMPa{}%
\gdef\pgfplots@glob@TMPb{}%
\gdef\pgfplots@glob@TMPc{}%

% use these macros for LOCAL temporary assigments.
% you can NEVER rely on their values unless you know exactly what you are doing.
\def\pgfplots@loc@TMPa{}%
\def\pgfplots@loc@TMPb{}%
\def\pgfplots@loc@TMPc{}%


% Invokes code #2 if file '#1' exists and #3 if not.
\long\def\pgfplots@iffileexists#1#2#3{%
	\openin\r@pgfplots@reada=#1
	\ifeof\r@pgfplots@reada
		#3\relax
	\else
		\closein\r@pgfplots@reada
		#2\relax
	\fi
}
\let\pgfplotsiffileexists=\pgfplots@iffileexists

\pgfutil@ifundefined{pgfplots@texdist@protect}{%
	\def\pgfplots@texdist@protect{}%
}{}

\input pgfplotssysgeneric.code.tex
\endinput