<?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 Reference line from axis to specific value in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Reference-line-from-axis-to-specific-value/m-p/48906#M27784</link>
    <description>&lt;P&gt;I am trying to script a graph that shows the predicted value on the y-axis from some specified value on the x-axis on a soft curve. I have managed to pull out the prediction formula and obtain the relevant values&amp;nbsp;to define reference lines. However to communicate this effectively i would like the reference lines to stop at the curve and preferable to be dashed. The above image is as far as I have been able to go with jsl scripting. Below is where I would like to end up.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Untitled.png" style="width: 366px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/8770i49A36E1FED31A684/image-size/large?v=v2&amp;amp;px=999" role="button" title="Untitled.png" alt="Untitled.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Picture1.png" style="width: 566px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/8771i2F61B3D667522B16/image-size/large?v=v2&amp;amp;px=999" role="button" title="Picture1.png" alt="Picture1.png" /&gt;&lt;/span&gt;&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>Wed, 20 Dec 2017 10:44:56 GMT</pubDate>
    <dc:creator>JPKO</dc:creator>
    <dc:date>2017-12-20T10:44:56Z</dc:date>
    <item>
      <title>Reference line from axis to specific value</title>
      <link>https://community.jmp.com/t5/Discussions/Reference-line-from-axis-to-specific-value/m-p/48906#M27784</link>
      <description>&lt;P&gt;I am trying to script a graph that shows the predicted value on the y-axis from some specified value on the x-axis on a soft curve. I have managed to pull out the prediction formula and obtain the relevant values&amp;nbsp;to define reference lines. However to communicate this effectively i would like the reference lines to stop at the curve and preferable to be dashed. The above image is as far as I have been able to go with jsl scripting. Below is where I would like to end up.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Untitled.png" style="width: 366px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/8770i49A36E1FED31A684/image-size/large?v=v2&amp;amp;px=999" role="button" title="Untitled.png" alt="Untitled.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Picture1.png" style="width: 566px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/8771i2F61B3D667522B16/image-size/large?v=v2&amp;amp;px=999" role="button" title="Picture1.png" alt="Picture1.png" /&gt;&lt;/span&gt;&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>Wed, 20 Dec 2017 10:44:56 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Reference-line-from-axis-to-specific-value/m-p/48906#M27784</guid>
      <dc:creator>JPKO</dc:creator>
      <dc:date>2017-12-20T10:44:56Z</dc:date>
    </item>
    <item>
      <title>Re: Reference line from axis to specific value</title>
      <link>https://community.jmp.com/t5/Discussions/Reference-line-from-axis-to-specific-value/m-p/48908#M27786</link>
      <description>&lt;P&gt;Instead of using two reference lines from the axes, try drawing a rectangle in the graph box using a graphics script:&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 );
