cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
ChrisM_X
Level III

RGB colors of rows in JMP datatable

I am working on a C# application the can be invoked by jsl JMP scripts.  The JMP script is a table script in a JMP datatable.  I am trying to figure out how to get the RGB color values from a row in the JMP datable.  Basically, if the user color codes rows in JMP, my C# application needs to know the RGB color values for each row, is there a way with JSL programming to get the RGB color values for a row in a JMP table?

 

Thanks!


Chris

1 ACCEPTED SOLUTION

Accepted Solutions
Jeff_Perkinson
Community Manager Community Manager

Re: RGB colors of rows in JMP datatable

Colors and other information are stored in Row States. Check out the Color Of() function.

 

Here's an example from the Scripting Index:

 

Names Default To Here( 1 );
Open( "$SAMPLE_DATA/Big Class.jmp" ) << Color By Column( :height );
Color To RGB( Color Of( Row State( 3 ) ) );

 

 

 

-Jeff

View solution in original post

6 REPLIES 6
uday_guntupalli
Level VIII

Re: RGB colors of rows in JMP datatable

@ChrisM_X,

RowStates = dt << Get Row States() ;
ColorList = list() ;
for( i = 1 , i <= N Items(RowStates), i ++,
Insert Into(ColorList ,Color Of(RowStates[i]);
)
Best
Uday
uday_guntupalli
Level VIII

Re: RGB colors of rows in JMP datatable

https://community.jmp.com/t5/JMP-Scripts/RGB-Color-Matching-Script/ta-p/21784/jump-to/first-unread-m...

 

You can use the script from this post to translate the color values into colors . Hope this helps .

Best
Uday
Jeff_Perkinson
Community Manager Community Manager

Re: RGB colors of rows in JMP datatable

Colors and other information are stored in Row States. Check out the Color Of() function.

 

Here's an example from the Scripting Index:

 

Names Default To Here( 1 );
Open( "$SAMPLE_DATA/Big Class.jmp" ) << Color By Column( :height );
Color To RGB( Color Of( Row State( 3 ) ) );

 

 

 

-Jeff
ChrisM_X
Level III

Re: RGB colors of rows in JMP datatable

Here's what I ran:

 

Names Default To Here( 1 );
dt=current datatable(); \ 
dt<< Color By Column( :COL);
it=Color To RGB( Color Of( Row State( 3 ) ) );
show(it);

 

it = {0.988235294117647, 0.0431372549019608, 0.0431372549019608};

 

I was expecting 3 integers, so do I multiple these by 255 and round each number?

 

ChrisM_X
Level III

Re: RGB colors of rows in JMP datatable

I confirmed Jeff solution works!!

 

Names Default To Here( 1 );
dt=current datatable();
 dt<< Color By Column( :COL);
it=Color To RGB( Color Of( Row State( 1 ) ) );
show(it);

 

it = {0.164705882352941, 0.247058823529412, 1};

 

You just need to multiple 3 numbers by 255 to get RGB color values.

 

This forum rocks! Thanks for the quick replies!

 

JohnPonte
Staff (Retired)

Re: RGB colors of rows in JMP datatable

Just thought I'd add a note about the values being 0.0-1.0. This is called normalized color space. Often times we think of color values in the range 0 to 255, but that implies an 8-bit color space, where 8 bits are used to represent each of the red, green and blue color components. But not all color spaces are 8 bits. Some color spaces and some image formats actually support more than 8 bits for each color component, such as 16. That is why normalized color space is useful. It doesn't matter how many bits you are working with. You can simply multiply the normalized values by the appropriate value based on your color space (255 for 8-bit or 65535 for 16-bit). Also, in graphics or image analysis often times you are doing lots of math. With integer values every operation incurs some rounding error. With normalized color space there is no error incurred. Hope this helps explain why you might want to work in normalized color space and why JMP returns the values as 0.0-1.0.