help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to plot two graphs with a textfile with a textdocument with two


From: Ron.Simonson
Subject: Re: How to plot two graphs with a textfile with a textdocument with two x two columns?
Date: Fri, 14 Mar 2014 15:29:04 -0700
User-agent: Mozilla/5.0 (X11; Linux i686 on x86_64; rv:10.0.6esrpre) Gecko/20120713 Thunderbird/10.0.6

On 03/14/2014 02:42 PM, Conrad Kopernikus wrote:
with some physic experiments with picoscope I get a textfile (.txt) with two
columns. But I have to graphs. My textfile look a littlebit like that:

The columns are larger in reality. But how to plot that? I delete the text
and copy the columns for the first graph in a new text-file and the second
in a new text-file.

If your goal is simply to plot this data then I would tend to use
sed and gnuplot rather than octave.  Octave is great for manipulating
data, gnuplot is good for plotting data.  My approach would be to
create a little sed script (or enter it on the command line) like
the following:

\begin{addcommentchar.sed}
sed -i '1,3 s/^/# /g' \
file1.dat \
file2.dat
\end{addcommentchar.sed}

where file1.dat and file2.dat contain the data you wish to plot.
Make addcomments.sed executable and run it.

Then build a gnuplot script, conrad.plt for example;

\begin{conrad.plt}
szTerm = 1
if(szTerm == 1) set term X11
if(szTerm == 2) set terminal pdf
if(szTerm == 3) set terminal png

set key bottom right
set grid

set pointsize 0.6
set xlabel "Time"
set ylabel "Volts"
set xrange [0:120]
set xtics 10
set mxtics 10
set yrange [5.0:9.0]
set ytics 0.5
set mytics 5
set format x "%0.0s%cs"
set format y "%0.1s%cV"
set title "Conrad's data plot\naddbegin.sed used to fix data files"

if(szTerm == 2) set output "conrad.pdf"
if(szTerm == 3) set output "conrad.png"

plot "file1.dat" using 1:($2/1000) title "Channel A" with linespoints, \
     "file2.dat" using 1:($2/1000) title "Channel B" with linespoints

if(szTerm == 1) pause -1
\end{conrad.plt}

Then run: gnuplot conrad.plt

Alter the above as required to get the plots looking like you want
them.  Setting szTerm to 2 will create a pdf file, set szTerm to
3 to get png files.

\begin{silly_comments}
Yes, I do recognize the oddity of including Hungarian notation in
a script written for use on a Linux machine.  Gnuplot is available
on m$ machines, I believe sed is also available on those machines.
\end{silly_comments}

Hope this helps.  Talk to you later.  Ron.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]