<?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: How to add a graphics script dynamically to a variability chart with multiple frame boxes in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-add-a-graphics-script-dynamically-to-a-variability-chart/m-p/628040#M82640</link>
    <description>&lt;P&gt;Hi Mark, thanks for your reply! I was wondering what the passed value of "aaa" is in H Line() and Expr(), I don't see it assigned anywhere so I'm curious as what that does? Thank you!&lt;/P&gt;</description>
    <pubDate>Wed, 03 May 2023 02:48:40 GMT</pubDate>
    <dc:creator>neelsrejan</dc:creator>
    <dc:date>2023-05-03T02:48:40Z</dc:date>
    <item>
      <title>How to add a graphics script dynamically to a variability chart with multiple frame boxes</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-add-a-graphics-script-dynamically-to-a-variability-chart/m-p/626905#M82558</link>
      <description>&lt;P&gt;Hi all,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I have a variability chart that is split by a "BY" grouping, I asked this question in&amp;nbsp;&lt;A href="https://community.jmp.com/t5/Discussions/How-to-add-Dynamic-horizontal-line-by-shared-y-axis-among/m-p/622722" target="_blank"&gt;https://community.jmp.com/t5/Discussions/How-to-add-Dynamic-horizontal-line-by-shared-y-axis-among/m-p/622722&lt;/A&gt;&amp;nbsp;in which I understand how the graphics script added the respective lines based on the values from the data tables. I was trying to adapt this method to the variability chart with more frameboxes and am unable to figure out how to do it. My guess as of now is to put each By in a for loop and add the graphics to the respective framebox iteratively but am confused as how to do that as I am not sure how to access a framebox iteratively. Any help would be appreciated. Thanks!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please use the rpt from below and potentially add a for loop so that&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;//Potential for loop?&lt;BR /&gt;&lt;BR /&gt;rpt = dt &amp;lt;&amp;lt; Variability Chart(
	Y( :Head IC),
	X( :Make, :Model ),
	Analysis Type( "Choose best analysis (EMS REML Bayesian)" ),
	Show Range Bars( 0 ),
	Show Cell Means( 0 ),
	Std Dev Chart( 0 ),
	Points Jittered( 1 ),
	BY(:Name("D/P"))
);
&lt;BR /&gt;//Subset data table by "By" condition to add the correct lines based on the condition.&lt;BR /&gt;
tree = rpt &amp;lt;&amp;lt; Report;
Eval( Eval Expr(
tree[FrameBox( 1 )] &amp;lt;&amp;lt; Add Graphics Script(
	Local( {values = Expr( category average ), numbers = Expr( category number ), i, items, sum = 0},
		items = numbers &amp;lt;&amp;lt; Get Keys;
		Pen Size( 2 );
		Pen Color( "Blue" );
		Summation( i = 1, N Items( items ),
			Line( Eval List( {sum, values[items[i]]} ), Eval List( {sum += numbers[items[i]], values[items[i]]} ) );
			0
		)
	)
)
) 
)&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 11 Jun 2023 11:31:49 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-add-a-graphics-script-dynamically-to-a-variability-chart/m-p/626905#M82558</guid>
      <dc:creator>neelsrejan</dc:creator>
      <dc:date>2023-06-11T11:31:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a graphics script dynamically to a variability chart with multiple frame boxes</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-add-a-graphics-script-dynamically-to-a-variability-chart/m-p/626954#M82561</link>
      <description>&lt;P&gt;I'm not sure what exactly you're trying but would something like this work?&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names default to here( 1 );
dt = open("$SAMPLE_DATA\Big Class.jmp");
var_chart = dt &amp;lt;&amp;lt; Variability Chart( Y( :height ), X( :sex ), By( :age ), stddevchart(0) );
summarize(dt, ages = by(:age));
var_rpt = var_chart &amp;lt;&amp;lt; Report(); // this should just give a list of outlineboxes

for(i=1, i&amp;lt;=nitems(var_rpt), i++, 
	olb = var_rpt[i];
	framebox = olb[FrameBox(1)];
	framebox &amp;lt;&amp;lt; Add Graphics Script(
		Transparency( 0.5 );
		Pen Color( "blue" );
		Line([0,100], [62.5, 62.5]);
	);
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 Apr 2023 19:38:08 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-add-a-graphics-script-dynamically-to-a-variability-chart/m-p/626954#M82561</guid>
      <dc:creator>vince_faller</dc:creator>
      <dc:date>2023-04-27T19:38:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a graphics script dynamically to a variability chart with multiple frame boxes</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-add-a-graphics-script-dynamically-to-a-variability-chart/m-p/626961#M82562</link>
      <description>&lt;P&gt;I generally do not use variables in graphics scripts unless they are generated entirely internally to the frame box. Here is an example of my approach.&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 );