New Window( "Example",
	Graph Box(
		// line color
		Pen Color( "Green" );
		// line width
		Pen Size( 2 );
		// line style (dashed)
		Line Style (2);
		Fill Color( "Red" );
		
		// filled rectangle
		Rect( 15, 75, 65, 55, 1 );
		
		// unfilled rectangle (reference lines)
		Rect( -1, 80, 70, -1 );
	)
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;M&lt;/P&gt;
&lt;DIV class="grammarly-disable-indicator"&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Wed, 20 Dec 2017 12:19:55 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Reference-line-from-axis-to-specific-value/m-p/48908#M27786</guid>
      <dc:creator>MikeD_Anderson</dc:creator>
      <dc:date>2017-12-20T12:19:55Z</dc:date>
    </item>
    <item>
      <title>Re: Reference line from axis to specific value</title>
      <link>https://community.jmp.com/t5/Discussions/Reference-line-from-axis-to-specific-value/m-p/48913#M27787</link>
      <description>&lt;P&gt;Adding to&amp;nbsp;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/4530"&gt;@MikeD_Anderson&lt;/a&gt;, the method that I have found easiest to develope the code for adding graphics to a chart in a platform, is to right click on the graph in question, and select "Custom".&amp;nbsp; This allows one to modify and add to the graph in real time.&amp;nbsp; I then simply click on th "+" and add a new segment&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="addline1.PNG" style="width: 723px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/8772iD1ECED1996F89D39/image-size/large?v=v2&amp;amp;px=999" role="button" title="addline1.PNG" alt="addline1.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Using the Templates or Samples, or using the Scripting Editor's "Graphics Category"&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="addline2.PNG" style="width: 892px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/8773i8A63E6EE9C09E567/image-size/large?v=v2&amp;amp;px=999" role="button" title="addline2.PNG" alt="addline2.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;one can play with the display until one has what they want.&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="addline3.PNG" style="width: 397px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/8774i915514815BB54C24/image-size/large?v=v2&amp;amp;px=999" role="button" title="addline3.PNG" alt="addline3.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;You can go to the red triangle and Save the Script&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="addline4.PNG" style="width: 398px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/8775iA5229EAA3A86E121/image-size/large?v=v2&amp;amp;px=999" role="button" title="addline4.PNG" alt="addline4.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Which will give you a sample script that you can then modify to make the script generic&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\big class.jmp" );
Bivariate(
	Y( :height ),
	X( :age ),
	Fit Polynomial( 2, {Line Color( {213, 72, 87} )} ),
	SendToReport(
		Dispatch(
			{},
			"Bivar Plot",
			FrameBox,
			{Add Graphics Script(
				2,
				Description( "Script" ),
				Line Style( dashed );
				Line( [0, 13.35, 13.35], [62, 62, 50] );
			), Grid Line Order( 1 ), Reference Line Order( 3 )}
		)
	)
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Dec 2017 12:50:17 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Reference-line-from-axis-to-specific-value/m-p/48913#M27787</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2017-12-20T12:50:17Z</dc:date>
    </item>
    <item>
      <title>Re: Reference line from axis to specific value</title>
      <link>https://community.jmp.com/t5/Discussions/Reference-line-from-axis-to-specific-value/m-p/49002#M27831</link>
      <description>&lt;P&gt;The code below should allow you to dynamically profile any saved formula column that involves only one input. In the case of 'Big Class' and a quartic model, it gives:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screen Shot 2017-12-22 at 11.44.10.png" style="width: 389px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/8804i79D93F325B0BA5EB/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screen Shot 2017-12-22 at 11.44.10.png" alt="Screen Shot 2017-12-22 at 11.44.10.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;It's more or less untested.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;NamesDefaultToHere(1);

// Function to find leaves in formula that are columns in the table
// See: https://community.jmp.com/blogs/Uncharted/2015/04/03/head-arg-recurse-formula"
// Thanks to Craige Hales
findColumns =
Function( {frm, cols},
    {h = Head( frm ), n = N Arg( frm ), i, result = {}}, 			// local variables
    If( n == 0, 													// head node has no children, it is a leaf
        If( Contains( cols, Name Expr( h ) ), 						// is the leaf in the list of columns?
            Insert Into( result, Name Expr( h ) ); 					// yes -&amp;gt; add to result
        )
    ,
        For( i = 1, i &amp;lt;= n, i++, 									// not a leaf, get children's results
            Insert Into( result, Recurse( Arg( frm, i ), cols ) )
        )
    );
    result;															// return the result
);


// Open a table to play with, and add a formula column to it
dt = Open("$SAMPLE_DATA/Big Class.jmp");
fCol = dt &amp;lt;&amp;lt; New Column( "Predicted weight", 
					Formula(-127 + 4 * :height),
					Set Property("Predicting", {:weight, Creator( "Bivariate" ), Model Name( "Polynomial Fit Degree=3" )})
					);

// Recover the required information
f = fCol &amp;lt;&amp;lt; getFormula;
xColList = findColumns(NameExpr(f), dt &amp;lt;&amp;lt; getColumnNames);
yCol = fCol &amp;lt;&amp;lt; getProperty("Predicting");
yCol = yCol[1];

// Subsequent code will only work with one x Column
xCol = Expr(xColList[1]);
for(c=1, c&amp;lt;=NItems(xColList), c++, Print(c); if(xColList[c] != xCol, Print("Only one x Column allowed."); Beep(); Throw()));

// Reparameterise the formula for later use in the 'GraphBox()'
SubstituteInto(f, xCol, Expr(x));

// Set the initial 'VLine()' value to the mean of the x values
xVals = xCol &amp;lt;&amp;lt; getValues;
x = Mean(xVals);

// Get 'reasonable' ranges for the axes
xMin = Min(xVals);
xMax = Max(xVals);
yMin = Min(yCol &amp;lt;&amp;lt; getValues);
yMax = Max(yCol &amp;lt;&amp;lt; getValues);

// Get the names of the columns involved
xColName = xCol &amp;lt;&amp;lt; getName;
yColName = yCol &amp;lt;&amp;lt; getName;

// Plot the graph
NewWindow("Function Profile",
	gb = GraphBox("Simple Profiler", XScale(xMin, xMax), YScale(yMin, yMax), XName(xColName), yName(yColName),
				// Plot the function
				PenColor("Red"); YFunction(f, x);
				// Handle to drag the 'VLine()' and update display
				Handle(x, yMin + (yMax-yMin)/10, gb &amp;lt;&amp;lt; reShow, Empty());
				// Get the function value for the current x value
				yy = Eval(Substitute(NameExpr(f), Expr(x), x));
				// Plot the lines at the new places
				PenColor("Blue"); LineStyle("Dotted");
				VLine(x, yMin, yy);
				HLine(xMin, x, yy);
				);
		);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 22 Dec 2017 11:54:56 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Reference-line-from-axis-to-specific-value/m-p/49002#M27831</guid>
      <dc:creator>ian_jmp</dc:creator>
      <dc:date>2017-12-22T11:54:56Z</dc:date>
    </item>
    <item>
      <title>Re: Reference line from axis to specific value</title>
      <link>https://community.jmp.com/t5/Discussions/Reference-line-from-axis-to-specific-value/m-p/49131#M27923</link>
      <description>&lt;P&gt;Thanks a lot, this was just what I was looking for!&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jan 2018 12:29:26 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Reference-line-from-axis-to-specific-value/m-p/49131#M27923</guid>
      <dc:creator>JPKO</dc:creator>
      <dc:date>2018-01-02T12:29:26Z</dc:date>
    </item>
    <item>
      <title>Re: Reference line from axis to specific value</title>
      <link>https://community.jmp.com/t5/Discussions/Reference-line-from-axis-to-specific-value/m-p/49132#M27924</link>
      <description>&lt;P&gt;This look really cool but is probably also a bit above my current level of understanding. I will try to work my way trough your example and will hopefully learn quite a bit in the process!&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jan 2018 12:31:06 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Reference-line-from-axis-to-specific-value/m-p/49132#M27924</guid>
      <dc:creator>JPKO</dc:creator>
      <dc:date>2018-01-02T12:31:06Z</dc:date>
    </item>
  </channel>
</rss>

