I have parameter in a text file and I would like to create legend using those parameters. I have tried to read data with


and get specific parameter with


and then set macro with


and the create legend entry with

\addlegendentry{\pgfmathprintnumber[precision=5,use comma]{\parA}}

I have tried to do this with \foreach command and simply copy-pasting but neither one has succeeded.

One entry consist of multiple different elements from table.


Do you mean something like ...

% create a dummy file with some values
    0.1 0.2 0.3
    0.4 0.5 0.6
            % read the data table
            % create a loop and specify some indices that can be found
            % in the data file
            \foreach \i/\j in {
            % read the element in the data table and store it in `\param'
            % now create the plot and the corresponding legend entry
                \addplot {\param};
                    \pgfmathprintnumber[precision=5,use comma]{\param}

image showing the result of above code

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.