<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent posts to Gnuplot: Plotting from *txt files from different directories by reading column header</title><link>https://sourceforge.net/p/gnuplot/discussion/5924/thread/f44e412e8b/</link><description>Recent posts to Gnuplot: Plotting from *txt files from different directories by reading column header</description><atom:link href="https://sourceforge.net/p/gnuplot/discussion/5924/thread/f44e412e8b/feed.rss" rel="self"/><language>en</language><lastBuildDate>Tue, 04 Jun 2019 10:46:52 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/gnuplot/discussion/5924/thread/f44e412e8b/feed.rss" rel="self" type="application/rss+xml"/><item><title>Gnuplot: Plotting from *txt files from different directories by reading column header</title><link>https://sourceforge.net/p/gnuplot/discussion/5924/thread/f44e412e8b/?limit=25#65d4</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;My folder structure looks kind of like this&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;$ tree
.
├── Original_folder
│   └── cat.txt
├── folderCD
│   └── cat.txt
├── folderGK
│   └── cat.txt
├── folderFE
    └── cat.txt
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;Each cat.txt file has 5 line before starting the column header. &lt;br/&gt;
Sample cat.txt file is like this &lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;Version LRv1.10.0
Build date 2017-12-06
MOL-calc
PRESSURE
!                       
      Time[s]     InletT[K]   InletP[Pa]   O2_GasOut     C_GasOut
       100         0.000885   1000000       0.0007       0.2111
and so on....
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;I want to plot first column along with the column which have column header with a keyword "_GasOut". (There are unknown number of header with this keywords, For each column I would like to have a separate graph). Additionally, the graphical results of Original_folder should be plotted in the same graph for all the plots from folderCD, folderGK, folderFE...... and so on.&lt;/p&gt;
&lt;p&gt;Corresponding graph should be saved in the corresponding folders with a title same as column header. In each graph there should be two legend one is "original_folder" and another is "folderCD/folderGK/......"&lt;/p&gt;
&lt;p&gt;I got all the output plot commands for Original_folder in one txt file and plot commands for all the other folders into another txt file. After that I am not finding a way to go ahead..&lt;/p&gt;
&lt;p&gt;Here is the code &lt;/p&gt;
&lt;table class="codehilitetable"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td class="linenos"&gt;&lt;div class="linenodiv"&gt;&lt;pre&gt; 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21&lt;/pre&gt;&lt;/div&gt;&lt;/td&gt;&lt;td class="code"&gt;&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="ch"&gt;#!/bin/bash&lt;/span&gt;

gawk -F &lt;span class="s1"&gt;$'\t'&lt;/span&gt; &lt;span class="s1"&gt;'                                     # Using TABs as field separators&lt;/span&gt;
&lt;span class="s1"&gt;   /_GasOut/{                                       # On lines containing "_GasOut"&lt;/span&gt;
&lt;span class="s1"&gt;      for(f=1;f&amp;lt;=NF;f++){                           # ... iterate over all fields on line&lt;/span&gt;
&lt;span class="s1"&gt;         this=$f                                    # ... picking them up&lt;/span&gt;
&lt;span class="s1"&gt;         if(index(this,"_GasOut"))wanted[f]=1       # ... and noting which ones we want to print&lt;/span&gt;
&lt;span class="s1"&gt;      }&lt;/span&gt;
&lt;span class="s1"&gt;   }&lt;/span&gt;
&lt;span class="s1"&gt;   ENDFILE{                                         # As we reaach end of each file&lt;/span&gt;
&lt;span class="s1"&gt;      for(f in wanted){                             # ... iterate over wanted fields&lt;/span&gt;
&lt;span class="s1"&gt;         if(length(cmds)) cmds = cmds ",\n"         # ... adding commas and newlines if needed&lt;/span&gt;
&lt;span class="s1"&gt;         cmds = cmds "\"" FILENAME "\" using 1:" f  # ... and adding the "using" statement&lt;/span&gt;
&lt;span class="s1"&gt;      }&lt;/span&gt;
&lt;span class="s1"&gt;      delete wanted                                 # Forget list of wanted fields for next file&lt;/span&gt;
&lt;span class="s1"&gt;   }&lt;/span&gt;
&lt;span class="s1"&gt;   END{                                             # At very end of last file&lt;/span&gt;
&lt;span class="s1"&gt;      print cmds                                    # ... print accumulated gnuplot cmds&lt;/span&gt;
&lt;span class="s1"&gt;   }&lt;/span&gt;

&lt;span class="s1"&gt;   '&lt;/span&gt; folder*/cat.txt
&lt;/pre&gt;&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;

&lt;p&gt;The output txt file look like this &lt;br/&gt;
 ```&lt;br/&gt;
(Original_folder)&lt;br/&gt;
"Original_folder/cat.txt" using 1:22,&lt;br/&gt;
"Original_folder/cat.txt" using 1:23,&lt;br/&gt;
"Original_folder/cat.txt" using 1:24,&lt;br/&gt;
"Original_folder/cat.txt" using 1:25,&lt;br/&gt;
"Original_folder/cat.txt" using 1:26,&lt;br/&gt;
"Original_folder/cat.txt" using 1:27,&lt;br/&gt;
"Original_folder/cat.txt" using 1:28,&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;If the same code is used again for other folders.. the output is like this...
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;(Other folders)&lt;br/&gt;
"folderCD/cat.txt" using 1:22,&lt;br/&gt;
"folderCD/cat.txt" using 1:23,&lt;br/&gt;
"folderCD/cat.txt" using 1:24,&lt;br/&gt;
"folderCD/cat.txt" using 1:25,&lt;br/&gt;
"folderCD/cat.txt" using 1:26,&lt;br/&gt;
"folderCD/cat.txt" using 1:27,&lt;br/&gt;
"folderCD/cat.txt" using 1:28,&lt;br/&gt;
"folderGK/cat.txt" using 1:22,&lt;br/&gt;
"folderGK/cat.txt" using 1:23,&lt;br/&gt;
"folderGK/cat.txt" using 1:24,&lt;br/&gt;
"folderGK/cat.txt" using 1:25,&lt;br/&gt;
"folderGK/cat.txt" using 1:26,&lt;br/&gt;
"folderGK/cat.txt" using 1:27,&lt;br/&gt;
"folderGK/cat.txt" using 1:28&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;So i have all the command ready for gnuplot "plot" command, I just don't know how to arrange them to get a plot.

For example
for column 22 it is like 
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;gnuplot&amp;gt;plot "Original_folder/cat.txt" using 1:22, \
             "folderCD/cat.txt" using 1:22&lt;br/&gt;
```&lt;br/&gt;
How can I do this for all other cases ? And how to make the column header as title?&lt;br/&gt;
N.B: folder numbers are not fixed.&lt;br/&gt;
I added one of the cat.txt file for reference. &lt;a href="https://1drv.ms/t/s!Aoomvi55MLAQh1wMmpnPGnliFmgg" rel="nofollow"&gt;https://1drv.ms/t/s!Aoomvi55MLAQh1wMmpnPGnliFmgg&lt;/a&gt; &lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">Mohammed Atta</dc:creator><pubDate>Tue, 04 Jun 2019 10:46:52 -0000</pubDate><guid>https://sourceforge.netf3547489a32168630c5822617af8feff655a13b5</guid></item></channel></rss>