LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 03-14-2007, 08:54 PM   #1
hedpe
Member
 
Registered: Jan 2005
Location: Pittsburgh
Distribution: Ubuntu
Posts: 378

Rep: Reputation: 30
gnuplot, pull X data from file, specify Y data at cmd line?


Hey all,

I was wondering if its possible with gnuplot, for me to pull the X axis points from a file while plotting, but on the gnuplot command line specify Y for all points. Something like this:

Code:
plot "data/flood" Y 3 with linespoints title "degree_in"
that would get all of the X-axis data points from data/flood and use Y=3 for all of the points. Is this possible some how? You might say to simply add 3 to the file for all of the points, but I have different plots which will be using this same file for which I want the Y to be different. So I was hoping to be able to specify it on the cmd line
 
Old 03-14-2007, 10:34 PM   #2
nmh+linuxquestions.o
Member
 
Registered: Feb 2007
Posts: 135

Rep: Reputation: 15
I have seen no indications that this is possible, and so when I want to do something similar to this, I use python and have it do whatever processing I want, and then use gnuplot just for plotting.
 
Old 03-15-2007, 01:33 AM   #3
alesz
Member
 
Registered: Mar 2005
Distribution: FC5 on disk, Knoppix as LiveCD
Posts: 48

Rep: Reputation: 15
I have had a similar/almost same problem many times. But in the end, i ended creating a file or a stream by sed, awk or any other program and then piping it to gnuplot, e.g. this one is from 2 days ago:

cat ../../input/gnuplot-att2d.in | sed -e "s*OUTPUT*atts_$FUN.eps*g" < gnuplot-att2d.in \
gnuplot

Here i was only changing the EPS output file name, but I am sure that you can understand my approach. Btw. if you perhaps need to concatenate columns within input file, use "paste" unix command.
 
Old 03-15-2007, 05:27 AM   #4
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 52
Quote:
Originally Posted by /tmp/data
1
2
5
10
20 bla
30:oh my god
./scrunch /tmp/data

scrunch script:
Code:
[[ "$1x" == "x" ]] && exit
tmp=`mktemp`
cat > $tmp << EOF
set terminal postscript eps colour
set output "scrunch.eps"
set yrange [0:5]
set xlabel "Data"
set ylabel "Flood"
plot \
"<awk -F'=| |:' '{print \$1\" \"3}' $1"  using 1:2 title "degree_in" with lines
EOF
gnuplot < $tmp
rm $tmp
Now you should have scrunch.eps in current directory

Last edited by nx5000; 03-15-2007 at 05:29 AM.
 
Old 03-15-2007, 08:56 AM   #5
firstfire
Member
 
Registered: Mar 2006
Location: Ekaterinburg, Russia
Distribution: Debian, Ubuntu
Posts: 623

Rep: Reputation: 364Reputation: 364Reputation: 364Reputation: 364
Hello!

If I understand your problem right, following approach may be useful:
Code:
gnuplot> plot "<(awk '{print $4,$3}' u-log-10)" w l
Here I'm filter out 4th and 3rd columns from file u-log-10 (awk '{print $4, $3}' u-log-10), and then plot this data with style `lines'. As I understand, gnuplot syntax
Code:
plot "< source-of-data"
allows to plot the data from standard output of any program (e.g. `plot "<seq 10" ' will plot the straight line).

So you can plot all points from "data/flood" being projected to the line y=3 as follows:
Code:
plot "< awk '{print $1, 3}' data/flood" with linespoints title "degree_in"
P.S.: I suggest you to take a look at plotutils package. Using `graph' util from there may be much more handy in noninteractive mode.
 
Old 03-15-2007, 11:32 PM   #6
julot
Member
 
Registered: Feb 2005
Location: Bogotá, Colombia
Distribution: Slackware
Posts: 36

Rep: Reputation: 15
alternatives to gnuplot

have you tried PyX, or PyXPlot?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
I made a program that can pull data off a large web site 20 times a day halfpower General 12 11-18-2006 08:38 PM
gnuplot: how to label x-axis with strings from data file? hedpe Linux - Software 2 07-11-2006 10:21 AM
Bios data via Cmnd Line esage MEPIS 6 06-07-2006 02:21 PM
using DD to pull records out of a data file fhinkle Linux - Newbie 6 02-24-2005 04:20 PM
WP for cmd-line data merging & printing? MikHud Linux - Software 0 11-06-2002 02:36 AM


All times are GMT -5. The time now is 10:22 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration