Best way to graph a discontinuous data set?

gseaborn
Posts: 16
Joined: 2008-08-01
Location: Canada

I have a numeric data set that is interspersed with "-1" values. Wherever there is a "-1", I would like the graph not to plot the point, and to make a gap between the two adjacent points (not join them up).

Is there any easy way to do this? I know I can use DeletePoints to remove the points that have a value of "-1", but I'm not sure how I can make it so that the line graph is plotted discontinuously.

Thanks


Posts: 563
Joined: 2007-03-01
Location: United States

Igor plots a gap where the value of a wave is NaN (not a number), so you just need to replace all -1 values in your wave with NaN and then display the wave.

Something like:
foo = foo[p] == -1 ? NaN : foo[p]
should work for the replacement.


gseaborn
Posts: 16
Joined: 2008-08-01
Location: Canada

Thanks - that's perfect.


patarroyo
Posts: 51
Joined: 2008-07-08
Location: United States

aclight, where can I learn more about the syntax that you used? That functionality looks interesting, but I don't follow it.


andyfaff
Posts: 476
Joined: 2007-09-11
Location: Australia

It's in the IGOR help browser. Look for ?: in the index.

On the LHS you have a "True or false" question.
Part 1:
foo[p]==-1? which points in foo are equal to -1?

Part 2:
foo= ....... NaN : foo[p]

where the question in part 1 equates to True, set the value of foo to NaN. Where the question equates to False, leave the point as it is.

aclight wrote:
Igor plots a gap where the value of a wave is NaN (not a number), so you just need to replace all -1 values in your wave with NaN and then display the wave.

Something like:
foo = foo[p] == -1 ? NaN : foo[p]
should work for the replacement.


vinodmagic
vinodmagic's picture
Posts: 6
Joined: 2012-04-20
Location: India

What should i do if i want to replace all values within a wave between two given points (say between point 2 and point 100) by NaN?


bech
Posts: 54
Joined: 2007-10-20
Location: Canada

vinodmagic wrote:
What should i do if i want to replace all values within a wave between two given points (say between point 2 and point 100) by NaN?

Just write w[2,100]=NaN


jtigor
Posts: 180
Joined: 2007-09-04
Location: United States

bech wrote:
Just write w[2,100]=NaN

Just to be painfully clear, note that will be inclusive of points 2 and 100. If you want points between 2 and 100, exclusive of the endpoints, you want to use

w[3,99] = NAN

Apologies if this is too close to stating the obvious.


vinodmagic
vinodmagic's picture
Posts: 6
Joined: 2012-04-20
Location: India

Thanks, it worked. Was really so easy!!


Back to top