<?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 GraphBuilder Customization in JSL: Draw Line Segment DYnamically = Error &amp;quot;Invalid Matrix Token&amp;quot; in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/GraphBuilder-Customization-in-JSL-Draw-Line-Segment-DYnamically/m-p/251890#M49463</link>
    <description>&lt;P&gt;Hi JMP Community;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my quest to automate some of the more tedious tasks of annotation Graph Builder plots, I'm trying to dynamically add horizontal line segments between data groups using the following script. Unfortunately, it looks like I cannot use simple Expr () followed by Substitute (), and Eval () for this specific task. Note: I'm working with sensitive data therefore I will need to create mock DATA and STAT tables if necessary.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default to Here (1);

dt1 = Data Table ("DATA.JMP");
dt2 = Data Table ("STAT.JMP");

gbe = Expr (dt1 &amp;lt;&amp;lt; Graph Builder(
			Size( 699, 625 ),
			Variables(
				X( :R vs NR ),
				Y( _YS_ ),
				Color( :R vs NR )
			),
			Elements(
				Points( X, Y, Legend( 6 ) ),
				Box Plot( X, Y, Legend( 8 ), Outliers( 0 ) )
			),
			SendToReport(
				
				Dispatch(
					{},
					"Graph Builder",
					FrameBox,
					{Add Graphics Script(
						2,
						Description( "Script" ),
						Pen Size (3);
						
						
						// The following line of code return the error "Invalid Matrix Token"
						Line ([0.2,0.8], [Y1, Y1]);
						Text( Center Justified, {0.5, top1}, VAL1 );
						
						// The following line of code return the error "Invalid Matrix Token"
						Line ([0.2,1.8], [Y2, Y2]);
						Text( Center Justified, {1.0, top2}, VAL2 );
						
						// The following line of code return the error "Invalid Matrix Token"
						Line ([1.2,1.8], [Y1, Y1]);
						Text( Center Justified, {1.5, top1}, VAL3 );
					), Grid Line Order( 1 ), Reference Line Order( 3 )}
				)
			)
		)
);	

For (i = 749, i &amp;lt;= 750, i++, 

	YCOL = Column (dt1, i);
	PVAL1 = "p VAL = " ||  CHAR(format(Column (dt2, 2) [i-747],"PValue"));
	PVAL2 = "p VAL = " ||  CHAR(format(Column (dt2, 3) [i-747],"PValue"));
	PVAL3 = "p VAL = " ||  CHAR(format(Column (dt2, 4) [i-747],"PValue"));
	
	data_topy1 = Col Quantile (YCOL, 0.99);
	data_topy2 = Col Quantile (YCOL, 0.975);
	
	gbx = Substitute(Name Expr (gbe),
		Expr (_YS_), YCOL,
		Expr (VAL1), PVAL1,
		Expr (VAL2), PVAL2,
		Expr (VAL3), PVAL3,
		Expr (Y1), data_topy1,
		Expr (Y2), data_topy2
		);
		
	gb = Eval (gbx);
	
	gb &amp;lt;&amp;lt; journal;
	gb &amp;lt;&amp;lt; close window;
	

);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Any ideas would be welcome.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
    <pubDate>Fri, 09 Jun 2023 23:26:26 GMT</pubDate>
    <dc:creator>Thierry_S</dc:creator>
    <dc:date>2023-06-09T23:26:26Z</dc:date>
    <item>
      <title>GraphBuilder Customization in JSL: Draw Line Segment DYnamically = Error "Invalid Matrix Token"</title>
      <link>https://community.jmp.com/t5/Discussions/GraphBuilder-Customization-in-JSL-Draw-Line-Segment-DYnamically/m-p/251890#M49463</link>
      <description>&lt;P&gt;Hi JMP Community;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my quest to automate some of the more tedious tasks of annotation Graph Builder plots, I'm trying to dynamically add horizontal line segments between data groups using the following script. Unfortunately, it looks like I cannot use simple Expr () followed by Substitute (), and Eval () for this specific task. Note: I'm working with sensitive data therefore I will need to create mock DATA and STAT tables if necessary.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default to Here (1);

dt1 = Data Table ("DATA.JMP");
dt2 = Data Table ("STAT.JMP");

