Re: Scatterplots in VisAD?

Thanks for your reply. I'm also still getting my mind around the VisAD
terminology and data models. This what I'm attempting so far:

RealType X = new RealType("salinity", null, null);
RealType Y = new RealType("Temperature", null, null);
RealType Z = new RealType("Pressure", null, null);
RealType ZColor = new RealType("Pressure", null, null);
RealTupleType domain_tuple = new RealTupleType(Y, X);
RealTupleType range_tuple = new RealTupleType(Z, ZColor);
FunctionTypefunc_domain_range = new FunctionType(domain_tuple, range_tuple);

// mins and maxes computed by ispecting the values of x and y
Linear2DSet domain_set = new Linear2DSet(domain_tuple, yMin, yMax, ySize,
                                               xMin, xMax, xSize);

Here's where I get confused. In the case of a surface, I would declare up a
flat samples array:
float[][] flat_samples = new float[2][xSize * ySize];

And fill it up with z anc ZColor values. Since my original data are not
grids, I'm not sure what to do here.

And then my code looks like this:
    vals_ff = new FlatField(func_domain_range, domain_set);

    // ...and put the values above into it. Note the argument false, meaning
that the array won't be copied
    vals_ff.setSamples(flat_samples, false);

    // Create Display and its maps
    // A 3D display
    display = new DisplayImplJ3D("display1");

    // Get display's graphics mode control and draw scales
    GraphicsModeControl dispGMC = (GraphicsModeControl)
display.getGraphicsModeControl();
    dispGMC.setScaleEnable(true);

    // Create the ScalarMaps
    yMap = new ScalarMap(Y, Display.YAxis);
    xMap = new ScalarMap(X, Display.XAxis);
    xRangeMap = new ScalarMap(X, Display.SelectRange);
    yRangeMap = new ScalarMap(Y, Display.SelectRange);

    // Add maps to display
    display.addMap(yMap);
    display.addMap(xMap);
    display.addMap(xRangeMap);
    display.addMap(yRangeMap);

     // "contour" variable on z-axis
    zMap = new ScalarMap(Z, Display.ZAxis);
    zRangeMap = new ScalarMap(Z, Display.SelectRange);
    display.addMap(zMap);

     zRGBMap = new ScalarMap(ZColor, Display.RGB);
  display.addMap(zRGBMap);
  display.addMap(zRGBRangeMap);

 zRGBRangeMap = new ScalarMap(ZColor, Display.SelectRange);

    // create the range widgets
    selXRange = new SelectRangeWidget(xRangeMap);
    selYRange = new SelectRangeWidget(yRangeMap);

    // Create a data reference and set the FlatField as our data
    data_ref = new DataReferenceImpl("data_ref");
    data_ref.setData(vals_ff);

    // Add reference to display
    display.addReference(data_ref);

Am I really off track here? Should I not even try to modify my surface
plotting code to draw a 3D scatter plot.

Bill Hibbard wrote:

> Hi John,
>
> > I'm just starting out with VisAD and have been successful creating a
> > variety of 3D surface plots. Now, however, I want to make a 3D scatter
> > plots and I'm having trouble getting my mind around what to do. My
> > surface plots were derived from gridded data but the data behind the
> > scatter plots are just tuples. TIA
>
> The general pattern for a scatter plot is data in a FlatField
> with MathType (index -> (a, b, c, ..., z)) and ScalarMaps:
>
>   a -> XAxis
>   b -> YAxis
>   c -> ZAxis
>
> where any range RealTypes (i.e., any letters a - z) can be
> substituted for a, b and c in these ScalarMaps. You can add
> other ScalarMaps to color components (e.g., Red, Green, Blue,
> RGB) and to SelectRange. The domain of your field doesn't
> have to be a 1-D 'index', but may be a 2-D image domain such
> as (line, element). The key idea in a scatter diagram is that
> domain RealTypes are not mapped to spatial display axes, but
> that range RealTypes are.
>
> Cheers,
> Bill