LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 07-29-2008, 10:24 PM   #1
Meson
Member
 
Registered: Oct 2007
Distribution: Arch x86_64
Posts: 606

Rep: Reputation: 67
gnuplot - do multiple plots from data file with built-in commands


Say I have the file testplot.p:

Code:
set xrange [-10,10]

plot "-" using 1:2 w l notitle, \
     "-" using 1:3 w l notitle

#col1 col2 col3
-10   100  -1000
-05    25   -250
  0     0      0
 05    25    250
 10   100   1000
end
What tends to happen is that I get an error if I try to plot from this data more than once. This will work:

Code:
set xrange [-10,10]

plot "-" using 1:3 w l notitle

#col1 col2 col3
-10   100  -1000
-05    25   -250
  0     0      0
 05    25    250
 10   100   1000
end
 
Old 07-30-2008, 03:44 PM   #2
BrianK
Senior Member
 
Registered: Mar 2002
Location: Los Angeles, CA
Distribution: Debian, Ubuntu
Posts: 1,334

Rep: Reputation: 51
Quote:
Originally Posted by Meson View Post
Say I have the file testplot.p:
...

What tends to happen is that I get an error if I try to plot from this data more than once. This will work:
'-' is a special character that denotes standard in. This is to say that when you use '-' as a data source, your script will expect input from standard in which usually either user input or redirected script. In interactive gnuplot, it will give you a prompt asking for stdin.

The problem with the above example is that you're reading two instances of stdin which means that after you give it an "end" to signal the end of stdin, there's a second '-' that expects another stdin.

The solution then would be either to send the dataset to your script twice, i.e.:

Code:
plot '-' using ..., '-' using ...

data
data
data
end

data
data
data
end
or, better yet, is to use a file in place of '-', i.e.

Code:
plot 'some_file' using ..., 'some_file' using...
and then keep the data in a file. If the data is in a file, there's no need to use the keyword "end" as EOF signals the end of input.
 
Old 07-30-2008, 03:52 PM   #3
ne pas
Member
 
Registered: Jul 2008
Posts: 55

Rep: Reputation: 23
Quote:
What tends to happen is that I get an error if I try to plot from this data more than once.
Can't see an error message
Let me guess, it's
Quote:
warning: Skipping data file with no valid points
that's because after the first plot you're already at the end of your inline data, so there is nothing to read for the second plot.
That's the same with replot:
gnuplot>help datafile special-filenames
Quote:
[...]
If you use `'-'` with `replot`, you may need to enter the data more than once
(see `replot`).
[...]
If you use a datafile instead of "-" it should work as expected
Code:
set xrange [-10:10]

plot "datafile" using 1:2 notitle with lines, \
     "datafile" using 1:3 notitle with lines

Last edited by ne pas; 07-30-2008 at 03:54 PM. Reason: hmpf... I took to long
 
  


Reply



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
gnuplot, pull X data from file, specify Y data at cmd line? hedpe Programming 5 03-15-2007 11:32 PM
gnuplot: how to label x-axis with strings from data file? hedpe Linux - Software 2 07-11-2006 10:21 AM
manipulate dcop data for File commandS? carl0ski Programming 2 07-02-2005 08:46 PM
GLIBC_2.3.4 not defined in file libc.so.6 when running gnuplot azariaya Linux - Software 7 01-05-2005 04:57 PM
How to export graph as JPG file in Gnuplot ninja Linux - Software 1 05-30-2003 09:20 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 05:42 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration