plotting multiple graph from nultiple data set within one data file

plotting multiple graph from nultiple data set within one data file

Post by KA MOHD-NAS » Fri, 31 May 1996 04:00:00



Dear Gnuplot users

Hi, I am new to Gnuplot. Sorry, if this question is very basic. I have multiple data set as shown below;

Crossection # 1 at Chainage 200
x= 0.000000  y=29.889000 x= 0.000000  y=29.889000
xl= -4.415000 yl= 32.048000 xr=4.435000 yr=32.223000
xl= -7.742000 yl= 34.627998 xr=7.462000 yr=34.772999
xl= -13.294000 yl= 37.702999 xr=12.367000 yr=37.522999
xl= -14.055000 yl= 37.608002 xr=13.885000 yr=37.563000

Crossection # 2 at Chainage 400
x= 0.000000  y=29.889000 x= 0.000000  y=29.889000
xl= -2.599000 yl= 30.469999 xr=2.150000 yr=29.982000
xl= -5.717000 yl= 31.392000 xr=6.683000 yr=30.402000
xl= -10.227000 yl= 34.152000 xr=8.963000 yr=33.062000
xl= -10.227000 yl= 34.152000 xr=9.021000 yr=33.266998
xl= -10.227000 yl= 34.152000 xr=9.655000 yr=33.722000

I would like to write a script that would take the first line as the title of the graph and the following data as points on a graph. The second data set is seperated by the null lines. How can I view the plotted graph each at a time. The script I wrote will put both data sets on one graph. I tried to use pause -1 but it didn't work. Can anyone help me solve these problems
1) to automatically read charaters from my data file and set it as title, and
2) to plot seperate graphs from seperate data sets, and to view the graphs one at each time.

Thanks in advance for your help.
Cheers,
Kamarul

 
 
 

plotting multiple graph from nultiple data set within one data file

Post by David Denho » Fri, 31 May 1996 04:00:00



> Dear Gnuplot users
> Hi, I am new to Gnuplot. Sorry, if this question is very basic. I have multiple data set as shown below;
> Crossection # 1 at Chainage 200
> x= 0.000000  y=29.889000 x= 0.000000  y=29.889000
> xl= -4.415000 yl= 32.048000 xr=4.435000 yr=32.223000
> xl= -7.742000 yl= 34.627998 xr=7.462000 yr=34.772999
> xl= -13.294000 yl= 37.702999 xr=12.367000 yr=37.522999
> xl= -14.055000 yl= 37.608002 xr=13.885000 yr=37.563000
> Crossection # 2 at Chainage 400
> x= 0.000000  y=29.889000 x= 0.000000  y=29.889000
> xl= -2.599000 yl= 30.469999 xr=2.150000 yr=29.982000
> xl= -5.717000 yl= 31.392000 xr=6.683000 yr=30.402000
> xl= -10.227000 yl= 34.152000 xr=8.963000 yr=33.062000
> xl= -10.227000 yl= 34.152000 xr=9.021000 yr=33.266998
> xl= -10.227000 yl= 34.152000 xr=9.655000 yr=33.722000
> I would like to write a script that would take the first line as the title of the graph and the following data as points on a graph. The second data set is seperated by the null lines. How can I view the plotted graph each at a time. The script I wrote will put both data sets on one graph. I tried to use pause -1 but it didn't work. Can anyone help me solve these problems
> 1) to automatically read charaters from my data file and set it as title, and

gnuplot cannot do this, but you could do it with a shell filter

Quote:> 2) to plot seperate graphs from seperate data sets, and to view the graphs one at each time.

version 3.6 offers an index command :  plot 'file' index 0  (?) would
plot points only until the first double-blank-line

But gnuplot is not going to like your files very much ; it likes
space-separated columns of numbers. If it can't have that, you
can give it a c scanf format such as 'xl= %lf yl= %lf xr=%lf yr=%lf'
but here, you dont have the same pattern on each line either.

dd
--

Tel (01494) 453376 (work)    (01494) 459742  (home)

 
 
 

plotting multiple graph from nultiple data set within one data file

Post by Gary Ho » Fri, 31 May 1996 04:00:00



writes:

   Hi, I am new to Gnuplot. Sorry, if this question is very basic. I have
