Multi coloured line graph


Gammatech

Recommended Posts

Hi,

I have used your suggested boolean math system to get round the lack of variable colour threshholds in the graph component so that on the first of my graphs the expressions, (here I have two colour thresholds) are:

red - outside the target band:

(ShiftAshDeviation*(Abs(ShiftAshDeviation)>AshBand))+(NaN()*!(Abs(ShiftAshDeviation)>AshBand))

and

green - within the target band:

ShiftAshDeviation*(Abs(ShiftAshDeviation)<=AshBand)+(NaN()*!(Abs(ShiftAshDeviation)<=AshBand))

and on the second graph where there are three colour thresholds the expressions are:

yellow - above target + band but below upper limit:

(RunningAsh*((RunningAsh>=(AshTarget+AshBand))*(RunningAsh<=AshHighLimit)))+(NaN()*!((RunningAsh>=(AshTarget+AshBand))*(RunningAsh<=AshHighLimit)))

yellow - below target - band but above lower limit:

(RunningAsh*((RunningAsh>=AshLowLimit)*(RunningAsh<=(AshTarget-AshBand))))+NaN()*!((RunningAsh>=AshLowLimit)*(RunningAsh<=(AshTarget-AshBand)))

red - below low limit:

(RunningAsh*(RunningAsh<=AshLowLimit))+NaN()*!(RunningAsh<=AshLowLimit)

red - above high limit:

RunningAsh*(RunningAsh>=AshHighLimit)+(NaN()*!(RunningAsh>=AshHighLimit))

green - within the band about the target:

(RunningAsh*(RunningAsh>=(AshTarget-AshBand))*(RunningAsh<=(AshTarget+AshBand)))+(NaN()*!((RunningAsh>=(AshTarget-AshBand))*(RunningAsh<=(AshTarget+AshBand))))

where RunningAsh is a channel populated from the last values of the Ash chanel as:

RunningAsh.AddValue(Mean(Ash[0,ResponseTime]))

I used to use the Smooth function on the raw Ash channel in line in the expression but this made the expression even more unwieldy than it is now.

These expressions seem to generally give me what I want with two exceptions:

1) Occasionally the first graph momentarilly plots a few red points at the center zero line (its a deviation from target graph) which disapear as the next point is plotted (1 per second) This doesn't happen very often but is sufficiently frequent to be distracting when it happens. Is this something wrong with my boolean math?

2) If the data gooes outside the Y scale by a sufficiently large excursion then the coloured point will plot just beyond the desk area of the graph. I have tried externally clamping the data to the Y scale limits before it is added into the channel from which I plot the graph points. This obviously works but has the disadvantage that if the user subsequently increases the Y scale then the historical data plotted has been limited to the old Y scale and is thus not a valid representation any more. I wondered if the use of the inline (iif) statement could be used to do the limiting to Y scale in the graph expression for each colour but as the expressions for each coloured trace are rather complicated I was a bit wary of trying this. As the channel data plotted is referenced as a block rather than just the latest point does the graph component recalculate each point in the trace ready for each update of the graph display?

Two other points I have yet to sort out with the graphs are:

i) The format for the Y axis values. If the number of increments along the Y scale give each value such that they can be drawn as integers then the actual graph occupies a greater proportion of the whole display. How can I force the format to always show say one figure after the decimal point. I have tried the Format statement in the expression for the Y scaling but this doesn't seem to work. The Y scale minimum and Y scale maximum are variables.

ii) The X axis scaling (time) has the digits in a font size that makes it dificult to read and varies as the length of the graph varies due to the above (a)

Is there a way to fix the format of the Y axis and font size of the X axis so that the readability is not variable?

Thanks in advance for all the help.

Martin

Link to comment
Share on other sites

ok, lets say your channel name is "myChannel" and you want it to plot blue if the value is < 0, green if its < 2 (but >=0) and otherwise red. Create another channel called graphColor or similar, Device type Test, I/O type A to D, Timing = 0. Then in the event for myChannel:

switch
   case(mychannel[0] &lt; 0)
	  graphColor.addValue(insertTime(0, myChannel.time[0], 0))
   case(myChannel[0] &lt; 2)
	  graphColor.addValue(insertTime(1, myChannel.time[0], 0))
   default
	  graphColor.addValue(insertTime(2, myChannel.time[0], 0))
endcase

This will make graphColor have either 0, 1, or 2 depending on what color should be used. You can then use graphColor as the expression driving the trace colors for the myChannel trace in your graph.

Link to comment
Share on other sites

That is much better than the Boolean Math approach and more easily readable by the person that picks this project up when I am gone! I have tried it with a line type, a stick type and an area type plot. As it indicates in the help the area type plot does not support multi-coloured plotting. The line type works well, much better than I achieved with the Boolean Math method. The Stick type plot still has a "shuffling progression" along the chart due in part to the thickness of the sticks not being related to the length of the X axis.

My next point was as outlined in my point (2) earlier in this thread. Any use of this method by, say, setting a colour that was the same as the graph area to make the plot invisible would suffer as my earlier attempt when the Y scale was altered. One would have to re-evaluate externally the entries in the Graph colour channel, as filled by the main channel event code, any time the Y scale was altered.

The last point was the Format of the axis scales as in the points (i) and (ii) earlier in this thread. Is there any fix for this?

Thanks,

Martin

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.