3

I include plots using matlab2tikz to generate tikz-files. There was a nice feature added which enables external datasets. A file plot.tikz is generated with the following code (unnecessary code is skipped):

\begin{tikzpicture}
\begin{axis}
\addplot table[row sep=crcr]{plot-1.tsv};
\end{axis}
\end{tikzpicture}%

plot-1.tsv is located in the same directory as plot.tikz and has the following content

0   1.10061021788087
0.1 1.54421189550395

In my latex directory I have my figures organized in /fig/chapterXX I have a custom command with which I include my figures: \includetikz{folder}{tikz-file}, e.g. \includetikz{fig/chapter3}{plot} (this custom command includes the file plot.tikz with the \input{}-command)

My problem is now: Latex expects the file plot-1.tsv relative to its tex-file. If I want to get it to run, I need to manually change the \addplot in the file plot.tikz to \addplot table[row sep=crcr]{fig/chapter3/plot-1.tsv};. I have to do this in each tikz-file and I need to know in advance where I will put the tikz-file.

Is it possible to tell pgfplots that plot-1.tsv is relative to the file plot.tikz?

bene
  • 2,090
  • Because you're iteratively referring in the same fashion to the same kind of figure at the same location, I'd aim towards, say, \newcommand{\myinsertplot}[1]{\addplot table[row sep=crcr] {fig/chapter3/#1.tsv};}. – 1010011010 Oct 17 '14 at 09:05
  • If I understand you correctly, here I'm having the same problem as before, that I manually have to set the folder structure for the datasets of my plot. I like the feature that I have separate tikz-files for my plots and the new feature of matlab2tikz for external datasets is also appealing for me but If I always manually have to change the folder within the tikz-file, this won't help me. – bene Oct 17 '14 at 09:10
  • Does it work when you include the .tikz file with \subimport from the import package, instead of \input? See http://tex.stackexchange.com/a/60227/12440 – Fritz Oct 17 '14 at 09:20
  • unfortunately, using \import or \subimport it is not working. I guess, it is because of pgf which loads the tsv-file within the tikz-file using the \addplot-command. – bene Oct 17 '14 at 10:44
  • I almost got what I want using the syntax shown in this question here: http://tex.stackexchange.com/questions/160882/subimport-issues-tikz-addplot The only drawback is, that I manually have to change each \addplot-command like this: \addplot table[row sep=crcr]{\relativepath plot-1.tsv}; – bene Oct 17 '14 at 12:55
  • @bene, as an alternative to specifying the path relatively, how about using the table/search path option that was introduced in PGFPlots v1.13 and works similar to \graphicspath? (Have a look at http://tex.stackexchange.com/questions/35863/pgfplots-from-file-search-path-looking-for-graphicspath-equivalent for more details.) – Stefan Pinnow Nov 02 '16 at 22:54

0 Answers0