display points using log scale
Celine Gestas
celine.gestas at gmail.com
Mon Mar 26 06:48:44 MDT 2007
Hi,
I am working on a application which enables users to choose to use a
logarithm scale or not (log scale on X, on Y or on X and Y). When I am
plotting a line the result id ok (scale and plot) but when I am trying to
display points, they don t fit to the log scale. So I have tried what is on
the comment but it changes nothing...
If someone has an idea ...
RealTupleType rangeIndex = null;
// create the index
if (log.equals("logX") || log.equals("logY") ||log.equals("loglog"))
{
index = RealType.getRealType("index", CommonUnit.promiscuous);
RealTupleType referenceIndex = new RealTupleType(index);
LogCoordinateSystem logCSindex = new
LogCoordinateSystem(referenceIndex, base);
rangeIndex = new RealTupleType(index, logCSindex, null);
index_set = new Integer1DSet(rangeIndex, x_vals[0].length,
logCSindex, null, null);
}
else {
index = RealType.getRealType("index");
index_set = new Integer1DSet(index, x_vals[0].length);
}
// organize x and y in a Tuple
// create the function to draw points
if (log.equals("logX")) {
y = RealType.getRealType( yAxis.split(" ")[0]);
x_y_tuple = new RealTupleType(logX, y);
func_i_tuple = new FunctionType( rangeIndex, x_y_tuple);
}
else if (log.equals("logY")) {
y = RealType.getRealType("");
logY = RealType.getRealType( yAxis.split(" ")[0],
CommonUnit.promiscuous);
x_y_tuple = new RealTupleType(x, logY);
func_i_tuple = new FunctionType( rangeIndex, x_y_tuple);
}
else if(log.equals("loglog")){
y = RealType.getRealType("");
logY = RealType.getRealType(yAxis.split(" ")[0],
CommonUnit.promiscuous);
x_y_tuple = new RealTupleType(logX, logY);
func_i_tuple = new FunctionType( rangeIndex, x_y_tuple);
}
else {
index = RealType.getRealType("index");
index_set = new Integer1DSet(index, x_vals[0].length);
y = RealType.getRealType(yAxis.split(" ")[0]);
x_y_tuple = new RealTupleType(x, y);
func_i_tuple = new FunctionType( index, x_y_tuple);
}
// our actual data values for x and y
float[][] point_vals = new float[2][x_vals[0].length];
point_vals[0] = x_vals[0];
point_vals[1] = y_vals[0];
// associate the function (func_i_tuple) to the values (index_set)
points_ff = new FlatField( func_i_tuple, index_set);
// and finally put the points above in it
points_ff.setSamples( point_vals );
// create data references and set the FlatFields (association
function/values) as our datas
points_ref = new DataReferenceImpl("points_ref");
points_ref.setData( points_ff );
// points and line initialization
pointsCMap = new ConstantMap[] { new ConstantMap(color[0]+0.2f,
Display.Red),
new ConstantMap( color[1], Display.Green),
new ConstantMap( color[2], Display.Blue),
new ConstantMap( 4.0f, Display.PointSize)};
// add references to the display
_display.addReference( points_ref, pointsCMap);
...
Cheers,
Celine Gestas
More information about the visad
mailing list