Is there any easy way to change the color of one curve based on its values relative to a second curve?

Say I have 2 curves that each contain their own arbitrary data:
  1. Signal curve - in general painted with a black pen (more on that in a second...)
  2. Reference curve - painted with a blue pen


The pen for Signal should be red whenever the ySignal >= yReference, and black whenever ySignal < yReference. If it helps, the two curves are identically sampled in x.

I don't see anything in the API that easily allows this, so unless I'm missing something, my approach is to:
  1. Plot all of Signal in black first
  2. Plot all of Reference in blue next
  3. Manually parse through the y-values of both Signal and Reference and create multiple curves for the regions where the signal data is >= the reference data, and then plot those resulting curves with a red pen and a higher z-order than the


The other possible option I see is based off from this hint: https://sourceforge.net/p/qwt/mailman/message/20349266, where I make my own special curve class that takes both the Signal and Reference and overrides drawCurve to change the pen color based on their relative values