gbe = Expr (dt1 &amp;lt;&amp;lt; Graph Builder(
			Size( 699, 625 ),
			Variables(
				X( :R vs NR ),
				Y( _YS_ ),
				Color( :R vs NR )
			),
			Elements(
				Points( X, Y, Legend( 6 ) ),
				Box Plot( X, Y, Legend( 8 ), Outliers( 0 ) )
			),
			SendToReport(
				
				Dispatch(
					{},
					"Graph Builder",
					FrameBox,
					{Add Graphics Script(
						2,
						Description( "Script" ),
						Pen Size (3);
						
						
						// The following line of code return the error "Invalid Matrix Token"
						Line ([0.2,0.8], [Y1, Y1]);
						Text( Center Justified, {0.5, top1}, VAL1 );
						
						// The following line of code return the error "Invalid Matrix Token"
						Line ([0.2,1.8], [Y2, Y2]);
						Text( Center Justified, {1.0, top2}, VAL2 );
						
						// The following line of code return the error "Invalid Matrix Token"
						Line ([1.2,1.8], [Y1, Y1]);
						Text( Center Justified, {1.5, top1}, VAL3 );
					), Grid Line Order( 1 ), Reference Line Order( 3 )}
				)
			)
		)
);	

For (i = 749, i &amp;lt;= 750, i++, 

	YCOL = Column (dt1, i);
	PVAL1 = "p VAL = " ||  CHAR(format(Column (dt2, 2) [i-747],"PValue"));
	PVAL2 = "p VAL = " ||  CHAR(format(Column (dt2, 3) [i-747],"PValue"));
	PVAL3 = "p VAL = " ||  CHAR(format(Column (dt2, 4) [i-747],"PValue"));
	
	data_topy1 = Col Quantile (YCOL, 0.99);
	data_topy2 = Col Quantile (YCOL, 0.975);
	
	gbx = Substitute(Name Expr (gbe),
		Expr (_YS_), YCOL,
		Expr (VAL1), PVAL1,
		Expr (VAL2), PVAL2,
		Expr (VAL3), PVAL3,
		Expr (Y1), data_topy1,
		Expr (Y2), data_topy2
		);
		
	gb = Eval (gbx);
	
	gb &amp;lt;&amp;lt; journal;
	gb &amp;lt;&amp;lt; close window;
	

);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Any ideas would be welcome.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Fri, 09 Jun 2023 23:26:26 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/GraphBuilder-Customization-in-JSL-Draw-Line-Segment-DYnamically/m-p/251890#M49463</guid>
      <dc:creator>Thierry_S</dc:creator>
      <dc:date>2023-06-09T23:26:26Z</dc:date>
    </item>
    <item>
      <title>Re: GraphBuilder Customization in JSL: Draw Line Segment DYnamically = Error "Invalid Matrix Token"</title>
      <link>https://community.jmp.com/t5/Discussions/GraphBuilder-Customization-in-JSL-Draw-Line-Segment-DYnamically/m-p/251894#M49464</link>
      <description>Hi,&lt;BR /&gt;&lt;BR /&gt;I found a work around: instead of calling the Line() function, I replaced it with H Line () which does not require coordinates as a matrix.&lt;BR /&gt;&lt;BR /&gt;Best regards,&lt;BR /&gt;&lt;BR /&gt;TS</description>
      <pubDate>Wed, 11 Mar 2020 22:06:41 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/GraphBuilder-Customization-in-JSL-Draw-Line-Segment-DYnamically/m-p/251894#M49464</guid>
      <dc:creator>Thierry_S</dc:creator>
      <dc:date>2020-03-11T22:06:41Z</dc:date>
    </item>
    <item>
      <title>Re: GraphBuilder Customization in JSL: Draw Line Segment DYnamically = Error "Invalid Matrix Token"</title>
      <link>https://community.jmp.com/t5/Discussions/GraphBuilder-Customization-in-JSL-Draw-Line-Segment-DYnamically/m-p/251912#M49466</link>
      <description>&lt;P&gt;Your solution is a great one for this case since HLine and VLine are infinitely long. Here's an explanation and some alternatives.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The square bracket matrix is a compile-time constant and can't use variables. I've often used concatenation operators to build small matrices like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;a = 17;
b = 23;
Show( a || b, a |/ b );&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;a || b = [17 23];&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;a |/ b = [17, 23];&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;You can also use matrix():&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;matrix( {{a, b}, {a, a}} );&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;[17 23, 17 17]&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If your line needed to be bounded at 0.2 and 1.8, you could use a different form of line that takes lists rather than matrices:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;line( {x1,y1}, {x2,y2} )&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;The line function evaluates the expressions in each list.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And, if you needed an infinitely long line at some angle other than horizontal or vertical, you could use the YFunction():&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="YFunction" style="width: 578px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/22300iC909CC5235946E3F/image-size/large?v=v2&amp;amp;px=999" role="button" title="Capture.PNG" alt="YFunction" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;YFunction&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Mar 2020 23:39:23 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/GraphBuilder-Customization-in-JSL-Draw-Line-Segment-DYnamically/m-p/251912#M49466</guid>
      <dc:creator>Craige_Hales</dc:creator>
      <dc:date>2020-03-11T23:39:23Z</dc:date>
    </item>
  </channel>
</rss>

