ContourPlot's ColorBar can't set Range

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
alsw-2000
Posts: 16
Joined: Thu May 22, 2003 12:53 pm

ContourPlot's ColorBar can't set Range

Post by alsw-2000 » Thu Jun 03, 2004 10:57 am

Dear all,

I have a ContourPlot as follow:
Image

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);
Cheers,
alsw-2000

Locked