<?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 dynamic horizontal lines with a shared y axis in a variability chart with grouped x axis with repeat values of different N? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/How-to-add-a-dynamic-horizontal-lines-with-a-shared-y-axis-in-a/m-p/762848#M94304</link>
    <description>&lt;P&gt;One fairly easy option is to create new column for your group.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Cars.jmp");

// for simplicity sake we drop Passenger
rows_to_delete = dt &amp;lt;&amp;lt; Get Rows Where(:"D/P"n == "Passenger");
dt &amp;lt;&amp;lt; Delete Rows(rows_to_delete);

varchart = dt &amp;lt;&amp;lt; Variability Chart(
	Y(:Head IC),
	X(:Protection, :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(:"D/P"n)
);

dt &amp;lt;&amp;lt; new column("Group", Character, Nominal, Formula(
	:"D/P"n || :Protection || :Make // don't add model here
));
dt_summary = dt &amp;lt;&amp;lt; Summary(
	Group(:Group),
	Max(:Wt),
	N Categories(:Model),
	Freq("None"),
	Weight("None"),
	statistics column name format("column"),
	Link to original data table(0),
	Invisible
);
weights = dt_summary[0, "Wt"];
counts = dt_summary[0, "Model"];
Close(dt_summary, no save);


fb = Report(varchart)[FrameBox(1)];
Eval(Eval Expr(
	fb &amp;lt;&amp;lt; Add Graphics Script(
		Local({refs = Expr(weights), counts = Expr(counts), i, sum = 0},
			Pen Size(2);
			Pen Color("Blue");
			Summation(i = 1, N Items(counts),
				Line(Eval List({sum, refs[i]}), Eval List({sum += counts[i], refs[i]}));
			);
		)
	)
));
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that this example has only one framebox as other D/P is dropped&lt;/P&gt;</description>
    <pubDate>Fri, 07 Jun 2024 11:21:45 GMT</pubDate>
    <dc:creator>jthi</dc:creator>
    <dc:date>2024-06-07T11:21:45Z</dc:date>
    <item>
      <title>How to add a dynamic horizontal lines with a shared y axis in a variability chart with grouped x axis with repeat values of different N?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-add-a-dynamic-horizontal-lines-with-a-shared-y-axis-in-a/m-p/762822#M94287</link>
      <description>&lt;P&gt;Hi all,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I wanted to create a new thread to differentiate based on my previous post:&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="_self"&gt;https://community.jmp.com/t5/Discussions/How-to-add-Dynamic-horizontal-line-by-shared-y-axis-among/m-p/622722&lt;/A&gt;. The same idea is to be applied where I would want a dynamic horizontal line across a variability chart, but unlike the previous solution that uses an associative array as there is one value per x, this case potentially has multiple values per x grouping in which graphing based on N per x doesn't work as the N is split between conditions and has to be drawn as such. This is where I am struggling to figure out how to do that and would appreciate someone with more graph scripting experience to aid if possible. Below is the desired output with hand drawn lines for example and the code for generating the graph is below as well.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the example below, Toyota is now split among :Protection in which there is N=8 and N=3 and likewise Ford is N=11 and N=3 for the groupings and I would like to ensure that both Toyota groups and Ford groups among others have a horizontal line with the value of Max(:Wt) as shown by the red and blue lines and all other's have an equally unique line as shown by the purple lines. Any idea of how to accomplish that would be fantastic. At the bottom of the post, the code given by&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/26363"&gt;@ErraticAttack&lt;/a&gt;&amp;nbsp;is posted as a wonderful template for grouping and graphing but since its an associative array it would say Toyota is N: 8+3 = 11 and likewise Ford is 11+3=14 wide and graph the ranges wrong as they are now split up. &lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="neelsrejan_0-1717728020584.png" style="width: 999px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/64974i1C01CCF3C53E7337/image-size/large?v=v2&amp;amp;px=999" role="button" title="neelsrejan_0-1717728020584.png" alt="neelsrejan_0-1717728020584.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Open( "$SAMPLE_DATA/Cars.jmp" );

rpt = dt &amp;lt;&amp;lt; Variability Chart(
	Y( :Head IC),
	X( :Protection, :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;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/26363"&gt;@ErraticAttack&lt;/a&gt;&amp;nbsp;'s code to aid my previous question.&amp;nbsp;&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 ),
	Where( :NAME("D/P") == "Driver" &amp;amp; :Protection == "manual belts" ),
);

//find groupings:
rows = dt &amp;lt;&amp;lt; Get Rows Where( :NAME("D/P") == "Driver" &amp;amp; :Protection == "manual belts" );
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 &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;&lt;P&gt;Thank you, truly appreciate any help!&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jun 2024 02:51:48 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-add-a-dynamic-horizontal-lines-with-a-shared-y-axis-in-a/m-p/762822#M94287</guid>
      <dc:creator>neelsrejan</dc:creator>
      <dc:date>2024-06-07T02:51:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a dynamic horizontal lines with a shared y axis in a variability chart with grouped x axis with repeat values of different N?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-add-a-dynamic-horizontal-lines-with-a-shared-y-axis-in-a/m-p/762848#M94304</link>
      <description>&lt;P&gt;One fairly easy option is to create new column for your group.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Cars.jmp");

// for simplicity sake we drop Passenger
rows_to_delete = dt &amp;lt;&amp;lt; Get Rows Where(:"D/P"n == "Passenger");
dt &amp;lt;&amp;lt; Delete Rows(rows_to_delete);

varchart = dt &amp;lt;&amp;lt; Variability Chart(
	Y(:Head IC),
	X(:Protection, :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(:"D/P"n)
);

dt &amp;lt;&amp;lt; new column("Group", Character, Nominal, Formula(
	:"D/P"n || :Protection || :Make // don't add model here
));
dt_summary = dt &amp;lt;&amp;lt; Summary(
	Group(:Group),
	Max(:Wt),
	N Categories(:Model),
	Freq("None"),
	Weight("None"),
	statistics column name format("column"),
	Link to original data table(0),
	Invisible
);
weights = dt_summary[0, "Wt"];
counts = dt_summary[0, "Model"];
Close(dt_summary, no save);


fb = Report(varchart)[FrameBox(1)];
Eval(Eval Expr(
	fb &amp;lt;&amp;lt; Add Graphics Script(
		Local({refs = Expr(weights), counts = Expr(counts), i, sum = 0},
			Pen Size(2);
			Pen Color("Blue");
			Summation(i = 1, N Items(counts),
				Line(Eval List({sum, refs[i]}), Eval List({sum += counts[i], refs[i]}));
			);
		)
	)
));
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Note that this example has only one framebox as other D/P is dropped&lt;/P&gt;</description>
      <pubDate>Fri, 07 Jun 2024 11:21:45 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-add-a-dynamic-horizontal-lines-with-a-shared-y-axis-in-a/m-p/762848#M94304</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2024-06-07T11:21:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a dynamic horizontal lines with a shared y axis in a variability chart with grouped x axis with repeat values of different N?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-add-a-dynamic-horizontal-lines-with-a-shared-y-axis-in-a/m-p/762915#M94335</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/14366"&gt;@jthi&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the solution, there is a quite elegant answer. As you mentioned, it is only for one Framebox and I would ideally like it to work for both frameboxes that the variability chart generates. I have adapted your code to this but am stuck in getting the horizontal lines to show up for both. If you could see the error and know how to go about it, that would be fantastic. Thanks!&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Cars.jmp");

varchart = dt &amp;lt;&amp;lt; Variability Chart(
	Y(:Head IC),
	X(:Protection, :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(:"D/P"n)
);

dt &amp;lt;&amp;lt; new column("Group", Character, Nominal, Formula(
	:"D/P"n || :Protection || :Make // don't add model here
));
dt_summary = dt &amp;lt;&amp;lt; Summary(
	Group(:Group),
	Max(:Wt),
	N Categories(:Model),
	Freq("None"),
	Weight("None"),
	statistics column name format("column"),
	Link to original data table(0),
	//Invisible
);

uniq = Associative Array( Column( dt, "D/P" ) &amp;lt;&amp;lt; GetValues ) &amp;lt;&amp;lt; GetKeys;

for(i = 1, i &amp;lt;= N Items(uniq), i++,
	dt_summary_subset = dt_summary &amp;lt;&amp;lt; Subset( Rows( dt_summary &amp;lt;&amp;lt; get rows where(Substr(:Group, 1, Length(uniq[i])) == uniq[i])), 
	Columns(), Not Linked);
	weights = dt_summary_subset[0, "Wt"];
	counts = dt_summary_subset[0, "Model"];
	
	fb = Report(varchart)[i][FrameBox(1)];
	Eval(Eval Expr(
		fb &amp;lt;&amp;lt; Add Graphics Script(
			Local({refs = Expr(weights), counts = Expr(counts), i, sum = 0},
				Pen Size(2);
				Pen Color("Blue");
				Summation(i = 1, N Items(counts),
					Line(Eval List({sum, refs[i]}), Eval List({sum += counts[i], refs[i]}));
				);
			)
		)
	));
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 08 Jun 2024 03:26:30 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-add-a-dynamic-horizontal-lines-with-a-shared-y-axis-in-a/m-p/762915#M94335</guid>
      <dc:creator>neelsrejan</dc:creator>
      <dc:date>2024-06-08T03:26:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a dynamic horizontal lines with a shared y axis in a variability chart with grouped x axis with repeat values of different N?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-add-a-dynamic-horizontal-lines-with-a-shared-y-axis-in-a/m-p/762916#M94336</link>
      <description>&lt;P&gt;On line 37 you need to change from&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;fb = Report(varchart)[i][FrameBox(1)];&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;to&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;fb = Report( varchart[i] )[FrameBox( 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;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 08 Jun 2024 03:52:42 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-add-a-dynamic-horizontal-lines-with-a-shared-y-axis-in-a/m-p/762916#M94336</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2024-06-08T03:52:42Z</dc:date>
    </item>
    <item>
      <title>Re: How to add a dynamic horizontal lines with a shared y axis in a variability chart with grouped x axis with repeat values of different N?</title>
      <link>https://community.jmp.com/t5/Discussions/How-to-add-a-dynamic-horizontal-lines-with-a-shared-y-axis-in-a/m-p/762917#M94337</link>
      <description>&lt;P&gt;Thank you Jim!&lt;/P&gt;</description>
      <pubDate>Sat, 08 Jun 2024 04:49:35 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/How-to-add-a-dynamic-horizontal-lines-with-a-shared-y-axis-in-a/m-p/762917#M94337</guid>
      <dc:creator>neelsrejan</dc:creator>
      <dc:date>2024-06-08T04:49:35Z</dc:date>
    </item>
  </channel>
</rss>

