<?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: fit a spline with a variable in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/fit-a-spline-with-a-variable/m-p/73152#M35713</link>
    <description>&lt;P&gt;Since no more information was provided, I am guessing at what you need. Maybe you only needed to make your spline statement using and expresssion.&amp;nbsp; &amp;nbsp;This script allows one or multiple legend values to be selected. It uses:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;The default linking of an invisible summary table to manage legend selections. This invisible table is closed when the bivariate is closed.&lt;/LI&gt;&lt;LI&gt;A rowstate handler function to clear out previous splines and only show those selected from the legend.&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;It's been tested on JMP14.1 and JMP13.21.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 355px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/12439iFF59F543ACF23194/image-size/medium?v=v2&amp;amp;px=400" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default to Here(1);

dt0 = Open("$sample_data/SATByYear.jmp");

//create a smaller table too many groupings
dt0 &amp;lt;&amp;lt; Select Where( :Region=="Plains" | :Region=="South");
dt = dt0 &amp;lt;&amp;lt; Subset(All Columns, Output Tablename("SomeStates"));

close(dt0,NoSave);  

//change Year from Ordinal to Continuous to create a Bivariate report
dt:Year &amp;lt;&amp;lt; Set Modeling Type("Continuous");  

//The legend column is hardcoded. It seemed like you know how to do that.
//I created a new column just for interest
gCol = dt &amp;lt;&amp;lt; New Column("Region_State", character);
gcol &amp;lt;&amp;lt; set each value( substr(:Region,1,1) || "_" || :State);
dt &amp;lt;&amp;lt; Color by Column(:Region);

//Create the Bivariate report
biv = dt &amp;lt;&amp;lt;  Bivariate( Y(:SAT Math), X(:Year) );
//Add a row legion for the legend column. For your script you woudl have to remove the
//previous legend and add a new one.
rbiv = Report(biv);
fb = rbiv[FrameBox(1)];

//You would likely change both color and symbol, just made it different for interest
fb &amp;lt;&amp;lt; Row Legend(:Region_State, color(0), Marker(1));

//It will be easier to create the Spline with a By group. The Summary table simplifies the task. 
sumdt =dt &amp;lt;&amp;lt; Summary(Group(:Region_State), Invisible);
//if the biv winow is closed/ close summary table
biv &amp;lt;&amp;lt; On Close (Close(sumdt, NoSave)); //closes the summary table and row state handler

//Create a row state handler function, that defines the tasks when rge rowstate of sumdt changes. 
f = Function({a},
	_c = biv &amp;lt;&amp;lt; Xpath("//IfBox[@isTrue='true']");
    for(i=nitems(_c), i&amp;gt;=1, i--,  biv &amp;lt;&amp;lt; (curve[i] &amp;lt;&amp;lt; Remove Fit) ); 
    _yy = sumdt &amp;lt;&amp;lt; get selected rows();
    if(nrow(_yy)&amp;gt;0,
       _xx = (sumdt:Region_State&amp;lt;&amp;lt;get values)[_yy];
       _zz = (sumdt &amp;lt;&amp;lt;get rowstates )[_yy];
	   for(i = 1, i&amp;lt;=nitems(_xx), i++,
	   _clr = Color to RGB(ColorOf(AsRowState(_zz[i])));
	   //show(_yy[i], _xx[i], _zz[i], _clr[i] );
	   Eval(EvalExpr(biv &amp;lt;&amp;lt; Fit Where(Expr(gcol)[]==Expr(_xx[i]), Fit Spline(0.1, Standardized,
            {Line Color(Expr(_clr) ), Line Width( 5 )}) ) ) );
       );
    );
);

rs = sumdt&amp;lt;&amp;lt;Make Row State Handler(f);
//Use Ctrl+ click to deselect or select multiple states [processes] &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 16 Sep 2018 18:26:34 GMT</pubDate>
    <dc:creator>gzmorgan0</dc:creator>
    <dc:date>2018-09-16T18:26:34Z</dc:date>
    <item>
      <title>fit a spline with a variable</title>
      <link>https://community.jmp.com/t5/Discussions/fit-a-spline-with-a-variable/m-p/72479#M35625</link>
      <description>&lt;P&gt;Hey,&lt;/P&gt;
&lt;P&gt;I build a chart with dinamic legend that the user can choose by radio box.&lt;/P&gt;
&lt;P&gt;The name of the legend that the user choose is saved as 'L1' variable.&lt;/P&gt;
&lt;P&gt;I want to add a function that when a user clicks on one value from the legend the spline of this value become more bold.&lt;/P&gt;
&lt;P&gt;I add a state handler to the file and tried to use this script:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;rsh1 = test1 &amp;lt;&amp;lt; Make Row State Handler( dt, rsupdate1 );

