Using "Modifygraph tomode=2" with NaN values
ajd
Is there a way to use "Modifygraph tomode=2" while ignoring NaN values (ie. same behavior as zero)?
Make/o wave0={0,1,2,3}
Make/o wave1={4,4,4,4}
make/o wave2={0.5,0.5,NaN,0.5}
//Waves without NaNs
Display wave0,wave1
Modifygraph tomode=2,mode=1,lsize=10
Setaxis left, 0,*
//Including a wave with a NaN...the third data point / bar disappears
Display wave0,wave1,wave2
Modifygraph tomode=2,mode=1,lsize=10
Setaxis left, 0,*
I know I could just copy the waves and replace the NaN's with zeros, but I'd prefer not to have to maintain a second set of data. (Since the NaN value is actually meaningful (ie different from zero) in some cases, I need to maintain a copy of the data that retains the NaN's.)
When does NaN mean zero, and when does it mean Not a Number? Since toMode=2 asks to add one value to another, and the IEEE definition of NaN says that adding NaN to anything results in NaN, it is hard to see how to proceed. Maybe use the approach of making a second wave with a zero there, put the wave in a data folder along with the original data wave. Make a note in the wave note about what's going on.
I hesitate to suggest a dependency- they can cause hard-to-find problems. But perhaps this is a case where it makes sense, if you have an algorithmic way to substitute a zero for a NaN. So you would establish a dependency like
WaveWithZeroes := ConvertNaNToZeroIntelligently(WaveWithNaNs)
April 2, 2019 at 09:26 am - Permalink