<?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: Bivariate line style looping in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Bivariate-line-style-looping/m-p/470066#M71413</link>
    <description>&lt;P&gt;There are 2 issues.&amp;nbsp; You are using the index variable "i" in 2 different loops.&amp;nbsp; The second loop is changing the values of "i", which increases its value when the first loop starts the second loop.&amp;nbsp; It finds that "i" is greater than nitems(colnamex), and therefore it stops the loop. If you change "i" to "k" for&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;For(k = 1, k &amp;lt;= Nitems(colnamex), k++,
		bivplot_line1( colname[1],colnamex[ik) );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;the code will loop.&lt;/P&gt;
&lt;P&gt;The second issue is that you have 2 columns specified, sibling ages and age vector, which are not valid columns to be used in the bivariate.&amp;nbsp; Therefore, in your example, the code will only correctly run for 2 columns.&lt;/P&gt;</description>
    <pubDate>Wed, 16 Mar 2022 01:09:59 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2022-03-16T01:09:59Z</dc:date>
    <item>
      <title>Bivariate line style looping</title>
      <link>https://community.jmp.com/t5/Discussions/Bivariate-line-style-looping/m-p/469741#M71372</link>
      <description>&lt;P&gt;Hi all&lt;/P&gt;&lt;P&gt;I am trying to create a bivariate plot with group that needs different line styles. However, the group is varying depending on the given data. Here's a sample data, where it is grouped according to their occupation. How can I create a loop inside my function to create line style?&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;&amp;nbsp;                       biv = Bivariate( Y( :weight ), X( :height ),
										Group By(  :occupation ), &amp;lt;&amp;lt; Fit Line );								
						rbiv = biv &amp;lt;&amp;lt; report &amp;lt;&amp;lt; Show Points( 1 );
						
						ymin = rbiv[Axis Box(1)] &amp;lt;&amp;lt; Get Min;
						ymax = rbiv[Axis Box(1)] &amp;lt;&amp;lt; Get Max;
						xmin = rbiv[Axis Box(2)] &amp;lt;&amp;lt; Get Min;
						xmax = rbiv[Axis Box(2)] &amp;lt;&amp;lt; Get Max;
													
						
						rbiv[Frame Box( 1 )] &amp;lt;&amp;lt; {Frame Size( 205, 164 ), Marker Size( 2 ), Line Width Scale( 2 )};
						rbiv [Border Box (2)] &amp;lt;&amp;lt; Sides(0);
												
						rbiv[Axis Box( 1 )]  &amp;lt;&amp;lt; Format( "Best", 12 ) &amp;lt;&amp;lt; Tick Font( style( 1 ), size( 9 ) )
											 &amp;lt;&amp;lt; Show Major Grid( 1 ) &amp;lt;&amp;lt; Show Minor Grid( 1 ) &amp;lt;&amp;lt; Show Minor Ticks( 1 );
							
						rbiv[Axis Box( 2 )] &amp;lt;&amp;lt; Format( "Best", 12 ) &amp;lt;&amp;lt; Tick Font( style( 1 ), size( 9 ) )
											&amp;lt;&amp;lt; Show Major Grid( 1 ) &amp;lt;&amp;lt; Show Minor Grid( 1 ) &amp;lt;&amp;lt; Show Minor Ticks( 1 );
							
						rbiv[Text Edit Box( 1 )] &amp;lt;&amp;lt; Set Font Size( 10 ) &amp;lt;&amp;lt;	Set Font Style( "Bold" );
						rbiv[Text Edit Box( 2 )] &amp;lt;&amp;lt; Set Font Size( 10 ) &amp;lt;&amp;lt;	Set Font Style( "Bold" );
						rbiv[Outline Box( 2 )] &amp;lt;&amp;lt; Close All Below;
						rbiv[Outline Box( 2 )] &amp;lt;&amp;lt; Close All Like This;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 11 Jun 2023 11:22:37 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Bivariate-line-style-looping/m-p/469741#M71372</guid>
      <dc:creator>UserID16644</dc:creator>
      <dc:date>2023-06-11T11:22:37Z</dc:date>
    </item>
    <item>
      <title>Re: Bivariate line style looping</title>
      <link>https://community.jmp.com/t5/Discussions/Bivariate-line-style-looping/m-p/469760#M71373</link>
      <description>&lt;P&gt;You could use associative array to save the settings (most likely best would be to use associative array inside associative array, but I got lazy), then use Fit Where with EvalEvalExpr. You need to know settings for each of the groups in this solution, but there are ways around this depending on your data/solution:&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);