rsupdate1 =function({},
SplineSelectlist=dt:L1[dt&amp;lt;&amp;lt;get selected rows];
SplineSelect=SplineSelectlist[1];
// MYSPLINE=EVAL(SplineSelect);
box8&amp;lt;&amp;lt;Fit Where(
:eval(L1) == eval(SplineSelect),
Fit Spline(
0.1,
Standardized,
{Line Width( 5 )}
));
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The 'fit where' state doesnt recognize the variable.&lt;/P&gt;
&lt;P&gt;I also tried with 'parse' or without 'eval' or to define the variable before-&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;mycolumn= eval(L1);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;but none of them work.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I will be glad to hear if there's a solution to this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Thank you.&lt;/P&gt;</description>
      <pubDate>Thu, 13 Sep 2018 14:15:01 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/fit-a-spline-with-a-variable/m-p/72479#M35625</guid>
      <dc:creator>shiro</dc:creator>
      <dc:date>2018-09-13T14:15:01Z</dc:date>
    </item>
    <item>
      <title>Re: fit a spline with a variable</title>
      <link>https://community.jmp.com/t5/Discussions/fit-a-spline-with-a-variable/m-p/72910#M35700</link>
      <description>&lt;P&gt;There is not enough information here to respond, and there are some syntax issues.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does the graph have splines already drawn and you want the selected item highlighted?&lt;/P&gt;&lt;P&gt;Are you using GraphBuilder or Bivariate (Fit Y by X)?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;:eval(L1) is not proper syntax.&lt;/P&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>Fri, 14 Sep 2018 22:06:00 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/fit-a-spline-with-a-variable/m-p/72910#M35700</guid>
      <dc:creator>gzmorgan0</dc:creator>
      <dc:date>2018-09-14T22:06:00Z</dc:date>
    </item>
    <item>
      <title>Re: fit a spline with a variable</title>
      <link>https://community.jmp.com/t5/Discussions/fit-a-spline-with-a-variable/m-p/73152#M35713</link>
      <description>&lt;P&gt;Since no more information was provided, I am guessing at what you need. Maybe you only needed to make your spline statement using and expresssion.&amp;nbsp; &amp;nbsp;This script allows one or multiple legend values to be selected. It uses:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;The default linking of an invisible summary table to manage legend selections. This invisible table is closed when the bivariate is closed.&lt;/LI&gt;&lt;LI&gt;A rowstate handler function to clear out previous splines and only show those selected from the legend.&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;It's been tested on JMP14.1 and JMP13.21.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 355px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/12439iFF59F543ACF23194/image-size/medium?v=v2&amp;amp;px=400" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default to Here(1);

dt0 = Open("$sample_data/SATByYear.jmp");

//create a smaller table too many groupings
dt0 &amp;lt;&amp;lt; Select Where( :Region=="Plains" | :Region=="South");
dt = dt0 &amp;lt;&amp;lt; Subset(All Columns, Output Tablename("SomeStates"));

close(dt0,NoSave);  

//change Year from Ordinal to Continuous to create a Bivariate report
dt:Year &amp;lt;&amp;lt; Set Modeling Type("Continuous");  

//The legend column is hardcoded. It seemed like you know how to do that.
//I created a new column just for interest
gCol = dt &amp;lt;&amp;lt; New Column("Region_State", character);
gcol &amp;lt;&amp;lt; set each value( substr(:Region,1,1) || "_" || :State);
dt &amp;lt;&amp;lt; Color by Column(:Region);

//Create the Bivariate report
biv = dt &amp;lt;&amp;lt;  Bivariate( Y(:SAT Math), X(:Year) );
//Add a row legion for the legend column. For your script you woudl have to remove the
//previous legend and add a new one.
rbiv = Report(biv);
fb = rbiv[FrameBox(1)];

//You would likely change both color and symbol, just made it different for interest
fb &amp;lt;&amp;lt; Row Legend(:Region_State, color(0), Marker(1));

//It will be easier to create the Spline with a By group. The Summary table simplifies the task. 
sumdt =dt &amp;lt;&amp;lt; Summary(Group(:Region_State), Invisible);
//if the biv winow is closed/ close summary table
biv &amp;lt;&amp;lt; On Close (Close(sumdt, NoSave)); //closes the summary table and row state handler

//Create a row state handler function, that defines the tasks when rge rowstate of sumdt changes. 
f = Function({a},
	_c = biv &amp;lt;&amp;lt; Xpath("//IfBox[@isTrue='true']");
    for(i=nitems(_c), i&amp;gt;=1, i--,  biv &amp;lt;&amp;lt; (curve[i] &amp;lt;&amp;lt; Remove Fit) ); 
    _yy = sumdt &amp;lt;&amp;lt; get selected rows();
    if(nrow(_yy)&amp;gt;0,
       _xx = (sumdt:Region_State&amp;lt;&amp;lt;get values)[_yy];
       _zz = (sumdt &amp;lt;&amp;lt;get rowstates )[_yy];
	   for(i = 1, i&amp;lt;=nitems(_xx), i++,
	   _clr = Color to RGB(ColorOf(AsRowState(_zz[i])));
	   //show(_yy[i], _xx[i], _zz[i], _clr[i] );
	   Eval(EvalExpr(biv &amp;lt;&amp;lt; Fit Where(Expr(gcol)[]==Expr(_xx[i]), Fit Spline(0.1, Standardized,
            {Line Color(Expr(_clr) ), Line Width( 5 )}) ) ) );
       );
    );
);

rs = sumdt&amp;lt;&amp;lt;Make Row State Handler(f);
//Use Ctrl+ click to deselect or select multiple states [processes] &lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 16 Sep 2018 18:26:34 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/fit-a-spline-with-a-variable/m-p/73152#M35713</guid>
      <dc:creator>gzmorgan0</dc:creator>
      <dc:date>2018-09-16T18:26:34Z</dc:date>
    </item>
    <item>
      <title>Re: fit a spline with a variable</title>
      <link>https://community.jmp.com/t5/Discussions/fit-a-spline-with-a-variable/m-p/208252#M41861</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd like to join in on the initial querry, since I've encountered a similar problem.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to create a "legand chooser button" where each value is a column name.&lt;/P&gt;&lt;P&gt;when choosing a value, the &lt;STRONG&gt;leagend&lt;/STRONG&gt; and &lt;STRONG&gt;spline&lt;/STRONG&gt; of my Bivariate x/y graph will be updated according to the chosen value (the previous legend and the spline will be erased).&lt;/P&gt;&lt;P&gt;However, I don't know how to adapt the "fit where" function to recive a &lt;U&gt;variable&lt;/U&gt; as input (the variable being the selected column name), as is described in the original query here.&lt;/P&gt;&lt;P&gt;Thanks, Hadar&lt;/P&gt;</description>
      <pubDate>Tue, 14 May 2019 11:45:03 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/fit-a-spline-with-a-variable/m-p/208252#M41861</guid>
      <dc:creator>vsr</dc:creator>
      <dc:date>2019-05-14T11:45:03Z</dc:date>
    </item>
    <item>
      <title>Re: fit a spline with a variable</title>
      <link>https://community.jmp.com/t5/Discussions/fit-a-spline-with-a-variable/m-p/208274#M41864</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/13764"&gt;@vsr&lt;/a&gt;, your task is different from&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/11902"&gt;@shiro&lt;/a&gt;'s task.&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/11902"&gt;@shiro&lt;/a&gt;&amp;nbsp;needed to fit a spline by different &lt;STRONG&gt;values&lt;/STRONG&gt; of one column.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Look at the example I provided, the curve shown is is different for different &lt;STRONG&gt;values&lt;/STRONG&gt; of :State.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;From your description, you seem to want different &lt;STRONG&gt;columns,&lt;/STRONG&gt;&amp;nbsp;not different values of one column. Fit Where is selecting on &lt;STRONG&gt;values&lt;/STRONG&gt; of a chosen column. Without more details of what specifically you are trying to do, I can only guess.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;My guess is that you might want to plot different Y's or different X's, that is columns. If that is teh case JMP has a builtin solution, called a column switcher.&amp;nbsp; Just in case, that is what you are needing, I provided an example screenshot and script.&amp;nbsp; If this is not what you need, please provide more details.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 726px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/17214i00E878D93052B7F5/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&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 = Open("$sample_data/TechStock.jmp");

biv = dt &amp;lt;&amp;lt; Bivariate(
	Y( :Name( "Adj. Close*" ) ),
	X( :Date ),
	Fit Spline( 10, {Line Color( {212, 73, 88} )} ),
	Column Switcher(
		:Name( "Adj. Close*" ),
		{:Open, :High, :Low, :Close, :Name( "Adj. Close*" )}
	)
);
//select a Y column one at a time or select the "play/go" button and JMP will cycle thru all columns&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 14 May 2019 13:11:52 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/fit-a-spline-with-a-variable/m-p/208274#M41864</guid>
      <dc:creator>gzmorgan0</dc:creator>
      <dc:date>2019-05-14T13:11:52Z</dc:date>
    </item>
  </channel>
</rss>

