Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Plotting multiple lines in a single graph

6,278 views
Skip to first unread message

crawford richard

unread,
Apr 10, 1997, 3:00:00 AM4/10/97
to

In message-Id: <334D495F...@obpa.usda.gov>
Sam Barkdull <s...@obpa.usda.gov> wrote:

> I've got Gnuplot for Unix version 3.5, and all I want to do is plot as
> many as six different lines in a single graph using a data file with
> several columns of numbers. I have no problem generating one line with
>
> gnuplot> plot "file.dat" using 12:9 with lines
>
> but how does one produce multiple lines from different columns in a data
> file?


Just string them all together on a single 'plot' command, separated by
commas:

set data style lines
plot "data" u 12:9, "data" u 11:10, "data" u 3:4


gnuplot will automatically assign a different line type (color or dot/
dash pattern) to each line.


Dick Crawford, aka rccra...@lanl.gov

Sam Barkdull

unread,
Apr 10, 1997, 3:00:00 AM4/10/97
to

I've got Gnuplot for Unix version 3.5, and all I want to do is plot as
many as six different lines in a single graph using a data file with
several columns of numbers. I have no problem generating one line with

gnuplot> plot "file.dat" using 12:9 with lines

but how does one produce multiple lines from different columns in a data
file?

Excuse my profound ignorance and thanks in advance,

Sam Barkdull

Dave Gavin

unread,
Apr 10, 1997, 3:00:00 AM4/10/97
to

try this;

gnuplot> plot "file.dat" using 12:9 with line 1,\
"file.dat" using 12:8 with line 2,\
"file.dat" using 12:7 with line 3,\
"file.dat" using 12:6 with line 4,\
"file.dat" using 12:5 with line 5,\
"file.dat" using 12:4 with line 6


Dave

>[[[[ unsubscribe from info-gnuplot via majo...@dartmouth.edu ]]]]

Slante,
Dave

dga...@unifi.com
Senior Network Software Engineer
UNIFI Communications
Sent by XFMail on 10-Apr-97 at 17:48:32
Under a government which imprisons any unjustly, the true place for a
just man is also a prison.
-- Henry David Thoreau

Khoo Chee

unread,
Apr 11, 1997, 3:00:00 AM4/11/97
to

Sam Barkdull wrote:
>
> I've got Gnuplot for Unix version 3.5, and all I want to do is plot as
> many as six different lines in a single graph using a data file with
> several columns of numbers. I have no problem generating one line with
>
> gnuplot> plot "file.dat" using 12:9 with lines
>
> but how does one produce multiple lines from different columns in a data
> file?
>
> Excuse my profound ignorance and thanks in advance,
>
> Sam Barkdull

gnuplot> plot "file1.dat" using 12:9 with lines, "file2.dat" using 12:9
with lines, "file3.dat" using 12:9 with lines, "file4.dat" using 12:9
with lines, "file5.dat" using 12:9 with linese, "file6.dat" using 12:9
with lines

Hope will help you.

--
|- # Alcatel Software Center Penang Malaysia #
| Phone: 6-04-507-0542 Fax: 6-04-506-3232
| // Khoo Chee - System Administrator //
--> mailto:cwk...@penang1.vz.cit.alcatel.fr

Terrence M. Brannon

unread,
Apr 11, 1997, 3:00:00 AM4/11/97
to

Khoo Chee <cwk...@penang1.vz.cit.alcatel.fr> writes:

>
> gnuplot> plot "file1.dat" using 12:9 with lines, "file2.dat" using 12:9
> with lines, "file3.dat" using 12:9 with lines, "file4.dat" using 12:9
> with lines, "file5.dat" using 12:9 with linese, "file6.dat" using 12:9
> with lines

but how to label the columns differently. the title option keeps
giving a syntax error:


gnuplot> plot "file.dat" using 0:1 with line 1 title "x"
undefined variable: title

gnuplot>

--
o============o Sending unsolicited commercial e-mail (UCE) to this address
Legal Notice is indication of your consent to pay me $120/hour for 1 hour
o============o minimum for professional proofreading & technical assessment.
terrence brannon * bra...@kappa.usc.edu * http://rana.usc.edu:8376/~brannon

crawford richard

unread,
Apr 11, 1997, 3:00:00 AM4/11/97
to

In message-Id: <ysizbu7l...@bufo.usc.edu>

Terrence M. Brannon <bra...@bufo.usc.ed> wrote:

> > gnuplot> plot "file1.dat" using 12:9 with lines, "file2.dat" using 12:9
> > with lines, "file3.dat" using 12:9 with lines, "file4.dat" using 12:9
> > with lines, "file5.dat" using 12:9 with linese, "file6.dat" using 12:9
> > with lines
>
> but how to label the columns differently. the title option keeps
> giving a syntax error:
>
>
> gnuplot> plot "file.dat" using 0:1 with line 1 title "x"
> undefined variable: title


Options are order-dependent -- try

plot "file.dat" using 0:1 title "x" with line 1

Dick Crawford, aka rccra...@lanl.gov

Khoo Chee

unread,
Apr 14, 1997, 3:00:00 AM4/14/97
to

How to specify a color if you run out of color after the sixth line
which may use black as default?

Thanks

crawford richard

unread,
Apr 14, 1997, 3:00:00 AM4/14/97
to

In message-Id: <3351EF1D...@penang1.vz.cit.alcatel.fr>
Khoo Chee <cwk...@penang1.vz.cit.alcatel.fr> wrote:

[snip]

> How to specify a color if you run out of color after the sixth line
> which may use black as default?

If you put an integer at the end of a section of the 'plot' command
(by a 'section' I mean the options that define a single function or
data set to be plotted), that integer will be used as the 'line-type
index'. A second integer will be used as the 'point-type index'.
Thus

plot f1(x) with lines 3, f2(x) with points 0 5

will plot f1(x) with a line of type 3 and f2(x) with points of type 5.

How do you know which index corresponds to which type? Use the 'test'
command -- it shows a display of the types available to your terminal.
Each terminal has its own menu of types, so if you use several terminals
you should run 'test' for each one.


Note that gnuplot pre-3.6 introduced a slightly different syntax about 20
versions ago -- keywords 'lt' and 'pt' are now required. My example reads

plot f1(x) with lines lt 3, f2(x) with points pt 5

for pre-3.6.


Dick Crawford, aka rccra...@lanl.gov

Khoo Chee

unread,
Apr 16, 1997, 3:00:00 AM4/16/97
to

Hi,

In gnuplot pre-3.6 version, it only has eight (I think) colors
to be used to plot multi-lines, and the rest have to use together with
the pattern. Is there a way to alter the source codes to make it to
use as many colors as possible without mixing with patterns? Because
I use it to draw a lot of lines in a graph and it would be very messy
if the patterns are used together.

Thanks & Best Regards,
Khoo.

0 new messages