dt = Current Data Table();

biv = Bivariate(Y(:weight), X(:height), Group By(:occupation));
rbiv = biv &amp;lt;&amp;lt; report &amp;lt;&amp;lt; Show Points(1);

aa_line = Associative Array();

aa_line["Dentist"] = {"Yellow", "Dotted"};
aa_line["Doctor"] = {"Green", "DashDotDot"};
aa_line["Engineer"] = {"Red", "Solid"};

For Each({{key_occ, value_list}}, aa_line,
	Eval(Eval Expr(biv &amp;lt;&amp;lt; Fit Where(:occupation == Expr(key_occ), Fit Line({Line Color(Expr(value_list[1])), Line Style(Expr(value_list[2]))}))))
);

rbiv = biv &amp;lt;&amp;lt; report &amp;lt;&amp;lt; Show Points(1);

ymin = rbiv[Axis Box(1)] &amp;lt;&amp;lt; Get Min;
ymax = rbiv[Axis Box(1)] &amp;lt;&amp;lt; Get Max;
xmin = rbiv[Axis Box(2)] &amp;lt;&amp;lt; Get Min;
xmax = rbiv[Axis Box(2)] &amp;lt;&amp;lt; Get Max;

rbiv[Frame Box(1)] &amp;lt;&amp;lt; {Frame Size(205, 164), Marker Size(2), Line Width Scale(2)};
rbiv[Border Box(2)] &amp;lt;&amp;lt; Sides(0);
rbiv[Axis Box(1)] &amp;lt;&amp;lt; Format("Best", 12) &amp;lt;&amp;lt; Tick Font(style(1), size(9)) &amp;lt;&amp;lt; Show Major Grid(1) &amp;lt;&amp;lt; Show Minor Grid(1) &amp;lt;&amp;lt; Show Minor Ticks(1);
rbiv[Axis Box(2)] &amp;lt;&amp;lt; Format("Best", 12) &amp;lt;&amp;lt; Tick Font(style(1), size(9)) &amp;lt;&amp;lt; Show Major Grid(1) &amp;lt;&amp;lt; Show Minor Grid(1) &amp;lt;&amp;lt; Show Minor Ticks(1);
	
rbiv[Text Edit Box(1)] &amp;lt;&amp;lt; Set Font Size(10) &amp;lt;&amp;lt; Set Font Style("Bold");
rbiv[Text Edit Box(2)] &amp;lt;&amp;lt; Set Font Size(10) &amp;lt;&amp;lt; Set Font Style("Bold");
rbiv[Outline Box(2)] &amp;lt;&amp;lt; Close All Below;
rbiv[Outline Box(2)] &amp;lt;&amp;lt; Close All Like This;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Mar 2022 07:02:53 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Bivariate-line-style-looping/m-p/469760#M71373</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2022-03-15T07:02:53Z</dc:date>
    </item>
    <item>
      <title>Re: Bivariate line style looping</title>
      <link>https://community.jmp.com/t5/Discussions/Bivariate-line-style-looping/m-p/469762#M71374</link>
      <description>&lt;P&gt;Hi, I got an error. And also, I think this part should not be hard coded because like I said, the data is varying and changing from time to time&lt;/P&gt;&lt;PRE class="language-jsl"&gt;&lt;CODE&gt;aa_line = Associative Array();

