Re: Scatterplots in VisAD?

Hi John,

> 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);

The two RealTypes with the same name "Pressure" cause an
Exception. If they have the same values, you only need
one. Otherwise, they should have different names.

> 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.

If your data aren't sampled on a grid, then you probably want
some other domain Set. Perhaps just a
'new Integer1DSet(index, number_of_samples)' if your data are
just a set of records, with no useful domain sampling.

> 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);

Construct this before you pass it to addMap().

>     // 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.

The main thing is to not construct a gridded sampling if you
don't have one. If there is no sampling, then just construct
a dummy RealType like 'index' and use Integer1DSets for Field
domains.

By the way, even though lots of our old exmaples and tutorials
use the RealType constructors, they have been deprecated in
favor of the RealType.getRealType() method.

Also, I highly recommend Ugo's tutorial and Tom's tutorials.

Good luck,
Bill