Subscribe Bookmark RSS Feed

using the dt<<set row states to set row colors

eigenmetricsoli

Community Trekker

Joined:

Jun 26, 2014

I have found that using the dt<<set row states(single column matrix) function to be much faster than using the more traditional ForEachRow(Rowstate() = Colorstate(LevelColor(Row(),n_groups,"JMP Light")) ), and so I would like to use it.  However in order to do this the scripter needs to build the single column matrix (here called "rscode") directly.  According to the JMP scripting guide, the matrix is determines the row states in the following way:

rscode

=

selected(r)+

2*excluded(r)+

4*hidden(r)+

8*labeled(r)+

16*marker of(r)+

256*color of(r);

I have read Erin Vang's blog post from 2010 about how to set the marker values (she discussed how to include unicode characters as markers), but I have not yet found an equivalent discussion for colors.  The issue I am having is that the "color of" function returns numbers that are not valid color states, but rather negative numbers. Ideally what I want to do is use the built-in color themes like "Spectral" and "JMP Default" rather than have to create one on my own.  So I would like to be able to use the ColorOf(ColorState(<HeatColor(...) or LevelColor(...)>)) to set values in the row state matrix.

Now, setting the color states in a dummy table and using the (dt<<Get Row States)/256 command, one obtains a vector of color indices, however these are not integers.  One of my questions is how are the non-integral parts calculated?

For example create a dummy table, set its colorstates, and then see the inconsistency between the entries of the output vector (which contains indices from JMP's color table 0-84) and the ColorOf(...) function which gives negative numbers, many of which are large.  Is there any pattern to this or any functions I am missing?  Note that blah != blah2 and the resulting table colors are very different.

dt = New Table("test",

  Add Rows( 100 ),

  New Column( "col1",

  Numeric,

  Continuous,

  Format( "Best", 10 ),

  Formula(Row())

  )

);

ForEachRow(

RowState() =

ColorState(HeatColor(Row()/NRows(dt),<<"Jet"))

);

blah = (dt<<GetRowStates)/256;

blah2 = J(NRows(dt),1,0);

ForEachRow(Show(blah2[Row()] = COlorOf(RowState())));

dt<<SetRowStates(blah2*256)

/*

blah =

[53.0000000318978, 53.0000000342261, 53.0000000367872, 53.0000000391155,

53.0000000414439, 53.0000000437722, 53.0000000463333, 53.0000000486616,

53.0000000509899, 21.0000000533182, 21.0000000558794, 21.0000000582077,

21.000000357395, 21.0000009534415, 21.0000015494879, 21.000002205139,

21.0000028011855, 21.0000033972319, 21.0000039932784, 21.0000045893248,

21.0000051853713, 5.00000584102236, 5.00000643706881, 5.00000703311525,

5.0000076291617, 13.0000082252081, 13.0000088212546, 45.0000094769057,

45.0000100729521, 45.0000106689986, 45.000011265045, 45.0000119206961,

45.0000125167426, 45.000013112789, 42.0000137088355, 42.0000143644866,

42.000014960533, 42.0000915501732, 42.0002441336401, 71.0003967175726,

71.0005645607598, 71.0007171453908, 71.0008697302546, 71.001022315817,

68.0011749016121, 68.0013274876401, 68.0014953331556, 68.0016479198821,

68.0018005073071, 68.0019530949649, 68.0019683514256, 68.0019988666754,

68.0020751582924, 68.0021514496766, 76.0022735176608, 76.0024108444341,

76.0025634299964, 76.0027617919259, 76.0029754126445, 76.0032042919193,

41.003463689005, 41.0037536036689, 41.0039058923721, 41.0039052963257,

41.0039046406746, 41.0039040446281, 9.0039034485817, 9.00390285253525,

9.00390219688416, 9.00390160083771, 9.00390100479126, 6.00390040874481,

6.00389975309372, 6.00389915704727, 6.00389856100082, 6.00389796495438,

6.00389736890793, 6.00389677286148, 6.00389611721039, 6.00389552116394,

6.00389492511749, 6.00389432907105, 3.0038937330246, 19.0038931369782,

19.0038924813271, 19.0038918852806, 19.0038912892342, 19.0038146972656,

19.003662109375, 19.0034942626953, 19.0033416748047, 19.0031890869141,

19.0030364990234, 51.0028686523438, 51.0027160644531, 51.0025634765625,

51.0024108886719, 51.0022430419922, 51.0020904541016, 51.0019378662109];

blah2 =

[-137, -147, -158, -168, -178, -188, -199, -209, -219, -229, -240, -250, -1535, -

4095, -6655, -9471, -12031, -14591, -17151, -19711, -22271, -25087, -27647, -30207,

-32767, -35327, -37887, -40703, -43263, -45823, -48383, -51199, -53759, -56319, -

58879, -61695, -64255, -393205, -1048546, -1703889, -2424770, -3080116, -3735463,

-4390813, -5046164, -5701516, -6422407, -7077762, -7733120, -8388479, -8454005, -

8585067, -8912737, -9240406, -9764684, -10354498, -11009848, -11861806, -12779300,

-13762329, -14876431, -16121605, -16775680, -16773120, -16770304, -16767744, -

16765184, -16762624, -16759808, -16757248, -16754688, -16752128, -16749312, -

16746752, -16744192, -16741632, -16739072, -16736512, -16733696, -16731136, -

16728576, -16726016, -16723456, -16720896, -16718080, -16715520, -16712960, -

16384000, -15728640, -15007744, -14352384, -13697024, -13041664, -12320768, -

11665408, -11010048, -10354688, -9633792, -8978432, -8323072];*/

1 REPLY
eigenmetricsoli

Community Trekker

Joined:

Jun 26, 2014

So what I decided to do for now is to simply create a dummy table with the number of rows equaling the number of groups that I have, setting their states, and then extracting the state info using get row states.

I did some timing analysis and ForEachRow(...) seems to take a negligible amount of time for data times that are small enough, but the time it takes to run ForEachRow(...) scales much faster with the number of rows and at some point ForEachRow(...) takes > 10x as long (for tables with ~1000 rows or more) than generating the rowstate vector directly and then using dt<<Set Row States.

dv:jmp_markers = Function({n_groups},{Default Local},

       dt = New Table("delete me",

            Invisible,

            Add Rows( n_groups ),

            New Column("col1",

                 Numeric,

                 Continuous,

                 Format( "Best", 10 ),

                 Formula(Row())

            )

       );

       dt<<RunFormulas;

       dt<<MarkerByColumn("col1",MarkerTheme(dv:row_legend_marker_theme));

       output_list = (dt<<GetRowStates)/16;

       Close(dt,no save);

       output_list;

);//analogous function for colors...except I do use the ForEachRow(...) assignment for colors