I have a ContourPlot as follow:

I found that the ColorBar is auto adjusted according to the data set.
However I want to fix the Range and TickUnit of the ColorBar so that is has the same ColorBar for any data set. Is there anyone know how to do it?
I have tried the following functions but the ColorBar just ignore it and auto adjust its range and tick unit..............

Code: Select all
ColorBar zColorBar = null;
String zAxisLabel = "";
zColorBar = new ColorBar(zAxisLabel);
ColorPalette cp = new RainbowPalette();
double x[] = {-2.5,-2,-1.5,-1,-0.5,0,0.5,1,1.5,2,2.5};
cp.setTickValues(x);
cp.setStepped(true);
zColorBar.setColorPalette(cp);
zColorBar.getAxis().setTickMarksVisible(true);
zColorBar.setMinimumValue(-1);
zColorBar.setMaximumValue(1);
zColorBar.getAxis().setAutoRange(false);
zColorBar.getAxis().setAutoTickUnitSelection(false);
zColorBar.getAxis().setLowerBound(-1);
zColorBar.getAxis().setUpperBound(1);
NumberTickUnit tickUnit = new NumberTickUnit(0.5);
TickUnits tickUnits = new TickUnits();
tickUnits.add(tickUnit);
zColorBar.getAxis().setStandardTickUnits(tickUnits);
alsw-2000