<?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 Re: Help with relative positions of custom &amp;quot;legend&amp;quot; in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Help-with-relative-positions-of-custom-quot-legend-quot/m-p/944806#M109622</link>
    <description>&lt;P&gt;You might want to evaluate the x1 and y2 to the graphic script to avoid all sorts of possibly annoying issues.&lt;/P&gt;
&lt;LI-SPOILER&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

x1 = 300;
y2 = 36.7;

dt = Current Data Table();
gb = Eval(Substitute(
		Expr(dt &amp;lt;&amp;lt; Graph Builder(
			Size(510, 510),
			Show Legend(0),
			Graph Spacing(4),
			Variables(X(:"MeasTime [s]"n), Y(:"Weight diff [g]"n), Y(:"Height diff [mm]"n, Position(1), Side("Right"))),
			Elements(Line(X, Y(1), Legend(5)), Line(X, Y(2), Legend(6))),
			SendToReport(
				Dispatch({}, "MeasTime [s]", ScaleBox, {Inc(100)}),
				Dispatch({}, "Graph Builder", FrameBox,
					{Add Graphics Script(
						5,
						Description(""),
						Pen Color("Black");
						Line Style("Dashed");
						Line({_x1_, Y Origin()}, {_x1_, _y2_}, {X Origin(), _y2_}, {_x1_, _y2_});
						Pen Color("Red");
						Pen Size(2);
						Line Style("Solid");
						Line({X Origin() + 30, 0.9 * Y Range()}, {X Origin() + 130, 0.9 * Y Range()});
						Text({X Origin() + 150, 0.9 * Y Range() - 1}, "Weight");
						Pen Color("Blue");
						Pen Size(2);
						Line({X Origin() + 30, 0.85 * Y Range()}, {X Origin() + 130, 0.85 * Y Range()});
						Text({X Origin() + 150, 0.85 * Y Range() - 1}, "Height");
					)}
				)
			)
		)),
		Expr(_x1_), x1,
		Expr(_y2_), y2
	)
);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/LI-SPOILER&gt;</description>
    <pubDate>Tue, 28 Apr 2026 12:38:53 GMT</pubDate>
    <dc:creator>jthi</dc:creator>
    <dc:date>2026-04-28T12:38:53Z</dc:date>
    <item>
      <title>Help with relative positions of custom "legend"</title>
      <link>https://community.jmp.com/t5/Discussions/Help-with-relative-positions-of-custom-quot-legend-quot/m-p/944670#M109617</link>
      <description>&lt;P&gt;Hello JSL Scripters,&lt;/P&gt;
&lt;P&gt;&amp;nbsp; I'm working on a script, where I am adding my own "legend" to a graph. See screenshot below.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SDF1_1-1777315738647.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/101271iB33AFEF96859203F/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SDF1_1-1777315738647.png" alt="SDF1_1-1777315738647.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; I've added the lines and text by right clicking in the graph Customize...&amp;gt; and then adding a Script to the graph. The following JSL generates the "legend" as shown above.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Pen Color( "Red" );
Pen Size( 2 );
Line Style( "Solid" );
Line( [20, 100], [65, 65] );
Text( {120, 64}, "Weight" );
Pen Color( "Blue" );
Pen Size( 2 );
Line( [20, 100], [60, 60] );
Text( {120, 59}, "Height" );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp; But, what I'm really after is how to make the positions of the legend lines and text relative to, e.g. 90% the maximum value in the column :"Weight diff [g]"n. Data table is attached as well with script (non working script is commented out). I thought I could do it with something like an Eval(Substitute(Expr(...), Expr(__pos__), pos) type of JSL, but I keep getting the "Invalid Matrix Token" error. With something like the following:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

pos = Col Max( :"Weight diff[g]"n );