aa_line["Dentist"] = {"Yellow", "Dotted"};
aa_line["Doctor"] = {"Green", "DashDotDot"};
aa_line["Engineer"] = {"Red", "Solid"};&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="UserID16644_0-1647328175997.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/40808i972EDA880FDB5CE2/image-size/medium?v=v2&amp;amp;px=400" role="button" title="UserID16644_0-1647328175997.png" alt="UserID16644_0-1647328175997.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Mar 2022 07:11:11 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Bivariate-line-style-looping/m-p/469762#M71374</guid>
      <dc:creator>UserID16644</dc:creator>
      <dc:date>2022-03-15T07:11:11Z</dc:date>
    </item>
    <item>
      <title>Re: Bivariate line style looping</title>
      <link>https://community.jmp.com/t5/Discussions/Bivariate-line-style-looping/m-p/469763#M71375</link>
      <description>&lt;P&gt;I have to ask, how would you create a line style if you don't know how to style the lines as in you don't know how many styles you need? &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That error is most likely caused by you using JMP version earlier than 16. The loop must be changed to regular For-loop instead of For Each (easy change).&lt;/P&gt;</description>
      <pubDate>Tue, 15 Mar 2022 07:16:36 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Bivariate-line-style-looping/m-p/469763#M71375</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2022-03-15T07:16:36Z</dc:date>
    </item>
    <item>
      <title>Re: Bivariate line style looping</title>
      <link>https://community.jmp.com/t5/Discussions/Bivariate-line-style-looping/m-p/469764#M71376</link>
      <description>&lt;P&gt;After creating your Bivariate report, find references to Line Segs by either using XPath or Find Segs and then do something to those references:&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);

dt = Current Data Table();

biv = dt &amp;lt;&amp;lt; Bivariate(Y(:weight), X(:height), Group By(:occupation), &amp;lt;&amp;lt;Fit Line);
rbiv = biv &amp;lt;&amp;lt; report &amp;lt;&amp;lt; Show Points(1);

rbiv[Outline Box(2)] &amp;lt;&amp;lt; Close All Below;
rbiv[Outline Box(2)] &amp;lt;&amp;lt; Close All Like This;

// get line seg references with XPath or Find Segs

// Xpath
//segs= rbiv2 &amp;lt;&amp;lt; XPath("//IfSeg[contains(@description, 'Linear Fit occupation')]");

// Find Segs
frame = rbiv[FrameBox(1)];
segs = (frame &amp;lt;&amp;lt; Find Segs(Line Seg()));

// Set the line properties by either looping over the references, or setting all at once by using segs as reference
// &amp;lt;&amp;lt; Set Line Color, &amp;lt;&amp;lt; Set Line Style, &amp;lt;&amp;lt; Set Line Width
segs &amp;lt;&amp;lt; Set Line Color("Green");
segs &amp;lt;&amp;lt; Set Line Style("Dotted");
segs &amp;lt;&amp;lt; Set Line Width(10);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 15 Mar 2022 07:45:43 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Bivariate-line-style-looping/m-p/469764#M71376</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2022-03-15T07:45:43Z</dc:date>
    </item>
    <item>
      <title>Re: Bivariate line style looping</title>
      <link>https://community.jmp.com/t5/Discussions/Bivariate-line-style-looping/m-p/469765#M71377</link>
      <description>&lt;P&gt;Here is another approach to the same issue&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
obj = dt &amp;lt;&amp;lt; Bivariate( Y( :weight ), X( :height ) );
styleList = {"Solid", "Dashed", "Dotted", "DashDot", "DashDotDot"};

