开发者

GNUPlot: plot different ranges with different styles

I know this should be pretty simple, but I haven't been able to find a similar example.

I need to plot different ranges of a datafile differently, but on the same graph.

For instance, say my datafile represents a function with x and y values. I want to plot the first N values using a style like lines, and then the next M values using a different style, like points.

I was thinking I would need a plot command similar to this:

plot [1:5] "my.data" using 1:2 with lines, [6:12] using 1:2 with points, [13:19] using 1:2 with lines

Essentially I want to distinguish different areas of the functions.

Any ideas? I am sorry if i开发者_运维知识库t sounds like I'm rambling but I am quite stumped.

Thanks in advance!


you could do the following:

 plot "mydat.txt" using 1:($1>0 ? $2 : 1/0) with lines,
 "" using 1:($1<=0 ? $2 : 1/0) with points  

edit: I dit test it, and it works, when x variable < 0 you will have points. Of course you can make the conditions in such a way you can accomodate many different graph formats as long as the x values of your function are in the datafile.


I do not think that you could split your data file into different ranges in gnuplot, but if you could do it outside of gnuplot, the problem could be easily solved. After pasting only the first part of 'my.data' to 'my.data1' and the second to 'my.data2' and so on, you could call:

plot "my.data1" using 1:2 title "Data 1" with lines, "my.data2" using 1:2 title "Data 2" with points

You could split up the file by hand, or if I may suggest in R also. Of course it could be done in bash or almost any (script)language.

I hope I could help.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