Re: re : logarithm scale issue

Hi Celine-

When you create the LogCoordinateSystem, you need to specify
a  different RealType as the reference for the system.  Using
x for both the RealTupleType and the reference will not work because
X is in the domain and in the reference, thus the error about
occurring more than once.

Try something like:

        double base = 10;
        RealType x = RealType.getRealType(xAxis);
        RealType logX
            RealType.getRealType("LogX", CommonUnit.promiscuous);
        RealTupleType reference = new RealTupleType(logX);
        CoordinateSystem logCS = new LogCoordinateSystem(reference, base);
        RealTupleType range = new RealTupleType(x, logCS, null);

Don Murray

Celine Gestas wrote:
Hi all,

I am working on displaying a logarithm scale on xAxis but I have the
following error :
" Single DisplayRealType DisplayXAxis occurs more than once:
ShadowType.testIndices"

and I don't understand why... I get X and Y values from a Class but I d like
to have a logarithm scale just for the xAxis.

My code is :

float xMin, xMax, yMax;
       xMax = getMax(_linePlot.getValues(xAxis));
       xMin = getMin(_linePlot.getValues(xAxis));

       yMax = getMax(_linePlot.getValues((String)yAxis.get(0)));
       for(i=1; i<yAxis.size(); i++) {
           if (getMax(_linePlot.getValues((String)yAxis.get(i))) > yMax)
               yMax = getMax(_linePlot.getValues((String)yAxis.get(i)));
       }

       /*************************/
       /* Create the quantities */
       /*************************/

       // create the ScalarMaps : quantity x is to be _displayed along
XAxis and y along YAxis
       RealType x = RealType.getRealType(xAxis);
       xMap = new ScalarMap( x, Display.XAxis );

       RealType y = RealType.getRealType("Y");
       yMap = new ScalarMap( y, Display.YAxis );
       yMap.setScaleEnable(true);
       yMap.setRange(0, yMax);

       CoordinateSystem logCoord = new LogCoordinateSystem(new
RealTupleType(x));
       RealTupleType logX = new RealTupleType(x, logCoord, null);

       // add them to the display
       _display.addMap( xMap );
       _display.addMap( yMap );


       /*************************/
       /* Create the quantities */
       /*************************/

       // our actual x and y values
       float[][] x_vals  = _linePlot.getValues(xAxis);

       // rank the x values
       for( i = (x_vals[0].length - 1);  i > 0;  i--) {
           for( int j=0;  j < i; j++) {
               if (x_vals[0][j] > x_vals[0][j+1]) {
                   float L_iTemp= x_vals[0][j];
                   x_vals[0][j]= x_vals[0][j+1];
                   x_vals[0][j+1]= L_iTemp;
               }
           }
       }

       // create the index
       x_set = new Gridded1DSet(logX, x_vals, x_vals[0].length, logCoord,
null, null);

       float[][] y_vals = _linePlot.getValues((String) yAxis.get(i));

       /******************************/
       /* Code for setting LINE data */
       /******************************/

       // create the function to draw the line
       func_x_y = new FunctionType(logX, y);

       // associate the function (func_x_y) to the values (x_set)
       line_ff = new FlatField( func_x_y, x_set);

       // and put the y values above in it
       line_ff.setSamples( y_vals );


       /**************************/
       /* Initialize the display */
       /**************************/

       // create data references and set the FlatFields (association
function/values) as our datas
       line_ref = new DataReferenceImpl("line_ref");
       line_ref.setData( line_ff );

       _display.addReference( line_ref , lineCMap);

If someone could help me fixing this ....

Celine Gestas


--
*************************************************************
Don Murray                               UCAR Unidata Program
dmurray@xxxxxxxxxxxxxxxx                        P.O. Box 3000
(303) 497-8628                              Boulder, CO 80307
http://www.unidata.ucar.edu/staff/donm
*************************************************************


==============================================================================
To unsubscribe visad, visit:
http://www.unidata.ucar.edu/mailing-list-delete-form.html
==============================================================================


  • 2007 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the visad archives: