Google Answers Logo
View Question
 
Q: gnuplot ( No Answer,   6 Comments )
Question  
Subject: gnuplot
Category: Computers
Asked by: ignorant-ga
List Price: $5.00
Posted: 29 Dec 2004 06:16 PST
Expires: 28 Jan 2005 06:16 PST
Question ID: 448654
I have a file consisting of two lists of x y pairs; the lists are separated
by a newline.  

Example:
1 2
2 5
3 4

1 6
2 8
3 9

How does one coerce gnuplot into making a plot of the file such that
the two broken-line graphs indicated by the data file have *different*
colors?  Specifically, how can I control the colors used?

Assuming my data file is called "r", the command 

         plot "r" with lines

gives me what I want, except that both graphs have the same color, which
makes them difficult to interpret.

P.S.  An acceptable answer is not something like: get postscript output
      and edit the postscript source.
Answer  
There is no answer at this time.

Comments  
Subject: Re: gnuplot
From: troglodyte-ga on 29 Dec 2004 13:17 PST
 
split the input file into two: r1 and r2, each containing one line.
then plot the two lines separately --

plot "r1" with lines

plot "r2" with lines

the lines are guaranteed to be of different color by default.  in
addition, you can control all the parameters of the lines
independently (such as point size, line width, etc.)  in particular,
to control line color, use the command plot with linestyle or linetype
(see gnuplot help for details).
Subject: Re: gnuplot
From: troglodyte-ga on 29 Dec 2004 14:01 PST
 
apologies for slip of the hand in prev comment.  the command must be a
single plot command:

plot "r1" with lines, "r2" with lines

(with optional parameters following each with-lines clause).
if you do two plot commands, the second overwrites the first, and you
get only the second line.  sorry.
Subject: Re: gnuplot
From: vladimir-ga on 29 Dec 2004 16:36 PST
 
If the datasets were separated by not one but two blank lines, then
you could use a command like this:

plot "r" index 0 with lines, "r" index 1 with lines

Which would give each dataset a different color.

Vladimir
Subject: Re: gnuplot
From: ignorant-ga on 30 Dec 2004 07:14 PST
 
I appreciate the pointers (especially that *two* newlines, rather than one,
are needed), but remain curious about how one can control -- i.e.,
specify -- which colors are used; rgb color cooridinates would be most
useful.

ignorant-ga
Subject: Re: gnuplot
From: vladimir-ga on 30 Dec 2004 14:51 PST
 
You can choose the color of lines with the following command:

plot "x" with lines linetype 5

Where the number after "linetype" specifies the color (or the type of
line in general - if colors are not available).

Here are two more gnuplot commands that you could find useful:

test

will show you the different linetypes/colors.

help plot with

will show a short description of the options available when plotting
(you can also choose line width and such).

I don't think it's possible to specify an RGB color.

Hope this helps,

Vladimir
Subject: Re: gnuplot
From: travisbickle-ga on 27 Jan 2005 07:57 PST
 
This would be a Gnuplot 4.1 feature (look at the CVS). 

See patches :
http://www.bmsc.washington.edu/people/merritt/gnuplot/demo/rainbow.html

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at answers-support@google.com with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  


Google Home - Answers FAQ - Terms of Service - Privacy Policy