<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to use variables in scale values (of a heat map) in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-use-variables-in-scale-values-of-a-heat-map/m-p/712318#M89558</link>
    <description>&lt;P&gt;Hi All,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the following example, a heat map was created using Big Class.jmp as an example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;gb=Graph Builder(
	Size( 686, 525 ),
	Show Control Panel( 0 ),
	Variables( X( :weight ), Y( :height ), Color( :age ) ),
	Elements( Heatmap( X, Y, Legend( 7 ) ) ),
	SendToReport(
		Dispatch(
			{},
			"400",
			ScaleBox,
			{Legend Model(
				7,
				Properties(
					0,
					{gradient( {Scale Values( [11 18] )} )},
					Item ID( "age", 1 )
				)
			)}
		)
	)
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Is there a way to use variables to define the gradient scale limits? Here's what I'd like to achieve:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;gradient_low=10;
gradient_high=19;

gb=Graph Builder(
	Size( 686, 525 ),
	Show Control Panel( 0 ),
	Variables( X( :weight ), Y( :height ), Color( :age ) ),
	Elements( Heatmap( X, Y, Legend( 7 ) ) ),
	SendToReport(
		Dispatch(
			{},
			"400",
			ScaleBox,
			{Legend Model(
				7,
				Properties(
					0,
					{gradient( {Scale Values( matrix({&lt;FONT face="arial black,avant garde" color="#FF0000"&gt;gradient_low&lt;/FONT&gt;, &lt;FONT face="arial black,avant garde" color="#FF0000"&gt;gradient_high&lt;/FONT&gt;}) )} )},
					Item ID( "age", 1 )
				)
			)}
		)
	)
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to use "grandient_low" and "gradient_high" to define the heatmap gradient limits.&lt;/P&gt;&lt;P&gt;I've tried to use eval() , eval expr(), etc. but haven't got it to work yet.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 23 Dec 2023 08:22:46 GMT</pubDate>
    <dc:creator>LatentDataTiger</dc:creator>
    <dc:date>2023-12-23T08:22:46Z</dc:date>
    <item>
      <title>How to use variables in scale values (of a heat map)</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-use-variables-in-scale-values-of-a-heat-map/m-p/712318#M89558</link>
      <description>&lt;P&gt;Hi All,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the following example, a heat map was created using Big Class.jmp as an example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;gb=Graph Builder(
	Size( 686, 525 ),
	Show Control Panel( 0 ),
	Variables( X( :weight ), Y( :height ), Color( :age ) ),
	Elements( Heatmap( X, Y, Legend( 7 ) ) ),
	SendToReport(
		Dispatch(
			{},
			"400",
			ScaleBox,
			{Legend Model(
				7,
				Properties(
					0,
					{gradient( {Scale Values( [11 18] )} )},
					Item ID( "age", 1 )
				)
			)}
		)
	)
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;Is there a way to use variables to define the gradient scale limits? Here's what I'd like to achieve:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;gradient_low=10;
gradient_high=19;

gb=Graph Builder(
	Size( 686, 525 ),
	Show Control Panel( 0 ),
	Variables( X( :weight ), Y( :height ), Color( :age ) ),
	Elements( Heatmap( X, Y, Legend( 7 ) ) ),
	SendToReport(
		Dispatch(
			{},
			"400",
			ScaleBox,
			{Legend Model(
				7,
				Properties(
					0,
					{gradient( {Scale Values( matrix({&lt;FONT face="arial black,avant garde" color="#FF0000"&gt;gradient_low&lt;/FONT&gt;, &lt;FONT face="arial black,avant garde" color="#FF0000"&gt;gradient_high&lt;/FONT&gt;}) )} )},
					Item ID( "age", 1 )
				)
			)}
		)
	)
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to use "grandient_low" and "gradient_high" to define the heatmap gradient limits.&lt;/P&gt;&lt;P&gt;I've tried to use eval() , eval expr(), etc. but haven't got it to work yet.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 23 Dec 2023 08:22:46 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-use-variables-in-scale-values-of-a-heat-map/m-p/712318#M89558</guid>
      <dc:creator>LatentDataTiger</dc:creator>
      <dc:date>2023-12-23T08:22:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to use variables in scale values (of a heat map)</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-use-variables-in-scale-values-of-a-heat-map/m-p/712340#M89560</link>
      <description>&lt;P&gt;You can&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1); 

dt = Open("$SAMPLE_DATA/Big Class.jmp");

gradient_low = 10;
gradient_high = 19;

gb = Eval(EvalExpr(dt &amp;lt;&amp;lt; Graph Builder(
	Size(686, 525),
	Show Control Panel(0),
	Variables(X(:weight), Y(:height), Color(:height)),
	Elements(Heatmap(X, Y, Legend(7))),
	SendToReport(
		Dispatch(
			{},
			"400",
			ScaleBox,
			{Legend Model(
				7,
				Properties(
					0,
					{gradient({Scale Values(Expr(Matrix({gradient_low, gradient_high})`))})},
					Item ID("height", 1)
				)
			)}
		)
	)
)));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;but I would most likely go through Legend Server&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1); 

dt = Open("$SAMPLE_DATA/Big Class.jmp");

gradient_low = 10;
gradient_high = 19;

gb = dt &amp;lt;&amp;lt; Graph Builder(
	Size(686, 525),
	Show Control Panel(0),
	Variables(X(:weight), Y(:height), Color(:height)),
	Elements(Heatmap(X, Y, Legend(7))),
);

m_gradient = Matrix({gradient_low, gradient_high})`;

server = gb &amp;lt;&amp;lt; Get Legend Server;
items = server &amp;lt;&amp;lt; Get Legend Items;
items[1][1] &amp;lt;&amp;lt; Set Properties({gradient({Scale Values(m_gradient)})});&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 23 Dec 2023 14:43:43 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-use-variables-in-scale-values-of-a-heat-map/m-p/712340#M89560</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2023-12-23T14:43:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to use variables in scale values (of a heat map)</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-use-variables-in-scale-values-of-a-heat-map/m-p/712343#M89561</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/54010"&gt;@LatentDataTiger&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What Jarmo states is correct.&amp;nbsp; However, he has made a change to your example that may not be noticed.&amp;nbsp; Your example uses the variable Age as the Color column, where Jarmo has changed it to Height.&amp;nbsp; The difference is, that Age has a Modeling Type of Ordinal, and Height has a&amp;nbsp; Modeling Type of Continuous.&amp;nbsp; An ordinal column will not honor the Gradient values.&amp;nbsp; To do this for age, you need to change the Modeling Type of the column.&amp;nbsp; Here is a script that&amp;nbsp; sets the specified color gradient for your original example.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = 
// Open Data Table: Big Class.jmp
// → Data Table( "Big Class" )
Open( "$SAMPLE_DATA/Big Class.jmp" );

dt:age &amp;lt;&amp;lt; modeling type( continuous );

gradient_low = 10;
gradient_high = 19;

Eval(
	Eval Expr(
		gb = Graph Builder(
			Size( 686, 525 ),
			Show Control Panel( 0 ),
			Variables( X( :weight ), Y( :height ), Color( :age ) ),
			Elements( Heatmap( X, Y, Legend( 7 ) ) ),
			SendToReport(
				Dispatch(
					{},
					"400",
					ScaleBox,
					{Legend Model(
						7,
						Properties(
							0,
							{gradient(
								{Scale Values( Matrix( {Expr( gradient_low ), Expr( gradient_high )} ) )}
							)},
							Item ID( "age", 1 )
						)
					)}
				)
			)
		)
	)
)
;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 23 Dec 2023 15:08:49 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-use-variables-in-scale-values-of-a-heat-map/m-p/712343#M89561</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2023-12-23T15:08:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to use variables in scale values (of a heat map)</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-use-variables-in-scale-values-of-a-heat-map/m-p/712347#M89563</link>
      <description>&lt;P&gt;Hi Jarmo and Jim&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm very interesting in learning the legend server technique, but the last line of your script didn't work. Here's the error I get:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;object not subscriptable in access or evaluation of 'items[1][1]' , items[1][/*###*/1]&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Can you please help check the last line in&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1); 

dt = Open("$SAMPLE_DATA/Big Class.jmp");

gradient_low = 10;
gradient_high = 19;

gb = dt &amp;lt;&amp;lt; Graph Builder(
	Size(686, 525),
	Show Control Panel(0),
	Variables(X(:weight), Y(:height), Color(:height)),
	Elements(Heatmap(X, Y, Legend(7))),
);

m_gradient = Matrix({gradient_low, gradient_high});

server = gb &amp;lt;&amp;lt; Get Legend Server;
items = server &amp;lt;&amp;lt; Get Legend Items;
items[1][1] &amp;lt;&amp;lt; Set Properties({gradient({Scale Values(m_gradient)})});&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&amp;nbsp;&lt;/P&gt;&lt;P&gt;rex&lt;/P&gt;</description>
      <pubDate>Sat, 23 Dec 2023 18:27:26 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-use-variables-in-scale-values-of-a-heat-map/m-p/712347#M89563</guid>
      <dc:creator>LatentDataTiger</dc:creator>
      <dc:date>2023-12-23T18:27:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to use variables in scale values (of a heat map)</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-use-variables-in-scale-values-of-a-heat-map/m-p/712350#M89566</link>
      <description>&lt;P&gt;Could maybe be version related. Which JMP version are you using? I'm using JMP 17.2.&lt;/P&gt;</description>
      <pubDate>Sat, 23 Dec 2023 19:21:27 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-use-variables-in-scale-values-of-a-heat-map/m-p/712350#M89566</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2023-12-23T19:21:27Z</dc:date>
    </item>
    <item>
      <title>Re: How to use variables in scale values (of a heat map)</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-use-variables-in-scale-values-of-a-heat-map/m-p/712352#M89568</link>
      <description>&lt;P&gt;I'm currently using JMP 15 and 16. I do have JMP 17, but some of my tool box that my colleagues developed wouldn't work in JMP17, so I decided to stay with 15 and 16.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 23 Dec 2023 19:48:26 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-use-variables-in-scale-values-of-a-heat-map/m-p/712352#M89568</guid>
      <dc:creator>LatentDataTiger</dc:creator>
      <dc:date>2023-12-23T19:48:26Z</dc:date>
    </item>
  </channel>
</rss>