// open example
dt = Open( "$SAMPLE_DATA\Big Class.jmp" );

// launch variability chart
var_chart = dt &amp;lt;&amp;lt; Variability Chart( Y( :height ), X( :sex ), By( :age ), stddevchart( 0 ) );

// get summary in same order as By groups
Summarize( dt, age = by( :age ), avg = Mean( :height ) );
var_rpt = var_chart &amp;lt;&amp;lt; Report;

// iterate over list and add script using H Line() with literal argument
For( i = 1, i &amp;lt;= N Items( age ), i++,
	Eval(
		Substitute(
			Expr(
				var_rpt[i][FrameBox(1)] &amp;lt;&amp;lt; Add Graphics Script(
					Pen Color( "Red" ); H Line( aaa );
				);
			),
			Expr( aaa ), avg[i]
		)
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 Apr 2023 20:34:57 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-add-a-graphics-script-dynamically-to-a-variability-chart/m-p/626961#M82562</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2023-04-27T20:34:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a graphics script dynamically to a variability chart with multiple frame boxes</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-add-a-graphics-script-dynamically-to-a-variability-chart/m-p/627132#M82575</link>
      <description>&lt;P&gt;You can loop over the return result from the original &lt;CODE class=" language-jsl"&gt;Variability Chart( By( ... ) )&lt;/CODE&gt; command:&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/Cars.jmp" );

rpt = dt &amp;lt;&amp;lt; Variability Chart(
	Y( :Head IC),
	X( :Make, :Model ),
	Analysis Type( "Choose best analysis (EMS REML Bayesian)" ),
	Show Range Bars( 0 ),
	Show Cell Means( 0 ),
	Std Dev Chart( 0 ),
	Points Jittered( 1 ),
	By( :NAME("D/P"), :Protection ),
);

//find groupings:

subt = dt &amp;lt;&amp;lt; Summary( Group( :"D/P"n, :Protection ), Link to Original Data Table( 0 ) );
dps = subt:"D/P"n &amp;lt;&amp;lt; Get Values;
protections = subt:protection &amp;lt;&amp;lt; Get Values;
Close( subt, No Save );

For( t = 1, t &amp;lt;= N Items( dps ), t++,
	Eval( eval Expr(
	rows = dt &amp;lt;&amp;lt; Get Rows Where( :NAME("D/P") == Expr( dps[t] ) &amp;amp; :Protection == Expr( protections[t] ) );
	) );
	subt = dt &amp;lt;&amp;lt; Subset( Rows( rows ), Columns( :Make, :Model, :Wt ), Not Linked, Private );
	sumt = subt &amp;lt;&amp;lt; Summary( Group( :Make, Model ), Mean( :Wt ), Statistics Column Name Format( "Column" ), Link to Original Data Table( 0 ), Private );
	Close( subt, No Save );
	subt = sumt &amp;lt;&amp;lt; Summary( Group( :Make ), Mean( :Wt ), Statistics Column Name Format( "Column" ), Link to Original Data Table( 0 ), Private );
	Close( sumt, No Save );

	category number = [=&amp;gt;];
	category average = [=&amp;gt;];
	For Each Row( subt,
		category number[:Make] = :N Rows; // each least-significant category in a VariabilityPlot is exactly X=1 width on the hidden x-axis, starting at zero
		category average[:Make] = :Wt
	);
	Close( subt, No Save );

	tree = rpt[t] &amp;lt;&amp;lt; Report;
	Eval( Eval Expr(
	tree[FrameBox( 1 )] &amp;lt;&amp;lt; Add Graphics Script(
		Local( {values = Expr( category average ), numbers = Expr( category number ), i, items, sum = 0},
			items = numbers &amp;lt;&amp;lt; Get Keys;
			Pen Size( 2 );
			Pen Color( "Blue" );
			Summation( i = 1, N Items( items ),
				Line( Eval List( {sum, values[items[i]]} ), Eval List( {sum += numbers[items[i]], values[items[i]]} ) );
				0
			)
		)
	)
	) )
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 29 Apr 2023 18:22:21 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-add-a-graphics-script-dynamically-to-a-variability-chart/m-p/627132#M82575</guid>
      <dc:creator>ErraticAttack</dc:creator>
      <dc:date>2023-04-29T18:22:21Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a graphics script dynamically to a variability chart with multiple frame boxes</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-add-a-graphics-script-dynamically-to-a-variability-chart/m-p/628040#M82640</link>
      <description>&lt;P&gt;Hi Mark, thanks for your reply! I was wondering what the passed value of "aaa" is in H Line() and Expr(), I don't see it assigned anywhere so I'm curious as what that does? Thank you!&lt;/P&gt;</description>
      <pubDate>Wed, 03 May 2023 02:48:40 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-add-a-graphics-script-dynamically-to-a-variability-chart/m-p/628040#M82640</guid>
      <dc:creator>neelsrejan</dc:creator>
      <dc:date>2023-05-03T02:48:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a graphics script dynamically to a variability chart with multiple frame boxes</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-add-a-graphics-script-dynamically-to-a-variability-chart/m-p/628041#M82641</link>
      <description>&lt;P&gt;Hi Vince,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the response, I see that you have 62.5 hard coded, but do you know how you would adapt that to be dynamic to be the value in :wt?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 03 May 2023 02:49:46 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-add-a-graphics-script-dynamically-to-a-variability-chart/m-p/628041#M82641</guid>
      <dc:creator>neelsrejan</dc:creator>
      <dc:date>2023-05-03T02:49:46Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a graphics script dynamically to a variability chart with multiple frame boxes</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-add-a-graphics-script-dynamically-to-a-variability-chart/m-p/628172#M82651</link>
      <description>&lt;P&gt;The first expression is just a template. The expression 'aaa' is a placeholder for substitution. It is never evaluated. The Substitute() looks for Expr( aaa ) and substitutes the value.&lt;/P&gt;</description>
      <pubDate>Wed, 03 May 2023 13:58:26 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-add-a-graphics-script-dynamically-to-a-variability-chart/m-p/628172#M82651</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2023-05-03T13:58:26Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a graphics script dynamically to a variability chart with multiple frame boxes</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-add-a-graphics-script-dynamically-to-a-variability-chart/m-p/628336#M82665</link>
      <description>&lt;P&gt;I see, thanks for the explanation. Just out of curiosity, does jmp not evaluate values inside a function first. I have had trouble with this in the past but haven't been able to figure out what to search to understand the behavior having come from a python background. In my head H Line should just get avg[i] rather than have to substitute the value in but I get an error.&lt;/P&gt;&lt;P&gt;"invalid subscript (must be number or list of numbers) in access or evaluation of 'avg[ /*###*/i]' , avg[/*###*/i]"&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;For( i = 1, i &amp;lt;= N Items( age ), i++,
	Eval(
		Expr(
			var_rpt[i][FrameBox(1)] &amp;lt;&amp;lt; Add Graphics Script(
				Pen Color( "Red" ); H Line( avg[i] );
			);
			),
		)
	);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;I appreciate the help and any explanation, thanks!&lt;/P&gt;</description>
      <pubDate>Wed, 03 May 2023 21:14:08 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-add-a-graphics-script-dynamically-to-a-variability-chart/m-p/628336#M82665</guid>
      <dc:creator>neelsrejan</dc:creator>
      <dc:date>2023-05-03T21:14:08Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a graphics script dynamically to a variability chart with multiple frame boxes</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-add-a-graphics-script-dynamically-to-a-variability-chart/m-p/628476#M82680</link>
      <description>&lt;P&gt;Expressions are a powerful feature in the JMP Scripting Language. I recommend reading the &lt;A href="https://www.jmp.com/support/help/en/17.0/#page/jmp/programming-methods.shtml#" target="_self"&gt;documentation&lt;/A&gt; to become more familiar with how they work and how they might be used.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is the correct way to use your last approach:&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 );

// open example
dt = Open( "$SAMPLE_DATA\Big Class.jmp" );

// launch variability chart
var_chart = dt &amp;lt;&amp;lt; Variability Chart( Y( :height ), X( :sex ), By( :age ), stddevchart( 0 ) );

// get summary in same order as By groups
Summarize( dt, age = by( :age ), avg = Mean( :height ) );
var_rpt = var_chart &amp;lt;&amp;lt; Report;

// iterate over the list and add script using H Line() with the literal argument
For( i = 1, i &amp;lt;= N Items( age ), i++,
	Eval(
		Eval Expr(
			var_rpt[i][FrameBox(1)] &amp;lt;&amp;lt; Add Graphics Script(
				Pen Color( "Red" ); H Line( Expr( avg[i] ) );
			);
		);
	)
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 04 May 2023 13:20:36 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-add-a-graphics-script-dynamically-to-a-variability-chart/m-p/628476#M82680</guid>
      <dc:creator>Mark_Bailey</dc:creator>
      <dc:date>2023-05-04T13:20:36Z</dc:date>
    </item>
  </channel>
</rss>