multiple data set as shown below:

   Crossection # 1 at Chainage 200
   x= 0.000000  y=29.889000 x= 0.000000  y=29.889000
   xl= -4.415000 yl= 32.048000 xr=4.435000 yr=32.223000
   xl= -7.742000 yl= 34.627998 xr=7.462000 yr=34.772999
   xl= -13.294000 yl= 37.702999 xr=12.367000 yr=37.522999
   xl= -14.055000 yl= 37.608002 xr=13.885000 yr=37.563000

   Crossection # 2 at Chainage 400
   x= 0.000000  y=29.889000 x= 0.000000  y=29.889000
   xl= -2.599000 yl= 30.469999 xr=2.150000 yr=29.982000
   xl= -5.717000 yl= 31.392000 xr=6.683000 yr=30.402000
   xl= -10.227000 yl= 34.152000 xr=8.963000 yr=33.062000
   xl= -10.227000 yl= 34.152000 xr=9.021000 yr=33.266998
   xl= -10.227000 yl= 34.152000 xr=9.655000 yr=33.722000

   I would like to write a script that would take the first line as the title
   of the graph and the following data as points on a graph. The second data
   set is seperated by the null lines. How can I view the plotted graph each at
   a time. The script I wrote will put both data sets on one graph. I tried to
   use pause -1 but it didn't work. Can anyone help me solve these problems 1)
   to automatically read charaters from my data file and set it as title, and
   2) to plot seperate graphs from seperate data sets, and to view the graphs
   one at each time.

You don't say in what language you are writing your script.  I wrote a simple
script in perl which will do what you want.  (If you don't have perl, talk to
your system manager.)  I'm assuming you're on a unix platform so I can use
pipes.  If not, it's a bit more complicated.

#!/usr/local/bin/perl
#
# Convert data file format into something viewable by gnuplot.  Usage:
#   perl data_reformat.pl infile
# This will start up gnuplot for you, and prompt you to press return after
# each file is displayed.
#
open(GNUPLOT, "| gnuplot") || die("$0: can't open pipe to gnuplot--$!\n");
                                # Start up gnuplot.
$old_fh = select(GNUPLOT); $| = 1; select($old_fh);
                                # Turn on autoflush on the gnuplot pipe.
                                # If you don't do this, gnuplot won't see what
                                # you send it immediately.
$| = 1;                         # Turn on autoflush on stdout.

print GNUPLOT "set nokey\n";  # The legends aren't going to be useful.

$/ = '';                        # Read in paragraph mode.  This means that
                                # records are separated by blank lines.
                                # Thus we read in a whole data set as one
                                # record.
while ($_ = <>) {
    ($title) = m/^(.*)\s+\n/;   # Extract the title from the first line of
                                # this record.
                                # The \s+ at the end strips trailing
                                # whitespace.
    print GNUPLOT "set title \"$title\"\n"; # Set the title line.
    open(TEMPFILE, "> tempfile") || die("$0: can't open temporary file--$!\n");

    while (m/x[lr]?=\s?(-?[\d\.]+)\s+y[lr]?=\s?(-?[\d\.]+)/g) {
                                # Find all occurences of x=number y=number or
                                # xl=number y=number or xr=number yr=number.
                                # Yeah, I know the regular expression is
                                # cryptic, but it's really pretty simple.
        print TEMPFILE "$1 $2\n"; # Output a pair of data points.
    }
    close(TEMPFILE);            # Done with the temporary file.
    print GNUPLOT "plot \"tempfile\"\n";
    print "$title: ";         # Output a prompt.
    $/ = "\n";                        # Just wait for a single line from STDIN.
    $_ = <STDIN>;         # Wait for user to press return.
    $/ = '';                    # Read paragraphs from the data file.

Quote:}

--
Gary Holt                       (818)-395-2882

 
 
 

1. Plotting Multiple data sets on the same graph

I'm running Gnuplot 3.5 with the multiplot and GIF extensions on Solaris
2.5.1 and displaying with the x11 driver.

How can I plot multiple data sets on the same graph?

I'd like to do:
plot "ds1" title 'Data set 1',
     "ds2" title 'Data set 2',
     ...

Apparently, you can plot multiple functions, but not multiple
data sets.

Combining the data sets into a single file, separated by
blank lines doesn't give the separate plot colors or entries
in the legend.

I tried the "multiplot" option.  It's close, in that the
different data sets get plotted, but everything's in the
same color and the legend entries end up on top of each other.

Help!!!


\\ `   Xilinx                                   FAX: (408)377-3259
//     2100 Logic Drive
\\/.\  San Jose, California 95124

2. Simple 2-D graphics editor example

3. plot multiple inline data sets on same graph ?

4. GIF Problem [can't load]

5. multiple plots from one data file

6. Moderate-priced digital video cameras (e.g. D1)

7. plotting 2 timeseries data files on one plot with pre3.6/pl273

8. Commercial posting follows

9. Graphing two data sets - only one shows up

10. Multiple bezier curves for one data set?

11. plot multiple set of data

12. How to plot multiple data sets?

13. multiple column data file & no data point