Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

graph - Line plot in GnuPlot where line color is a third column in my data file?

I have a datafile that looks like this:

1 1.0 0
2 1.5 0
3 0.0 1
4 1.2 2
5 1.0 1
6 1.1 1

where the first column is my X value, the second column is my Y value, and the third column is a color. I'd like for each line segment to be colored according to the third column. So the first two line segments would be "color 1", the next would be "color 2", the next would be "color 3", and the final two would be "color 1" again.

I tried:

plot 'file.dat' using 1:2:3 with lines rgb variable;

But my line was all black.

Is this possible in gnuplot?

Thanks, Gabe

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

This following works for me (gnuplot 4.4)

plot "./file.dat" u 1:2:3 with lines  palette

Hope this helps.

When I ran your code gnuplot couldn't pass the "rgb" part.

For an example of using the variable tag see the similar question: GNUPLOT: dot plot with data depending dot size

with the useful examples found here: http://gnuplot.sourceforge.net/demo/pointsize.html

All the best

Tom


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...