Eval(
	Substitute(
			Expr(
				Graph Builder(
					Size( 510, 510 ),
					Show Legend( 0 ),
					Graph Spacing( 4 ),
					Variables(
						X( :"MeasTime [s]"n ),
						Y( :"Weight diff [g]"n ),
						Y( :"Height diff [mm]"n, Position( 1 ), Side( "Right" ) )
					),
					Elements( Line( X, Y( 1 ), Legend( 5 ) ), Line( X, Y( 2 ), Legend( 6 ) ) ),
					SendToReport(
						Dispatch( {}, "MeasTime [s]", ScaleBox, {Inc( 100 )} ),
						Dispatch( {}, "Graph Builder", FrameBox,
							{Add Graphics Script(
								5,
								Description( "" ),
								Pen Color( "Red" );
								Pen Size( 2 );
								Line Style( "Solid" );
								Line( [20, 100], [__pos__, __pos__] );
								Text( {120, 64}, "Weight" );
								Pen Color( "Blue" );
								Pen Size( 2 );
								Line( [20, 100], [60, 60] );
								Text( {120, 59}, "Height" );
							)}
						)
					)
				)
			),
		Expr( __pos__ ), Eval( Round( 0.9 * pos, 0 ) )
	)
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp; I've even tried wrapping the y-coordinates of the Line() in "{ }", like: Line( [20, 100],[{_pos__,__pos__}]), and I still get the same error. I'd prefer to use a variable like "pos", that I get from a column rather than have it as an absolute value because the column values can change and I need the graph objects like the line and text to be able to move relative to what's being graphed.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Any suggestions on how to get around this error and/or what I'm missing -- this approach should work, but I'm just not catching why.&lt;/P&gt;
&lt;P&gt;Thanks!,&lt;/P&gt;
&lt;P&gt;DS&lt;/P&gt;</description>
      <pubDate>Mon, 27 Apr 2026 19:08:46 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Help-with-relative-positions-of-custom-quot-legend-quot/m-p/944670#M109617</guid>
      <dc:creator>SDF1</dc:creator>
      <dc:date>2026-04-27T19:08:46Z</dc:date>
    </item>
    <item>
      <title>Re: Help with relative positions of custom "legend"</title>
      <link>https://community.jmp.com/t5/Discussions/Help-with-relative-positions-of-custom-quot-legend-quot/m-p/944680#M109618</link>
      <description>&lt;P&gt;&lt;A href="https://www.jmp.com/support/help/en/19.1/#page/jmp/graphics-functions.shtml?os=win&amp;amp;source=application#ww2652629" target="_blank" rel="noopener"&gt;Y Range()&lt;/A&gt;&amp;nbsp;and &lt;A href="https://www.jmp.com/support/help/en/19.1/#page/jmp/graphics-functions.shtml?os=win&amp;amp;source=application#ww2652624" target="_blank" rel="noopener"&gt;Y Origin()&lt;/A&gt;&amp;nbsp;are most likely what you need.&lt;/P&gt;</description>
      <pubDate>Mon, 27 Apr 2026 19:19:16 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Help-with-relative-positions-of-custom-quot-legend-quot/m-p/944680#M109618</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2026-04-27T19:19:16Z</dc:date>
    </item>
    <item>
      <title>Re: Help with relative positions of custom "legend"</title>
      <link>https://community.jmp.com/t5/Discussions/Help-with-relative-positions-of-custom-quot-legend-quot/m-p/944681#M109619</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Thanks for the hint! With a minor modification, that helped out a lot and got me exactly what I needed, thanks!&lt;/P&gt;
&lt;P&gt;Thank for the quick reply, too!,&lt;/P&gt;
&lt;P&gt;DS&lt;/P&gt;</description>
      <pubDate>Mon, 27 Apr 2026 19:35:59 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Help-with-relative-positions-of-custom-quot-legend-quot/m-p/944681#M109619</guid>
      <dc:creator>SDF1</dc:creator>
      <dc:date>2026-04-27T19:35:59Z</dc:date>
    </item>
    <item>
      <title>Re: Help with relative positions of custom "legend"</title>
      <link>https://community.jmp.com/t5/Discussions/Help-with-relative-positions-of-custom-quot-legend-quot/m-p/944805#M109621</link>
      <description>&lt;P&gt;In case other readers are interested, I modified the JSL code (see below) to:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

x1=300;
y2=36.7;

Graph Builder(
	Size( 510, 510 ),
	Show Legend( 0 ),
	Graph Spacing( 4 ),
	Variables( X( :"MeasTime [s]"n ), Y( :"Weight diff [g]"n ), Y( :"Height diff [mm]"n, Position( 1 ), Side( "Right" ) ) ),
	Elements( Line( X, Y( 1 ), Legend( 5 ) ), Line( X, Y( 2 ), Legend( 6 ) ) ),
	SendToReport(
		Dispatch( {}, "MeasTime [s]", ScaleBox, {Inc( 100 )} ),
		Dispatch( {}, "Graph Builder", FrameBox,
			{Add Graphics Script(
				5,
				Description( "" ),
				Pen Color( "Black" );
				Line Style( "Dashed" );
				Line( {x1,YOrigin()}, {x1,y2}, {XOrigin(),y2}, {x1,y2} );
				Pen Color( "Red" );
				Pen Size( 2 );
				Line Style( "Solid" );
				Line( {XOrigin()+30, 0.9*YRange()}, {XOrigin()+130, 0.9*YRange()} );
				Text( {XOrigin()+150, 0.9*YRange()-1}, "Weight" );
				Pen Color( "Blue" );
				Pen Size( 2 );
				Line( {XOrigin()+30, 0.85*YRange()}, {XOrigin()+130, 0.85*YRange()} );
				Text( {XOrigin()+150, 0.85*YRange()-1}, "Height" );
			)}
		)
	)
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Which makes the following output:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SDF1_0-1777379422260.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/101347i146FBC59230A0C02/image-size/medium?v=v2&amp;amp;px=400" role="button" title="SDF1_0-1777379422260.png" alt="SDF1_0-1777379422260.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Which are demonstrations of exactly what I was looking to do -- create relative "legends" and specific reference lines that don't go across the entire length/height of the graph.&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Hopefully this can help others looking to do something similar.&lt;/P&gt;
&lt;P&gt;Hope this helps others!,&lt;/P&gt;
&lt;P&gt;DS&lt;/P&gt;</description>
      <pubDate>Tue, 28 Apr 2026 12:32:41 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Help-with-relative-positions-of-custom-quot-legend-quot/m-p/944805#M109621</guid>
      <dc:creator>SDF1</dc:creator>
      <dc:date>2026-04-28T12:32:41Z</dc:date>
    </item>
    <item>
      <title>Re: Help with relative positions of custom "legend"</title>
      <link>https://community.jmp.com/t5/Discussions/Help-with-relative-positions-of-custom-quot-legend-quot/m-p/944806#M109622</link>
      <description>&lt;P&gt;You might want to evaluate the x1 and y2 to the graphic script to avoid all sorts of possibly annoying issues.&lt;/P&gt;
&lt;LI-SPOILER&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);

x1 = 300;
y2 = 36.7;

dt = Current Data Table();
gb = Eval(Substitute(
		Expr(dt &amp;lt;&amp;lt; Graph Builder(
			Size(510, 510),
			Show Legend(0),
			Graph Spacing(4),
			Variables(X(:"MeasTime [s]"n), Y(:"Weight diff [g]"n), Y(:"Height diff [mm]"n, Position(1), Side("Right"))),
			Elements(Line(X, Y(1), Legend(5)), Line(X, Y(2), Legend(6))),
			SendToReport(
				Dispatch({}, "MeasTime [s]", ScaleBox, {Inc(100)}),
				Dispatch({}, "Graph Builder", FrameBox,
					{Add Graphics Script(
						5,
						Description(""),
						Pen Color("Black");
						Line Style("Dashed");
						Line({_x1_, Y Origin()}, {_x1_, _y2_}, {X Origin(), _y2_}, {_x1_, _y2_});
						Pen Color("Red");
						Pen Size(2);
						Line Style("Solid");
						Line({X Origin() + 30, 0.9 * Y Range()}, {X Origin() + 130, 0.9 * Y Range()});
						Text({X Origin() + 150, 0.9 * Y Range() - 1}, "Weight");
						Pen Color("Blue");
						Pen Size(2);
						Line({X Origin() + 30, 0.85 * Y Range()}, {X Origin() + 130, 0.85 * Y Range()});
						Text({X Origin() + 150, 0.85 * Y Range() - 1}, "Height");
					)}
				)
			)
		)),
		Expr(_x1_), x1,
		Expr(_y2_), y2
	)
);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/LI-SPOILER&gt;</description>
      <pubDate>Tue, 28 Apr 2026 12:38:53 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Help-with-relative-positions-of-custom-quot-legend-quot/m-p/944806#M109622</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2026-04-28T12:38:53Z</dc:date>
    </item>
  </channel>
</rss>

