Tell me more ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

My next question follows on Sum up rows from different data files where I asked how to sum up the data from different files.

In this case I have e.g. two data files, consisting of m (here e.g. m=3) columns and a fixed number of rows n (here e.g. n=3), seperated by a semicolon (see minimal example):

What I want to plot in a tikzpicture is an elementwise division, e.g

Yvalues(1)=D1(1,2)/D2(1,3)
Yvalues(2)=D1(2,2)/D2(2,3)
Yvalues(3)=D1(3,2)/D2(3,3)
... for all n rows

The Xvalues shoud be the first column of one of the two loaded files (they are the same).

Maybe someone can use the defined makro 'mergetables' from the link above. Maybe the document could look something like this:

\documentclass{article}
\usepackage{pgfplots, pgfplotstable}
\usepackage{filecontents}

\begin{filecontents}{D1.txt}
0.1;10;10
0.2;20;12
0.3;30;14
\end{filecontents}

\begin{filecontents}{D2.txt}
0.1;3;5
0.2;3.5;10
0.3;4;15
\end{filecontents}

\begin{document}

\begin{tikzpicture}
\begin{axis}
    \addplot [Xvalues=first column of any file (D1 or D2),
              Yvalues= e.g. 2nd column of file D1 devided by 3rd column of file D2]
\end{axis} 
\end{tikzpicture}

\end{document}

edit:

My problem is to access to the single columns of each loaded file. In my oppinion the new command, lets call it again \mergetables, should look something like:

\mergetables{D1}{0,1}{D2}{2}..{Di}{col1,col2}{\datatable}

This command should create a new table \datatable with the first column D1(0), the second column D1(1) and the third column D2(2) seperated by a semicolon. Maybe each column of the new \datatable should have a columnname X,Y1,Y2,... so when I want to plot them I can call them using their columnames like:

\addplot table [x=X, y expr={Y1./Y2}] {\datatable};
share|improve this question
Could you edit your question to include a full minimal example document (starting from \documentclass)? It's not a whole lot of fun to piece something together, so it would be good if you could do that work to make it easier for others to try and help you. – Jake Feb 1 at 12:30
I hope my edit is what you asked me to do? – David K. Feb 1 at 12:39
The solution of Jake in tex.stackexchange.com/questions/93779/… appears to be quite general and should also work for this case. Did you run into into problems with the approach? – Christian Feuersänger Feb 2 at 19:47
@ Christian: I have to agree that the makro is quite general and it helped me a lot! (again thanks to Jake). I edited my question, so maybe my problem gets a little bit clearer. – David K. Feb 3 at 10:56

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.