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
|
%--------------------------------------------
%
% 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-2021 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/>.
\ifpgfplots@LUA@supported
\pgfplotsutil@directlua{require("prepcontour");}
\pgfplotsset{
contour lua/.style={
contour external={%
% we decided to NOT precompute contour/levels:
% @before cmd=\pgfplotscontourpopulateallkeys,
scanline marks=required,
script type=lua,
%
% this library consumes FOUR coordinates...
script input format=x y z meta,
% ... and it also generates FOUR. Always read the last one
% as it is never subject to rounding issues within the
% same contour line:
output point meta=explicit,
%
script={
copylines = 0;
nblocks = \if 0\ordering \pgfkeysvalueof{/pgfplots/mesh/rows}\else \pgfkeysvalueof{/pgfplots/mesh/cols}\fi;
nlines = \if 0\ordering \pgfkeysvalueof{/pgfplots/mesh/cols}\else \pgfkeysvalueof{/pgfplots/mesh/rows}\fi;
if copylines == nil or nblocks == nil or nlines == nil then
io.stderr:write("failed to parse arguments");
os.exit(2);
end;
yvaries = \if 0\ordering 'x'\else 'y'\fi;
yvaries = (yvaries == 'y');
infile = io.open(\"\infile\", \"r\");
outfile = io.open(\"\outfile\", \"w\");
mesh = PrepcMesh.new(yvaries, nblocks, nlines, copylines, infile, outfile);
\ifpgfplotsplothandlercontour@corners
corners = true;
\else
corners = false;
\fi
\ifx\thecontourlevels\pgfutil@empty
mesh:autocontour(\thecontournumber, \pgfplotsmetamin, \pgfplotsmetamax, corners);
\else
levels = {\thecontourlevels};
for n = 1, \#levels do
level = tonumber(levels[n]);
if level then
mesh:contour(level, corners);
end;
end;
\fi
io.close(infile);
mesh:printcontours();
io.close(outfile);
},%
#1,%
},
}
}
\else
% do not throw the exception at load time ... this library is
% included as default
\pgfplotsset{
contour lua/.code={
\pgfplots@error{Library 'contour lua' requires you to run in LUA mode (i.e. lualatex instead of pdflatex)}%
}
}
\fi
|