Change color of overlapping waves with "fill-to-zero" mode

Is there a straightforward way to reproduce the style of the attached plot in Igor Pro? In particular, where the red wave overlaps with the green wave, the color is white. I suspect there is an easy way to do this by arranging waves and choosing the correct mode/fill, but I haven't been able to figure it out. Any help is appreciated. I have Igor 7, so I can make one of the waves translucent; this approximates the effect I'm after, but I would prefer the look of the attached plot. 

Example plot where overlapping waves are different color

With just two waves you could simply use fill-to-next with different colors for positive and negative values.

To do what you want without transparency, you need to splt the front (red) wave into two waves which add up to the value in the red wave. Here's a function that does that:

Function MakeOverlapWaves(frontWave, backWave)
    Wave frontWave // broken into two additional waves: one to be displayed on top of the other using add-to-next
    Wave backWave // the wave that "slices" the front wave into an aboveWave and a belowWave
   
    if( numpnts(frontWave) != numpnts(backWave) )
        DoAlert 0, "expects waves of the same length"
        return 0
    endif
   
    Duplicate/O frontWave, aboveWave, belowWave // should use variable names, but this is a demo
    belowWave = frontWave[p] > backWave[p] ? backwave[p] : frontWave[p]
    aboveWave = frontWave[p] - belowWave[p]
    return 1
End

I've attached an image of the results compared to using transparency, as well as my demo experiment.

 

Forum

Support

Gallery

Igor Pro 9

Learn More

Igor XOP Toolkit

Learn More

Igor NIDAQ Tools MX

Learn More