2

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 it sounds like I'm rambling but I am quite stumped.

Thanks in advance!

2 Answers 2

10

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.

Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.