[NTG-context] Pgfplots - "reverse legend" by Lua

Aditya Mahajan adityam at umich.edu
Tue Dec 22 17:36:55 CET 2015

On Tue, 22 Dec 2015, Procházka Lukáš Ing. - Pontex s. r. o. wrote:
> \starttikzpicture
>    %\startaxis[legend entries={Cos,Sin2,Sin},reverse legend]
>    \cldcommand{startaxis{["legend entries"] = "{Cos,Sin2,Sin}", "reverse
>    legend"}}

This is not valid lua. On a lua prompt, try

t = {["legend entries"]="{Cos,Sin2,Sin}", "reverse legend"}

you get

stdin:1: table index is nil
stack traceback:
         stdin:1: in main chunk
         [C]: in ?

One can define a lua table using

{[key]=value, [key]=value, ... } etc


{value1, value2, ...} etc.

Mixing the two is not allowed.

In ConTeXt, the two are not mixed. But tikz (and pgfplot) freely mix the 
two syntax. So, one way to get the result using lua is (untested)

\ctxlua{"\\startaxis[legend entries={Cos,Sin2,Sin}, reverse legend]"}

where, if needed, you can build the string using string.format.


More information about the ntg-context mailing list