Search code examples
jfreechart

Can you set multiple paints on the same XYPlot?


So I have a working XYPlot but I want to add different colors to the background, not a single one. I know this appears to be doable for quadrants, but I want it basically row by row, or ranges of rows I should say.

Basically something like this : enter image description here

but with ideally 3-4 colors instead of just 2. Can you set the background paint for a specified Axis range for example? I haven't found any info or way to do it yet.


Solution

  • IntervalMarker "Represents an interval to be highlighted in some way." In the example below, two markers span the plot's range.

    XYPlot plot = new XYPlot(…);
    plot.addRangeMarker(new IntervalMarker(.3, 1, new Color(0x60CCFFE5, true)));
    plot.addRangeMarker(new IntervalMarker(0, .3, new Color(0x60FFCCE5, true)));
    

    image