Best way to graph a discontinuous data set?
| gseaborn | August 29, 2008 - 10:49 | ||
|---|---|---|---|
|
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 |
|||

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.
Joined: 2008-08-01
Location: Canada
Thanks - that's perfect.
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.
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.
Something like:
foo = foo[p] == -1 ? NaN : foo[p]
should work for the replacement.
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?
Joined: 2007-10-20
Location: Canada
Just write w[2,100]=NaN
Joined: 2007-09-04
Location: United States
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.
Joined: 2012-04-20
Location: India
Thanks, it worked. Was really so easy!!