// Define range and precision for the function to plot
Range range = new Range(-.5, .5);
int steps = 50;
// Create the object to represent the function over the given range.
final Shape surface = (Shape)Builder.buildOrthonormal(new OrthonormalGrid(range, steps, range, steps), mapper);
surface.setColorMapper(new ColorMapper(new ColorMapRainbow(), surface.getBounds().getZmin(), surface.getBounds().getZmax()));
surface.setFaceDisplayed(true);
surface.setWireframeDisplayed(true);
surface.setWireframeColor(Color.BLACK);
// Setup a colorbar for the surface object and add it to the scene
Chart chart = getChart();
chart.getScene().getGraph().add(surface);
ColorbarLegend cbar = new ColorbarLegend(surface, chart.getView().getAxe().getLayout());
surface.setLegend(cbar);
}