cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
JLX
JLX
Level II

how to reverse color gradient

Hi, recently I set property to a column in big class data table and make this column has color gradient. code is like below:

 

:height<<set property( "color gradient", { "white to blue", range( colminimum(:height), colmaximum(:height) ) } );
:height<<color cell by value(1);

 

it works.

but after that I want to reverse the color scale, the code is like:

 

:height<<set property( "color gradient", { "white to blue", range( colminimum(:height), colmaximum(:height) ), "reverse scale" } );
:height<<color cell by value(1);

 

it fails.

is there anyone can help you how to reverse color scale applied on a column?

 

 

2 REPLIES 2
Thierry_S
Super User

Re: how to reverse color gradient

Hi,
The command to reverse gradient is: Reverse Gradient( 1 )
Best regards,
TS
Thierry R. Sornasse
txnelson
Super User

Re: how to reverse color gradient

The issues are:

  1. The requirement for the format of the code to set the Color Gradient, requires a List within a List, and you were leaving out the internal specification of the list 
    :height << set property(
    	"color gradient",
    	{"white to blue", Range( Col Minimum( :height ), Col Maximum( :height ) ), "reverse scale"}
    );
     The above code is missing the list that needs to be embedded into the Range() element.  The below code corrects the required addition for the internal list specification, but it still will not work, because of the 2nd issue following below
    :height << set property(
    	"color gradient",
    	{"white to blue", Range( { Col Minimum( :height ), Col Maximum( :height ) } ), "reverse scale"}
    );
  2. Secondly, when JMP sees a list, let alone a list within a list, it is going to accept it for exactly for what it is, and it will not do any processing for what is in the list....thus, col min() and col max() will not be evaluated.  So something needs to be done to handle this issue.  Below are 2 ways to handle this:
    Names Default To Here( 1 );
    dt = Open( "$sample_data/big class.jmp" );
    
    Eval(
    	Parse(
    		Eval Insert(
    			":height << set property(
    	\!"color gradient\!",
    	{\!"white to blue\!", Range({^colmin(:height)^,^colmax(:height)^ }) , \!"reverse scale\!"}
    );
    :height << color cell by value( 1 );"
    		)
    	)
    );
    
    // or
    
    Eval(
    	Substitute(
    			Expr(
    				:height << set property(
    					"color gradient",
    					{"white to blue", Range( {__min__, __max__} ), "reverse scale"}
    				);
    				:height << color cell by value( 1 );
    			),
    		Expr( __min__ ), Col Min( :height ),
    		Expr( __max__ ), Col Max( :height )
    	)
    );
Jim