4.1.8 Contour2D Series

Contour Series

Contour2D Series is similar to Surface Series, but they are more accurate than Surface charts.

Setting ContourSeries:

1
2
3
4
// Sets ContourSeries object, named series, where 
//    data is an instance of ChartDataModel and contains values which will be shown on chart
//    xMapper and yMapper are instances of AxisMapper and will map values from data
ContourSeries series = new ContourSeries(data, xMapper, yMapper);

Contour Series 2D Demonstration

Figure 4.1.8.1 Contour2D Series Demonstration

View Source

Other Contour2D Series Properties

Aspect Ratio

There is a possibility to set chart's aspect ratio, that is a ration which is a result of chart's width divided by height.

Setting ratio:

 
// setting series golden aspect ration
series.setAspectRatio(AspectRatio.INVERSE_GOLD);
Wire frame

If there is a need only to render contour lines(visual representation on contour edges), this can be achieved using setWireframe method. However, chart's foreground color (for instance (series.getPaintStyle().setForeground(Color.RED)) should not be set to null).

Setting wire frame:

 
series.setWireFrame(true);

Contour2D Series WireFrame Demonstration

Figure 4.1.8.2 Contour2D Series WireFrame Demonstration

Contour Count

Contour Count - indicates a number of contours that should be painted.

Setting contour count:

 
series.setContourCount(5);

Contour2D Series Contour Count set to 5 Demonstration

Figure 4.1.8.3 Contour2D Series Contour Count set to 5 Demonstration

 
series.setContourCount(10);

Contour2D Series Contour Count set to 10 Demonstration

Figure 4.1.8.3 Contour2D Series Contour Count set to 10 Demonstration

Color Palette

Contour color palette can be set using ColorPalette enumeration or setting an array of Colors (length of array should be contourCount + 1 in order to render it correctly).

Setting Color using ColorPalette:

 
series.setContourCount(9);
//setting color palette 
series.setColorPalette(ColorPalette.DEFAULT_CONTOUR_PALETTE,10);

Contour2D Series ColorPalette Demonstration

Figure 4.1.8.4 Contour2D Series ColorPalette Demonstration

Setting Color using Color array:

1
2
3
4
5
6
7
8
series.setContourCount(2);
//setting color palette using array
series.setColorPalette(new Color[]
{
  new Color(41, 53, 150), 
  Color.GREEN.darker().darker(), 
  Color.RED.brighter().brighter()
});

Contour2D Series Color Array Demonstration

Figure 4.1.8.5 Contour2D Series Color Array Demonstration