KristofferC / PGFPlotsX.jl

Plots in Julia using the PGFPlots LaTeX package
Other
301 stars 40 forks source link

Save plot data in external file (feature) #223

Open jebej opened 4 years ago

jebej commented 4 years ago

It can be convenient to save the plot data in an external file that is read in with table.

This option could be passed as a keyword argument to pgfsave.

tpapp commented 4 years ago

Sorry I don't understand. Can you please clarify with an example?

KristofferC commented 4 years ago

I think the request is to upon saving to .tex transform e.g.

table[row sep={\\}, x={Dof}, y={Err}]
{
    Dof  Err  \\
    1.0  2.0  \\
    2.0  1.0  \\
    4.0  0.1  \\
}

into

table[row sep={\\}, x={Dof}, y={Err}]
{
 data.dat
}

where data.dat would contain the data

    Dof  Err 
    1.0  2.0  
    2.0  1.0  
    4.0  0.1  

Would make for smaller .tex files.

jebej commented 4 years ago

Yes, exactly. The same as is implemented in matlab2tikz.

The only thing is to make sure to allow for a relative directory option, because latex will always read in files from the directory of the main file. Thus, if the tikz files are stored in another directory (e.g. /figures), we need to add that path to table[], even if the data files are in the same directory as the tikz files.

jguterl commented 1 year ago

Any chance this will be looked at? That would prevent having massive blocks of tikzpictures. This would require to add a method print_tex to dump table data into an external text file and print the path toward that file example: addplot[ybar interval, fill=red, fill opacity=0.2, draw=none, area legend] table[] {data_001.tsv};