<?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: Adding annotations programmatically to an existing plot with JSL in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Adding-annotations-programmatically-to-an-existing-plot-with-JSL/m-p/729984#M91271</link>
    <description>&lt;P&gt;You can also make slight modification to Jim's script and use X Origin and Y Origin to set the location&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");

gb = dt &amp;lt;&amp;lt; Graph Builder(
	Size(528, 456),
	Show Control Panel(0),
	Variables(X(:weight), Y(:height)),
	Elements(Points(X, Y, Legend(3)), Smoother(X, Y, Legend(4)))
);

Report(gb)[FrameBox(1)] &amp;lt;&amp;lt; Add Graphics Script(
	Text Color("Red");
	Text({X Origin(), Y Origin()},
		"Metadata1 " || Format(Today(), "yyyymmdd") || "/OwnerName\!Npath c:tmp/graph-01.jrp"
	);
);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Tue, 05 Mar 2024 13:21:07 GMT</pubDate>
    <dc:creator>jthi</dc:creator>
    <dc:date>2024-03-05T13:21:07Z</dc:date>
    <item>
      <title>Adding annotations programmatically to an existing plot with JSL</title>
      <link>https://community.jmp.com/t5/Discussions/Adding-annotations-programmatically-to-an-existing-plot-with-JSL/m-p/729908#M91263</link>
      <description>&lt;P&gt;Hi all,&amp;nbsp;&lt;BR /&gt;I'm looking to add some metadata "fine print" &lt;EM&gt;through JSL&lt;/EM&gt; to my plot after I have made the plot in the Graph Builder.&lt;BR /&gt;Below are two examples of what I'd like to get done with JSL: Metadata 1 text field is in the plot area, Metadata 2 text field is outside it at the bottom of the graph. In the example plot I just added the text fields by the annotate tool in the GUI. However, I have hard time figuring out how to achieve this in JSL.&lt;BR /&gt;This is my first post here - thank you in advance for any help!&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="asj_0-1709629862836.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/61808i040D46CF27F25ABE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="asj_0-1709629862836.png" alt="asj_0-1709629862836.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Mar 2024 09:18:18 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Adding-annotations-programmatically-to-an-existing-plot-with-JSL/m-p/729908#M91263</guid>
      <dc:creator>asj</dc:creator>
      <dc:date>2024-03-05T09:18:18Z</dc:date>
    </item>
    <item>
      <title>Re: Adding annotations programmatically to an existing plot with JSL</title>
      <link>https://community.jmp.com/t5/Discussions/Adding-annotations-programmatically-to-an-existing-plot-with-JSL/m-p/729940#M91266</link>
      <description>&lt;P&gt;Here is some hardwired code that does what you specified&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="txnelson_0-1709635604883.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/61809i28D6F889227DC783/image-size/medium?v=v2&amp;amp;px=400" role="button" title="txnelson_0-1709635604883.png" alt="txnelson_0-1709635604883.png" /&gt;&lt;/span&gt;&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" );

gb = dt &amp;lt;&amp;lt; Graph Builder(
	Size( 528, 456 ),
	Show Control Panel( 0 ),
	Variables( X( :weight ), Y( :height ) ),
	Elements( Points( X, Y, Legend( 3 ) ), Smoother( X, Y, Legend( 4 ) ) )
);

// To add text within the graph one way is to use "Add Graphics Script" 
// to the graph
Report( gb )[Outline Box( 1 ), framebox( 1 )] &amp;lt;&amp;lt;
add graphics script(
	xMin = Report( gb )[axisbox( 1 )] &amp;lt;&amp;lt; get min;
	yMin = Report( gb )[axisbox( 2 )] &amp;lt;&amp;lt; get min;
	Text Color( "red" );
	Text(
		Right Justified,
		{xMin + 46, yMin + 1},
		"Metadata1 " || Format( Today(), "yyyymmdd" ) || "/OwnerName"
	);
	Text( Right Justified, {xMin + 32, yMin + .1}, "path c:tmp/graph-01.jrp" );
);

