Colored background bands

Jul 10, 2012 at 9:30 PM

I've created a line graph to plot data on and it's working well. I'd like to have the background show colored bands to represent red/yellow/green areas. For example, the background of the graph should be red for Y values less than 10; yellow for Y values >= 10 and < 20; green for Y values >= 20.

What's the best way to achieve this?

(Here's a crude example: http://www.csc-scc.gc.ca/text/pblct/rpp/rpp2012-13/images/ex1-eng.jpg )

Jul 10, 2012 at 11:24 PM

This could be done by annotations. I added a "RectangleAnnotation" class - see the example "Annotations | RectangleAnnotation - horizontal bands" in the "Example browser". The code is in the ExampleLibrary/Examples/AnnotationExamples.cs

Jul 11, 2012 at 1:23 AM

Dude, you rock! That works perfectly.

One thing I noticed is that if I specify the MaximumY parameter as double.MaxValue it didn't plot the RectangleAnnotation. However, this was trivial to solve by omitting the MaximumY parameter.

Jul 11, 2012 at 1:50 PM

I added support also for double.MinValue/MaxValue (same effect as using NaN). I see this is useful when setting only the upper/lower bound. 

Ps. The hatched (pattern) brush in your example is not supported by OxyPlot.