diff options
author | Karl Berry <karl@freefriends.org> | 2017-06-05 23:09:50 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2017-06-05 23:09:50 +0000 |
commit | 327cd87d4221068ab573a3504626efee4617a231 (patch) | |
tree | 38428d40c974abbc49cc1a156e8c6eb1f0c7f20c /Master/texmf-dist/tex/generic/pgfplots/lua | |
parent | 3b20e2fc53faaae132472dfb561107e62079a95e (diff) |
pgfplots (5jun17)
git-svn-id: svn://tug.org/texlive/trunk@44469 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/generic/pgfplots/lua')
8 files changed, 205 insertions, 122 deletions
diff --git a/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots/binary.lua b/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots/binary.lua index 704778440bc..74c04b7409f 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots/binary.lua +++ b/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots/binary.lua @@ -12,7 +12,7 @@ else pgfplotsUnpack = unpack; end --- Takes a table containing an arbitrary number of integers in the range 0..255 and converts it +-- Takes a table containing an arbitrary number of integers in the range 0..255 and converts it -- into a binary stream of the corresponding binary chars. -- -- @param charIndices a table containing 0...N arguments; each in the range 0..255 diff --git a/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots/colormap.lua b/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots/colormap.lua index e0df003e724..73cbb2c894e 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots/colormap.lua +++ b/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots/colormap.lua @@ -13,6 +13,8 @@ local table=table do -- all globals will be read from/defined in pgfplots: local _ENV = pgfplots + +local pgftonumber = pgfluamathfunctions.tonumber ----------------------------------- ColorSpace = newClass() @@ -33,7 +35,8 @@ ColorMap.range =1000 -- colorspace: an instance of ColorSpace -- values: an array (1-based table) with color components. Each color component is supposed to be a table with K entries where K is colorspace:numComponents -- positions: either an empty array (in which case the colormap is uniform) or one position per value. Positions are in [0,1000] -function ColorMap:constructor( h, colorspace, values, positions) +-- scaleOrderZ the specific scaling factor used for 'colormap access=const' (or negative or the empty string if this is disabled) +function ColorMap:constructor( h, colorspace, values, positions, scaleOrderZ) if not h or not colorspace or not positions or not values then error("arguments must not be nil")end self.name = name @@ -42,6 +45,7 @@ function ColorMap:constructor( h, colorspace, values, positions) self.colorspace = colorspace self.values = values self.pos = positions + self:setScaleOrderZ(scaleOrderZ) local numComponents = self.colorspace.numComponents for i = 1,#self.values do @@ -52,24 +56,48 @@ function ColorMap:constructor( h, colorspace, values, positions) end end -function ColorMap:findPrecomputed(inMin, inMax, x) +function ColorMap:isUniform() + if #self.pos == 0 then + return true + else + return false + end +end + +function ColorMap:setScaleOrderZ(scaleOrderZ) + if type(scaleOrderZ) == "number" then + self.scaleOrderZ = scaleOrderZ + elseif #scaleOrderZ == 0 or type(scaleOrderZ) == "string" and scaleOrderZ == "h" then + -- special case which means "h" + self.scaleOrderZ = "h" + else + self.scaleOrderZ = pgftonumber(scaleOrderZ) + end +end + +function ColorMap:_transform(inMin, inMax, x) local transformed if inMin == 0 and inMax == ColorMap.range then transformed = x else - local scale = ColorMap.range / (inMax - inMin) + local scale = ColorMap.range / (inMax - inMin) transformed = (x - inMin) * scale end transformed = math.max(0, transformed) transformed = math.min(ColorMap.range, transformed) - + return transformed +end + +function ColorMap:findPrecomputed(inMin, inMax, x) + local transformed = self:_transform(inMin, inMax, x) + local divh = transformed * self.invh local intervalno = math.floor(divh) local factor = divh - intervalno local factor_two = 1-factor - + -- Step 2: interpolate the desired RGB value using vector valued interpolation on the identified interval if intervalno+1 == #self.values then -- ah- we are at the right end! @@ -90,6 +118,34 @@ function ColorMap:findPrecomputed(inMin, inMax, x) return result end +function ColorMap:findPiecewiseConst(inMin, inMax, x) + -- see docs in \pgfplotscolormapfindpiecewiseconst@precomputed@ for details + + local transformed = self:_transform(inMin, inMax, x) + local intervalno =-1 + if self:isUniform() then + if self.scaleOrderZ == "h" then + invh = self.invh + 0.001 + else + -- disable the extra interval + invh = self.invh + end + + local divh = transformed * invh + intervalno = math.floor(divh) + else + -- FIXME : IMPLEMENT + end + + if intervalno+1 == #self.values then + -- we have artificially increased the "h" (see the comments + -- above) -- meaning that this 'if' can happen. + -- ->Map the rightmost point to the rightmost interval: + return self.values[#self.values] + end + return self.values[intervalno+1] +end + ----------------------------------- -- global registry of all colormaps. diff --git a/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots/meshplothandler.lua b/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots/meshplothandler.lua index a3b492a5296..dba97aaf350 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots/meshplothandler.lua +++ b/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots/meshplothandler.lua @@ -90,7 +90,7 @@ function MeshPlothandler:reverseScanline(scanLineLength) tmp = coords[1+scanlineOff+i] coords[1+scanlineOff+i] = coords[reverseindex] coords[reverseindex] = tmp - + reverseindex = reverseindex-1 end end @@ -192,7 +192,7 @@ function MeshVisualizer:getVisualizationOutput() if self.isZBufferSort then result = self:applyZBufferSort(result) end - + return result end @@ -200,7 +200,7 @@ end function MeshVisualizer:applyZBufferSort(coords) -- in order to sort this thing, we need to compute the sort key (view depth) for each coord. -- furthermore, each list entry must be single patch... that means we need a (huge?) temporary table. - + local patchType = self.patchType local numVertices = patchType.numVertices @@ -225,7 +225,7 @@ function MeshVisualizer:applyZBufferSort(coords) -- STEP 2: assign the sort key: the "element depth". -- -- the "element depth" is defined to be the MEAN of all - -- vertex depths. + -- vertex depths. -- And since the mean is 1/n * sum_{i=1}^n V_i, we can -- directly omit the 1/n --- it is the same for every -- vertex anyway, and we only want to compare the depth @@ -241,7 +241,7 @@ function MeshVisualizer:applyZBufferSort(coords) local vertex = patchcoords[j] local vertexDepth = getVertexDepth(axis,vertex) - + sumOfVertexDepth = sumOfVertexDepth + vertexDepth end patch.elementDepth = sumOfVertexDepth @@ -270,7 +270,7 @@ end function MeshVisualizer:decodeIntoPatches(coords) local result = {} - + local scanLineLength = self.scanLineLength local length = #coords diff --git a/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots/pgfplotstexio.lua b/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots/pgfplotstexio.lua index bbce58d50c9..cffb518c925 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots/pgfplotstexio.lua +++ b/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots/pgfplotstexio.lua @@ -9,10 +9,10 @@ -- * TeX can call LUA methods in order to "do something". The reverse direction is not true: LUA cannot call TeX methods. -- -- * the only way that LUA can read TeX input values or write TeX output values is the top layer (at the time of this writing: only pgfplotstexio.lua ). --- --- * The LUA backend has one main purpose: scalability and performance. +-- +-- * The LUA backend has one main purpose: scalability and performance. -- Its purpose is _not_ to run a standalone visualization. --- +-- -- The precise meaning of "scalability" is: the LUA backend should do as much -- as possible which is done for single coordinates. Coordinates constitute -- "scalability": the number of coordinates can become arbitrarily large. @@ -20,13 +20,13 @@ -- "Performance" is related to scalability. But it is more: some dedicated -- utility function might have a TeX backend and will be invoked whenever it -- is needed. Candidates are colormap functions, z buffer arithmetics etc. --- +-- -- Thus, the best way to ensure "scalability" is to move _everything_ which is to be done for a single coordinate to LUA. -- --- Sometimes, this will be impossible or too expensive. +-- Sometimes, this will be impossible or too expensive. -- Here, "Performance" might still be optimized by some dedicated LUA function. -- --- +-- -- Unfortunately, the LUA backend does not simplify the code base - it makes it more complicated. -- This is due to the way it is used: one needs to know when the TeX backend -- delegates all its work to LUA. It is also due to the fact that it @@ -40,7 +40,7 @@ -- -- * \begin{axis}. It invokes \pgfplots@prepare@LUA@api . -- The purpose is to define the global pgfplots.gca "_g_et _c_urrent _a_xis" and to transfer some key presets. --- +-- -- Log message: "lua backend=true: Activating LUA backend for axis." -- -- * \end{axis}. It invokes \pgfplots@LUA@visualization@update@axis . @@ -73,7 +73,7 @@ -- entire processing to the LUA backend. If it succeeds, it will do -- nothing on the TeX side. -- --- Both PARTIAL MODE and COMPLETE MODE call +-- Both PARTIAL MODE and COMPLETE MODE call -- \pgfplots@LUA@survey@start : transfer plot type and current axis arguments to LUA -- and -- \pgfplots@LUA@survey@end : copy LUA axis arguments back to TeX. @@ -114,7 +114,7 @@ function texSurveyPoint(x,y,z,meta) pt.x[2] = y pt.x[3] = z pt.meta = meta - + gca.currentPlotHandler:surveypoint(pt) end @@ -125,7 +125,7 @@ function texSurveyAddJump() pt.x[2] = nil pt.x[3] = nil pt.meta = nil - + gca:addSurveyedJump(gca.currentPlotHandler, pt) end @@ -134,7 +134,7 @@ end function texSurveyEnd() local result = gca:surveyToPgfplots(gca.currentPlotHandler, true) --log("returning " .. result .. "\n\n") - + tex.sprint(LOAD_TIME_CATCODETABLE, result); gca.currentPlotHandler=nil end @@ -156,14 +156,14 @@ function texVisualizationInit(plotNum, plotIs3d) if not plotNum or plotIs3d==nil then error("arguments must not be nil") end local currentPlotHandler = gca.plothandlers[plotNum+1] - gca.currentPlotHandler = currentPlotHandler; + gca.currentPlotHandler = currentPlotHandler; if currentPlotHandler then currentPlotHandler.plotIs3d = plotIs3d currentPlotHandler:visualizationPhaseInit(); - tex.sprint("1") + tex.sprint("1") else -- ok, this plot has no LUA support. - tex.sprint("0") + tex.sprint("0") end end @@ -200,49 +200,56 @@ end function texApplyZBufferReverseScanline(scanLineLength) local currentPlotHandler = gca.currentPlotHandler if not currentPlotHandler then error("This function cannot be used in the current context") end - + currentPlotHandler:reverseScanline(scanLineLength) -end +end -- Modifies the Surveyed coordinate list. -- Expands to nothing function texApplyZBufferReverseTransposed(scanLineLength) local currentPlotHandler = gca.currentPlotHandler if not currentPlotHandler then error("This function cannot be used in the current context") end - + currentPlotHandler:reverseTransposed(scanLineLength) -end +end -- Modifies the Surveyed coordinate list. -- Expands to nothing function texApplyZBufferReverseStream() local currentPlotHandler = gca.currentPlotHandler if not currentPlotHandler then error("This function cannot be used in the current context") end - + currentPlotHandler:reverseStream(scanLineLength) -end +end -- Modifies the Surveyed coordinate list. --- +-- -- Note that this is UNRELATED to mesh/surface plots! They have their own (patch-based) z buffer. -- -- Expands to nothing function texApplyZBufferSort() local currentPlotHandler = gca.currentPlotHandler if not currentPlotHandler then error("This function cannot be used in the current context") end - + currentPlotHandler:sortCoordinatesByViewDepth() -end +end -- Modifies the Surveyed coordinate list. -- Expands to the resulting coordinates function texGetSurveyedCoordsToPgfplots() local currentPlotHandler = gca.currentPlotHandler if not currentPlotHandler then error("This function cannot be used in the current context") end - + tex.sprint(LOAD_TIME_CATCODETABLE, currentPlotHandler:surveyedCoordsToPgfplots(gca)) end +function texColorMapSetScaleOrderZ(mapName, scaleOrderZ) + local colormap = ColorMaps[mapName]; + if colormap then + colormap:setScaleOrderZ(scaleOrderZ) + end +end + -- Performance optimization: computes the colormap lookup. function texColorMapPrecomputed(mapName, inMin, inMax, x) local colormap = ColorMaps[mapName]; @@ -261,6 +268,24 @@ function texColorMapPrecomputed(mapName, inMin, inMax, x) end end +-- Performance optimization: computes the colormap lookup. +function texColorMapFindPiecewiseConst(mapName, inMin, inMax, x) + local colormap = ColorMaps[mapName]; + if colormap then + local result = colormap:findPiecewiseConst( + pgftonumber(inMin), + pgftonumber(inMax), + pgftonumber(x)) + + local str = "" + for i = 1,#result do + if i>1 then str = str .. "," end + str = str .. tostringfixed(result[i]) + end + tex.sprint(LOAD_TIME_CATCODETABLE, str) + end +end + local function isStripPrefixOrSuffixChar(char) return char == ' ' or char == '{' or char == "}" end @@ -343,7 +368,7 @@ do local domainMin = arg1 local h = arg2-arg1 local domainMax = arg3 - + -- round to the nearest integer (using +0.5, should be ok) local samples = math.floor((domainMax - domainMin)/h + 0.5) + 1 @@ -359,32 +384,32 @@ end -- generates TeX output '1' on success and '0' on failure -- @param debugMode one of a couple of strings: "off", "verbose", or "compileerror" function texAddplotExpressionCoordinateGenerator( - is3d, - xExpr, yExpr, zExpr, - sampleLine, - domainxmin, domainxmax, - domainymin, domainymax, - samplesx, samplesy, - variablex, variabley, + is3d, + xExpr, yExpr, zExpr, + sampleLine, + domainxmin, domainxmax, + domainymin, domainymax, + samplesx, samplesy, + variablex, variabley, samplesAt, debugMode ) local plothandler = gca.currentPlotHandler local coordoutputstream = SurveyCoordOutputStream.new(plothandler) - + if samplesAt and string.len(samplesAt) >0 then -- "samples at" has higher priority than domain. -- Use it! domainxmin, domainxmax, samplesx = samplesAtToDomain(samplesAt) if not domainxmin then - -- FAILURE: could not convert "samples at". + -- FAILURE: could not convert "samples at". -- Fall back to a TeX based survey. log("log", "LUA survey failed: The value of 'samples at= " .. tostring(samplesAt) .. "' is unsupported by the LUA backend (currently, only 'samples at={a,b,...,c}' is supported).\n") tex.sprint("0") return end - + else domainxmin= pgftonumber(domainxmin) domainxmax= pgftonumber(domainxmax) @@ -421,7 +446,7 @@ function texAddplotExpressionCoordinateGenerator( removeSurroundingBraces(expressions) local generator = AddplotExpressionCoordinateGenerator.new( - coordoutputstream, + coordoutputstream, expressions, domainMin, domainMax, samples, @@ -441,7 +466,7 @@ function texAddplotExpressionCoordinateGenerator( else error("Got unknown debugMode = " .. debugMode ) end - + local success if compileErrorOnFailure then success = generator:generateCoords() diff --git a/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots/pgfplotsutil.lua b/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots/pgfplotsutil.lua index b3b09fea688..40ac83bb385 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots/pgfplotsutil.lua +++ b/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots/pgfplotsutil.lua @@ -65,7 +65,7 @@ pgfplotsmath.infty = infty local nan = math.sqrt(-1) pgfplotsmath.nan = nan ---------------------------------------- +--------------------------------------- -- @@ -97,7 +97,7 @@ end --- Create a new class that inherits from a base class +-- Create a new class that inherits from a base class -- -- base = pgfplots.newClass() -- function base:constructor() diff --git a/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots/plothandler.lua b/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots/plothandler.lua index 218b08c5dd3..59dfbb2c774 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots/plothandler.lua +++ b/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots/plothandler.lua @@ -6,7 +6,7 @@ -- pgfplots.Axis -- pgfplots.Coord -- pgfplots.Plothandler --- +-- -- and some related classes. local math=math @@ -43,11 +43,11 @@ function Coord:copy(other) end function Coord:__tostring() - local result = '(' .. stringOrDefault(self.x[1], "--") .. - ',' .. stringOrDefault(self.x[2], "--") .. - ',' .. stringOrDefault(self.x[3], "--") .. + local result = '(' .. stringOrDefault(self.x[1], "--") .. + ',' .. stringOrDefault(self.x[2], "--") .. + ',' .. stringOrDefault(self.x[3], "--") .. ') [' .. stringOrDefault(self.meta, "--") .. ']' - + if not self.x[1] and self.unfiltered then result = result .. "(was " .. tostring(self.unfiltered) .. ")" end @@ -109,15 +109,15 @@ function PointMetaMap:map(meta) result = math.min(1000, result) return result else - if self.warnForfilterDiscards then + if self.warnForfilterDiscards then log("The per point meta data '" .. tostring(meta) .. " (and probably others as well) is unbounded - using the minimum value instead.\n") self.warnForfilterDiscards=false end return 0 end end - - + + ------------------------------------------------------- @@ -240,7 +240,7 @@ function Plothandler:surveypoint(pt) end end self.axis:datapointsurveyed(current, self) - + self.coordindex = self.coordindex + 1; end @@ -271,11 +271,11 @@ function Plothandler:getCoordsInTeXFormat(axis, coords, extraSerializer) return table.concat(result) end --- PRIVATE +-- PRIVATE -- -- does the same as \pgfplotsplothandlerserializepointto function Plothandler:serializeCoordToPgfplots(pt) - return + return toTeXstring(pt.x[1]) .. "," .. toTeXstring(pt.x[2]) .. "," .. toTeXstring(pt.x[3]) @@ -321,7 +321,7 @@ function Plothandler:sortCoordinatesByViewDepth() local vertexDepth = getVertexDepth(axis,coords[i]) coords[i].vertexDepth = vertexDepth end - + -- Step 2: sort (inplace) local comparator = function(ptA, ptB) return ptA.vertexDepth > ptB.vertexDepth @@ -372,7 +372,7 @@ end -- * visualize just plot marks at each of the collected coordinates -- * visualize just error bars at each collected coordinate -- * ... --- +-- -- this class offers basic visualization support. "Basic" means that it will merely transform and finalize input coordinates. PlotVisualizer = newClass() @@ -392,7 +392,7 @@ end -- -- @return any results. The format of the results is currently a list of Coord, but I am unsure of whether it will stay this way. -- --- Note that a PlotVisualizer does _not_ modify self.sourcePlotHandler.coords +-- Note that a PlotVisualizer does _not_ modify self.sourcePlotHandler.coords function PlotVisualizer:getVisualizationOutput() local result = {} local coords = self.sourcePlotHandler.coords @@ -407,7 +407,7 @@ function PlotVisualizer:getVisualizationOutput() local result_i local result_i = Coord.new() result_i:copy(coords[i]) - + if result_i.x[1] ~= nil then self:visphasegetpoint(result_i) else @@ -422,7 +422,7 @@ end -- PROTECTED -- resembles \pgfplotsplothandlervisualizejump -- or at least that part which can be done in LUA. --- It does not visualize anything, but it can be used to modify the coordinate +-- It does not visualize anything, but it can be used to modify the coordinate function PlotVisualizer:notifyJump(pt) -- do nothing. end @@ -486,7 +486,7 @@ end -- - the other input coordinates are already read. -- POSTCONDITION for '@assign': -- - \pgfplots@current@point@meta is ready for use: --- - EITHER a parsed floating point number +-- - EITHER a parsed floating point number -- - OR an empty string, -- - OR a symbolic string (if the issymbolic boolean is true) -- The default implementation is @@ -521,7 +521,7 @@ CoordAssignmentPointMetaHandler = newClassExtends( PointMetaHandler ) function CoordAssignmentPointMetaHandler:constructor(dir) PointMetaHandler.constructor(self, false,false) if not dir then error "nil argument for 'dir' is unsupported." end - self.dir=dir + self.dir=dir end function CoordAssignmentPointMetaHandler:assign(pt) @@ -561,7 +561,7 @@ function ExpressionPointMetaHandler:assign(pt) error("point meta=" .. self.expression .. ": expression has been rejected.") end end - + ------------------------------------------------------- @@ -580,12 +580,12 @@ end ------------------------------------------------------- --- An axis. +-- An axis. Axis = newClass() function Axis:constructor() self.is3d = false - self.clipLimits = true + self.clipLimits = { true, true, true} self.autocomputeAllLimits = true -- FIXME : redundant!? self.autocomputeMin = { true, true, true } self.autocomputeMax = { true, true, true } @@ -618,7 +618,7 @@ function Axis:getVertexDepth(pt) end if #vertex ~=3 then - error("Cannot compute vertex depth of " .. tostring(pt) .. ": expected a 3d point but got " .. tostring(#vertex)) + error("Cannot compute vertex depth of " .. tostring(pt) .. ": expected a 3d point but got " .. tostring(#vertex)) end if not viewdir or #viewdir~=3 then error("got unexpected view dir " ..tostring(viewdir) ) end @@ -704,7 +704,7 @@ end function Axis:validatecoord(dir, point) if not dir or not point then error("arguments must not be nil") end local result = pgftonumber(point.x[dir]) - + if result == nil then result = nil elseif result == pgfplotsmath.infty or result == -pgfplotsmath.infty or pgfplotsmath.isnan(result) then @@ -728,9 +728,9 @@ function Axis:parsecoordinate(pt, filterExpressionByDir) if pt.x[3] ~= nil then self.is3d = true end - + local result = Coord.new() - + local unfiltered = Coord.new() unfiltered.x = {} unfiltered.meta = pt.meta @@ -754,7 +754,7 @@ function Axis:parsecoordinate(pt, filterExpressionByDir) for i = 1,self:loopMax() do self:validatecoord(i, result) end - + local resultIsBounded = true for i = 1,self:loopMax() do if result.x[i] == nil then @@ -766,7 +766,7 @@ function Axis:parsecoordinate(pt, filterExpressionByDir) result.x = { nil, nil, nil} end - return result + return result end -- PROTECTED @@ -794,23 +794,23 @@ end -- @param pt an instance of Coord function Axis:updatelimitsforcoordinate(pt) local isClipped = false - if self.clipLimits then - for i = 1,self:loopMax(),1 do + for i = 1,self:loopMax(),1 do + if self.clipLimits[i] then if not self.autocomputeMin[i] then isClipped = isClipped or pt.x[i] < self.min[i] end if not self.autocomputeMax[i] then isClipped = isClipped or pt.x[i] > self.max[i] end - end + end end - + if not isClipped then for i = 1,self:loopMax(),1 do if self.autocomputeMin[i] then self.min[i] = math.min(pt.x[i], self.min[i]) end - + if self.autocomputeMax[i] then self.max[i] = math.max(pt.x[i], self.max[i]) end @@ -833,14 +833,14 @@ end -- -- unfinished, see its fixmes function Axis:addVisualizationDependencies(pt) - -- FIXME : 'visualization depends on' + -- FIXME : 'visualization depends on' -- FIXME : 'execute for finished point' return pt end -- PROTECTED -- --- indicates that a data point has been surveyed by the axis and that it can be consumed +-- indicates that a data point has been surveyed by the axis and that it can be consumed function Axis:datapointsurveyed(pt, plothandler) if not pt or not plothandler then error("arguments must not be nil") end if pt.x[1] ~= nil then @@ -882,7 +882,7 @@ function Axis:datapointsurveyed(pt, plothandler) end end end - + -- note that the TeX variant would increase the coord index here. -- We do it it surveypoint. end @@ -905,7 +905,7 @@ local function toTeXxyzCoord(namePrefix, pt ) local x = toTeXstring(pt.x[1]) local y = toTeXstring(pt.x[2]) local z = toTeXstring(pt.x[3]) - return + return "\\gdef" .. namePrefix .. "@x{" .. x .. "}" .. "\\gdef" .. namePrefix .. "@y{" .. y .. "}" .. "\\gdef" .. namePrefix .. "@z{" .. z .. "}"; @@ -942,8 +942,8 @@ function Axis:surveyToPgfplots(plothandler) local firstCoord = findFirstValidCoord(plothandler.coords) or Coord.new() local lastCoord = findLastValidCoord(plothandler.coords) or Coord.new() - local result = - plothandlerResult .. + local result = + plothandlerResult .. toTeXxyzCoord("\\pgfplots@currentplot@firstcoord", firstCoord) .. toTeXxyzCoord("\\pgfplots@currentplot@lastcoord", lastCoord) .. axisLimitToTeXString("\\pgfplots@metamin", plothandler.metamin) .. @@ -959,21 +959,21 @@ function Axis:surveyToPgfplots(plothandler) axisLimitToTeXString("\\pgfplots@zmax", self.max[3]) .. "\\global\\pgfplots@threedimtrue "; end - if plothandler.plotHasJumps then + if plothandler.plotHasJumps then result = result .. "\\def\\pgfplotsaxisplothasjumps{1}" else result = result .. "\\def\\pgfplotsaxisplothasjumps{0}" end - if plothandler.hasUnboundedPointMeta then + if plothandler.hasUnboundedPointMeta then result = result .. "\\def\\pgfplotsaxisplothasunboundedpointmeta{1}" else result = result .. "\\def\\pgfplotsaxisplothasunboundedpointmeta{0}" end - if plothandler.filteredCoordsAway then + if plothandler.filteredCoordsAway then result = result .. "\\def\\pgfplotsaxisfilteredcoordsaway{1}" else diff --git a/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots/statistics.lua b/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots/statistics.lua index 57350254b30..ff264858d0a 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots/statistics.lua +++ b/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots/statistics.lua @@ -42,7 +42,7 @@ function PercentileEstimator:getIndex(data, i) end return result end - + -- @param percentile the requested percentile. Use 0.5 for the median, 0.25 for the first quartile, 0.95 for the 95% percentile etc. function PercentileEstimator:getValue(percentile, data) @@ -65,8 +65,8 @@ function LegacyPgfplotsPercentileEstimator:getValue(percentile, data) local offset_low = mathfloor(h) local isInt = ( h==offset_low ) - local offset_high = offset_low+1 - + local offset_high = offset_low+1 + local x_low = self:getIndex(data, offset_low) local x_up = self:getIndex(data, offset_high) local res = x_low @@ -92,8 +92,8 @@ function LegacyBadPgfplotsPercentileEstimator:getValue(percentile, data) local offset_low = mathfloor(h) local isInt = ( h==offset_low ) - local offset_high = offset_low+1 - + local offset_high = offset_low+1 + local x_low = self:getIndex(data, offset_low+1) local x_up = self:getIndex(data, offset_high+1) local res = x_low @@ -122,39 +122,39 @@ function ParameterizedPercentileEstimator:constructor( typeFlag ) local x_up = getIndex(self, data, h_low +1 ) return x_low + (h - h_low) * (x_up - x_low) end - + if typeFlag == 1 then - -- R1 + -- R1 self.getValue = function(self, percentile, data) local h= #data * percentile return getIndex(self, data, mathceil(h) ) end elseif typeFlag == 2 then - -- R2 + -- R2 self.getValue = function(self, percentile, data) local h= #data * percentile + 0.5 return 0.5*(getIndex(self, data, mathceil(h-0.5)) + getIndex(self, data, mathfloor(h+0.5) ) ) end elseif typeFlag == 3 then - -- R3 + -- R3 self.getValue = function(self, percentile, data) local h= #data * percentile return getIndex(self, data, pgfluamathfunctions.round(h) ) end elseif typeFlag == 4 then - -- R4 + -- R4 self.getValue = function(self, percentile, data) local h= #data * percentile return stdLookup(data,h) end elseif typeFlag == 5 then - -- R5 + -- R5 self.getValue = function(self, percentile, data) local h= #data * percentile + 0.5 return stdLookup(data,h) end elseif typeFlag == 6 then - -- R6 + -- R6 self.getValue = function(self, percentile, data) local h= (#data +1) * percentile return stdLookup(data,h) @@ -166,13 +166,13 @@ function ParameterizedPercentileEstimator:constructor( typeFlag ) return stdLookup(data,h) end elseif typeFlag == 8 then - -- R8 + -- R8 self.getValue = function(self, percentile, data) local h= (#data + 1/3) * percentile + 1/3 return stdLookup(data,h) end elseif typeFlag == 9 then - -- R9 + -- R9 self.getValue = function(self, percentile, data) local h= (#data + 1/4) * percentile + 3/8 return stdLookup(data,h) @@ -183,7 +183,7 @@ function ParameterizedPercentileEstimator:constructor( typeFlag ) end -getPercentileEstimator = function(estimatorName) +getPercentileEstimator = function(estimatorName) if estimatorName == "legacy" then return LegacyPgfplotsPercentileEstimator.new() elseif estimatorName == "legacy*" then @@ -251,7 +251,7 @@ end -- @return an instance of BoxPlotResponse function boxPlotCompute(boxPlotRequest, data) if not boxPlotRequest or not data then error("Arguments must not be nil") end - + for i = 1,#data do local data_i = data[i] if data_i == nil or type(data_i) ~= "number" then @@ -265,7 +265,7 @@ function boxPlotCompute(boxPlotRequest, data) for i = 1,#data do sum = sum + data[i] end - + local numCoords = #data local lowerWhisker @@ -321,7 +321,7 @@ function boxPlotCompute(boxPlotRequest, data) end ------------------------------------------------------- --- Replicates the survey phase of \pgfplotsplothandlerboxplot +-- Replicates the survey phase of \pgfplotsplothandlerboxplot BoxPlotPlothandler = newClassExtends(Plothandler) -- drawDirection : either "x" or "y". @@ -355,17 +355,17 @@ function BoxPlotPlothandler:surveyend() local computed = boxPlotCompute( self.boxPlotRequest, self.boxplotInput ) - local texResult = + local texResult = "\\pgfplotsplothandlersurveyend@boxplot@set{lower whisker}{" .. toTeXstring(computed.lowerWhisker) .. "}" .. "\\pgfplotsplothandlersurveyend@boxplot@set{lower quartile}{" .. toTeXstring(computed.lowerQuartile) .. "}" .. "\\pgfplotsplothandlersurveyend@boxplot@set{median}{" .. toTeXstring(computed.median) .. "}" .. "\\pgfplotsplothandlersurveyend@boxplot@set{upper quartile}{" .. toTeXstring(computed.upperQuartile) .. "}" .. "\\pgfplotsplothandlersurveyend@boxplot@set{upper whisker}{" .. toTeXstring(computed.upperWhisker) .. "}" .. "\\pgfplotsplothandlersurveyend@boxplot@set{sample size}{" .. toTeXstring(# self.boxplotInput) .. "}" - + self.boxplotInput = nil Plothandler.surveystart(self) - + local outliers = computed.outliers for i =1,#outliers do local outlier = outliers[i] diff --git a/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots/streamer.lua b/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots/streamer.lua index ab5b605d6d1..39baf5ceca1 100644 --- a/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots/streamer.lua +++ b/Master/texmf-dist/tex/generic/pgfplots/lua/pgfplots/streamer.lua @@ -49,7 +49,7 @@ function AddplotExpressionCoordinateGenerator:constructor(coordoutputstream, exp self.domainMax = domainMax self.samples = samples self.variableNames = variableNames - + -- log("initialized " .. tostring(self) .. "\n") end @@ -57,7 +57,7 @@ end -- this method is a replicate of \pgfplots@addplotimpl@expression@@ function AddplotExpressionCoordinateGenerator:generateCoords() local stringToFunctionMap = pgfluamathfunctions.stringToFunctionMap - -- create a backup of the 'x' and 'y' math expressions which + -- create a backup of the 'x' and 'y' math expressions which -- have been defined in \pgfplots@coord@stream@start: local old_global_function_x = stringToFunctionMap["x"] local old_global_function_y = stringToFunctionMap["y"] @@ -78,10 +78,10 @@ function AddplotExpressionCoordinateGenerator:generateCoords() end local variableNames = self.variableNames - + local x,y local sampleLine = #samples==1 - + local function pseudoconstantx() return x end local pseudoconstanty if sampleLine then @@ -125,8 +125,10 @@ function AddplotExpressionCoordinateGenerator:generateCoords() local Z = nil if is3d then Z = pgfmathparse(zExpr) + else + -- FIXME BUG: we need to do something else with 'Z' if this is a 2d plot inside of a 3d axis! end - + local pt = Coord.new() pt.x = { X, Y, Z} @@ -137,7 +139,7 @@ function AddplotExpressionCoordinateGenerator:generateCoords() coordoutputstream:coord(pt) end - + if not sampleLine then local xmin = domainMin[1] local ymin = domainMin[2] @@ -167,7 +169,7 @@ function AddplotExpressionCoordinateGenerator:generateCoords() computeXYZ() end end - + stringToFunctionMap[variableNames[1]] = nil stringToFunctionMap[variableNames[2]] = nil return true @@ -181,10 +183,10 @@ function AddplotExpressionCoordinateGenerator:__tostring() result = result .. self.expressions[i] ..", " end result = result .. "\n domain=" .. self.domainMin[1] .. ":" .. self.domainMax[1] - result = result .. "\n samples=" .. self.samples[1] + result = result .. "\n samples=" .. self.samples[1] if #self.domainMin == 2 then result = result .. "\n domain y=" .. self.domainMin[2] .. ":" .. self.domainMax[2] - result = result .. "\n samples y=" .. self.samples[2] + result = result .. "\n samples y=" .. self.samples[2] end result = result .. "]" return result |