// Add Outside of the graph
Report( gb )[Outline Box( 1 )] &amp;lt;&amp;lt; Append(
	V List Box(
		Text Box( "Metadata1 " || Format( Today(), "yyyymmdd" ) || "/OwnerName" ),
		Text Box( "path c:tmp/graph-01.jrp" )
	)
);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Mar 2024 10:47:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Adding-annotations-programmatically-to-an-existing-plot-with-JSL/m-p/729940#M91266</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2024-03-05T10:47:09Z</dc:date>
    </item>
    <item>
      <title>Re: Adding annotations programmatically to an existing plot with JSL</title>
      <link>https://community.jmp.com/t5/Discussions/Adding-annotations-programmatically-to-an-existing-plot-with-JSL/m-p/729943#M91268</link>
      <description>&lt;P&gt;Thank you, Jim, this was fast!&lt;BR /&gt;&lt;BR /&gt;This almost takes me to the goalpost. I am now able to generate the texts like I want.&lt;BR /&gt;However, if a save a graph made in this way as a script I get something like this:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Graph Builder(
	Size( 528, 456 ),
	Show Control Panel( 0 ),
	Variables( X( :weight ), Y( :height ) ),
	Elements( Points( X, Y, Legend( 3 ) ), Smoother( X, Y, Legend( 4 ) ) ),
	SendToReport(
		Dispatch(
			{},
			"Graph Builder",
			FrameBox,
			{Add Graphics Script(
				5,
				Description( "" ),
				xMin = Report( gb )[axisbox( 1 )] &amp;lt;&amp;lt; get min;
				yMin = Report( gb )[axisbox( 2 )] &amp;lt;&amp;lt; get min;
				Text Color( "red" );
				Text(
					Right Justified,
					{xMin + 46, yMin + 1},
					"Metadata1 " || Format( Today(), "yyyymmdd" ) || "/OwnerName"
				);
				Text(
					Right Justified,
					{xMin + 32, yMin + 0.1},
					"path c:tmp/graph-01.jrp"
				);
			)}
		)
	)
)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;and if i try to run the script I get an error&lt;BR /&gt;&amp;gt;object not subscriptable in access or evaluation of 'Report(gb)[ /*###*/axisbox(1)]' , Report( gb )[/*###*/axisbox( 1 )]&lt;BR /&gt;which i think makes sense, since the "gb" is not defined within the script. Is there any way around this problem?&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 05 Mar 2024 12:29:39 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Adding-annotations-programmatically-to-an-existing-plot-with-JSL/m-p/729943#M91268</guid>
      <dc:creator>asj</dc:creator>
      <dc:date>2024-03-05T12:29:39Z</dc:date>
    </item>
    <item>
      <title>Re: Adding annotations programmatically to an existing plot with JSL</title>
      <link>https://community.jmp.com/t5/Discussions/Adding-annotations-programmatically-to-an-existing-plot-with-JSL/m-p/729944#M91269</link>
      <description>&lt;P&gt;You are missing the variable "gb" which&amp;nbsp; points to the Graph Builder instance&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;gb = Graph Builder(&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Mar 2024 12:35:58 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Adding-annotations-programmatically-to-an-existing-plot-with-JSL/m-p/729944#M91269</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2024-03-05T12:35:58Z</dc:date>
    </item>
    <item>
      <title>Re: Adding annotations programmatically to an existing plot with JSL</title>
      <link>https://community.jmp.com/t5/Discussions/Adding-annotations-programmatically-to-an-existing-plot-with-JSL/m-p/729984#M91271</link>
      <description>&lt;P&gt;You can also make slight modification to Jim's script and use X Origin and Y Origin to set the location&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");

gb = dt &amp;lt;&amp;lt; Graph Builder(
	Size(528, 456),
	Show Control Panel(0),
	Variables(X(:weight), Y(:height)),
	Elements(Points(X, Y, Legend(3)), Smoother(X, Y, Legend(4)))
);

Report(gb)[FrameBox(1)] &amp;lt;&amp;lt; Add Graphics Script(
	Text Color("Red");
	Text({X Origin(), Y Origin()},
		"Metadata1 " || Format(Today(), "yyyymmdd") || "/OwnerName\!Npath c:tmp/graph-01.jrp"
	);
);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Mar 2024 13:21:07 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Adding-annotations-programmatically-to-an-existing-plot-with-JSL/m-p/729984#M91271</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-03-05T13:21:07Z</dc:date>
    </item>
    <item>
      <title>Re: Adding annotations programmatically to an existing plot with JSL</title>
      <link>https://community.jmp.com/t5/Discussions/Adding-annotations-programmatically-to-an-existing-plot-with-JSL/m-p/729986#M91273</link>
      <description>&lt;P&gt;Well this is true, but this is how the script is saved by JMP when I for example use the "save script ... to data table".&lt;BR /&gt;However I found a solution using Eval and EvalExpr from here:&lt;BR /&gt;&lt;A href="https://community.jmp.com/t5/Discussions/GraphBuilder-gt-FrameBox-lt-lt-Add-Graphics-Script-V-Line-x-y1/td-p/366991" target="_self"&gt;https://community.jmp.com/t5/Discussions/GraphBuilder-gt-FrameBox-lt-lt-Add-Graphics-Script-V-Line-x-y1/td-p/366991&lt;/A&gt;&lt;BR /&gt;this way I got it all to work:&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" );

gb = dt &amp;lt;&amp;lt; Graph Builder(
	Size( 528, 456 ),
	Show Control Panel( 0 ),
	Variables( X( :weight ), Y( :height ) ),
	Elements( Points( X, Y, Legend( 3 ) ), Smoother( X, Y, Legend( 4 ) ) )
);

yMin = Report( gb )[axisbox( 1 )] &amp;lt;&amp;lt; get min;
yMin = Report( gb )[axisbox( 2 )] &amp;lt;&amp;lt; get min;

//I need the values "hard-coded"" in the new graphics script to be added =&amp;gt; hence i
//need to use the Eval(EvalExpr( .. )) trick from
//https://community.jmp.com/t5/Discussions/GraphBuilder-gt-FrameBox-lt-lt-Add-Graphics-Script-V-Line-x-y1/td-p/366991
Eval(EvalExpr(
Report( gb )[Outline Box( 1 ), framebox( 1 )] &amp;lt;&amp;lt;
add graphics script(
	Text Color( "red" );
	Text( {expr(xMin),expr(yMin)}, "path c:tmp/graph-01.jrp" );
)
));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 05 Mar 2024 13:34:50 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Adding-annotations-programmatically-to-an-existing-plot-with-JSL/m-p/729986#M91273</guid>
      <dc:creator>asj</dc:creator>
      <dc:date>2024-03-05T13:34:50Z</dc:date>
    </item>
  </channel>
</rss>

