Help answer threads with 0 replies.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
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.


  Search this Thread
Old 03-14-2007, 08:54 PM   #1
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:

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
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
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/ | sed -e "s*OUTPUT*atts_$FUN.eps*g" < \

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
Senior Member
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 55
Originally Posted by /tmp/data
20 bla
30:oh my god
./scrunch /tmp/data

scrunch script:
[[ "$1x" == "x" ]] && exit
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
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
Registered: Mar 2006
Location: Ekaterinburg, Russia
Distribution: Debian, Ubuntu
Posts: 703

Rep: Reputation: 423Reputation: 423Reputation: 423Reputation: 423Reputation: 423

If I understand your problem right, following approach may be useful:
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
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:
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
Registered: Feb 2005
Location: Bogotá, Colombia
Distribution: Slackware
Posts: 36

Rep: Reputation: 15
alternatives to gnuplot

have you tried PyX, or PyXPlot?


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 > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:26 AM.

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