Summarize( dt, groups = by( :sex ) );
mystyle = styleList[2];
For( i = 1, i &amp;lt;= N Items( groups ), i++,
	Eval(
		Parse(
			"obj &amp;lt;&amp;lt; Fit Where( :sex == \!"" || groups[i] || "\!", 
Fit Line( { Line Style( \!"" ||
			styleList[i] || "\!" )} ) )"
		)
	)
);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 15 Mar 2022 08:17:13 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Bivariate-line-style-looping/m-p/469765#M71377</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2022-03-15T08:17:13Z</dc:date>
    </item>
    <item>
      <title>Re: Bivariate line style looping</title>
      <link>https://community.jmp.com/t5/Discussions/Bivariate-line-style-looping/m-p/470062#M71410</link>
      <description>&lt;DIV class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;Hi txnelson,&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;The line legends works fine but when I tried putting this loop into my function that needs to generate multiple plots, it only generates one plot when it should be four (4 y columns). &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;Please help in looping the function&amp;nbsp;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class Families.jmp" );

bivplot_line1 = Function({ ycol, xcol }, {plot},
				
	biv = Bivariate( Y( Column( dt, ycol ) ), X( Column( dt, xcol )) );													
	rbiv = biv &amp;lt;&amp;lt; report &amp;lt;&amp;lt; Show Points( 1 );					
	styleList = {"Solid", "Dashed", "Dotted", "DashDot", "DashDotDot"};
	Summarize( dt, groups = by ( :Sex ) );
	mystyle = styleList[2];
		For( i = 1, i &amp;lt;= N Items( groups ), i++,
			Eval(
			  Parse( "biv &amp;lt;&amp;lt; Fit Where( :Sex == \!"" || groups[i] || "\!", 
				Fit Line( { Line Style( \!"" || styleList[i] || "\!" )} ) )"
			  )
			)
		);
     );
					
colname = {"weight"};
colnamex = {"age", "height", "siblings ages", "age vector"};

For(i = 1, i &amp;lt;= Nitems(colnamex), i++,
		bivplot_line1( colname[1],colnamex[i]) );	
		&lt;/CODE&gt;&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 16 Mar 2022 00:30:53 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Bivariate-line-style-looping/m-p/470062#M71410</guid>
      <dc:creator>UserID16644</dc:creator>
      <dc:date>2022-03-16T00:30:53Z</dc:date>
    </item>
    <item>
      <title>Re: Bivariate line style looping</title>
      <link>https://community.jmp.com/t5/Discussions/Bivariate-line-style-looping/m-p/470066#M71413</link>
      <description>&lt;P&gt;There are 2 issues.&amp;nbsp; You are using the index variable "i" in 2 different loops.&amp;nbsp; The second loop is changing the values of "i", which increases its value when the first loop starts the second loop.&amp;nbsp; It finds that "i" is greater than nitems(colnamex), and therefore it stops the loop. If you change "i" to "k" for&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;For(k = 1, k &amp;lt;= Nitems(colnamex), k++,
		bivplot_line1( colname[1],colnamex[ik) );&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;the code will loop.&lt;/P&gt;
&lt;P&gt;The second issue is that you have 2 columns specified, sibling ages and age vector, which are not valid columns to be used in the bivariate.&amp;nbsp; Therefore, in your example, the code will only correctly run for 2 columns.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2022 01:09:59 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Bivariate-line-style-looping/m-p/470066#M71413</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2022-03-16T01:09:59Z</dc:date>
    </item>
    <item>
      <title>Re: Bivariate line style looping</title>
      <link>https://community.jmp.com/t5/Discussions/Bivariate-line-style-looping/m-p/470067#M71414</link>
      <description>&lt;P&gt;Totally missed that! Thank you, I understood it completely&lt;/P&gt;</description>
      <pubDate>Wed, 16 Mar 2022 01:42:58 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Bivariate-line-style-looping/m-p/470067#M71414</guid>
      <dc:creator>UserID16644</dc:creator>
      <dc:date>2022-03-16T01:42:58Z</dc:date>
    </item>
  </channel>
</rss>

