<?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: Is there a way to write a script to that graphs 2 different types of plots in one graph? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Is-there-a-way-to-write-a-script-to-that-graphs-2-different/m-p/283137#M54772</link>
    <description>&lt;OL&gt;
&lt;LI&gt;Please read the section on Matrices in the Scripting Guide&lt;/LI&gt;
&lt;LI&gt;Here is an example
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names default to here(1);
framex_value = 5000;

xMat = matrix(76200 - framex_value) |/ matrix(76200 - framex_value) |/ 
	matrix(76200 + framex_value) |/ matrix(76200 + framex_value);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/LI&gt;
&lt;/OL&gt;</description>
    <pubDate>Thu, 30 Jul 2020 20:09:50 GMT</pubDate>
    <dc:creator>txnelson</dc:creator>
    <dc:date>2020-07-30T20:09:50Z</dc:date>
    <item>
      <title>Is there a way to write a script to that graphs 2 different types of plots in one graph?</title>
      <link>https://community.jmp.com/t5/Discussions/Is-there-a-way-to-write-a-script-to-that-graphs-2-different/m-p/282882#M54730</link>
      <description>&lt;P&gt;Hi, I am fairly new to jmp and am trying to write a script to automate something I have been able to do in other software. I am not sure what I am wanting to do is possible. I am trying to use some data to overlay 2 graphs, one is a scatter plot and the other is a line graph. I am able to do the scatter plot, but cannot figure out how to include the line graph one as well.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have included some images of the 2 graphs I want to overlay, and also an example with other software of how it should look. I also will include what I have so far for my script.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance for any assistance.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;framex_value = "";
w = New Window( "Frame size X", // opens a window with a title and this content...
		&amp;lt;&amp;lt;Return Result,
    Border Box( top( 20 ), bottom( 20 ), Left( 20 ), Right( 20 ), // window dressing 
        V List Box( // V and H lists nest to organize the display boxes
            H Center Box( Text Box( "Frame size X" ) ), // a second title, centered
            Spacer Box( size( 1, 30 ) ), // a little vertical space
            H List Box( Text Box( "Frame size X: " ), framex = Number Edit Box( "" ) ), // data entry
            Spacer Box( size( 1, 10 ) ), // a little vertical space
            H Center Box( // center the button
                Button Box( "Create graph", // this script runs when the button is pressed...
                  framex_value = framex &amp;lt;&amp;lt; get text();
                    values1 = {framex_value, framex_value};
                    values2 = {1, 0.92, 0.92, 1};
                    
                    
                    column("X coordinate")&amp;lt;&amp;lt;data type(Numeric)&amp;lt;&amp;lt;Modeling Type(Continuous)&amp;lt;&amp;lt;Format(Best,12);
					New Column ( "New Y", Numeric, Nominal, Width( 5), Formula(Round(Y coordinate)));
					dt =Current Data Table();
					dt &amp;lt;&amp;lt; select where( :New Y != 50503 );
					dt &amp;lt;&amp;lt; delete rows;
					New Column ( "Normalized", Numeric, Continuous, Width( 10 ), Precision ( 7 ), Formula(IntenCD/Col Max(IntenCD)) );
                    
                    New Column ( "Frame X", Numeric, Continuous, Width( 10 ), Precision ( 7 ), set values( values1 ));
                    New Column ( "Frame X 2", Numeric, Continuous, Width( 10 ), Precision ( 7 ), Formula(76200 - (Frame X/2)));
                    New Column ( "Frame Y", Numeric, Continuous, Width( 10 ), Precision ( 7 ), set values( values2 ));
                    
                    Graph Builder(
						Variables( X( :X coordinate ), Y( :Normalized ) ),
						Elements( Points( X, Y, Legend( 9 ) ) ),
						
						//Variables( X( :Frame X ), Y( :Frame Y ) ),
						Elements( Line( X, Y, Legend( 5 ), Row order( 1 ) ) ),
	
						SendToReport(
							Dispatch(
								{},
								"X coordinate",
								ScaleBox,
								{Min( 10000 ), Max( 140000 ), Inc( 10000 ), Minor Ticks( 1 )}
									),
							Dispatch(
								{},
								"Normalized",
								ScaleBox,
								{Min( 0.91 ), Max( 1.01 ), Inc( 0.002 ), Minor Ticks( 1 )}
							)
						)
					);
                    
                    // launch a platform to analyze the data...
                    //dt &amp;lt;&amp;lt; Distribution( Continuous Distribution( Column( :a ), Quantiles( 0 ), Summary Statistics( 0 ), Vertical( 0 ), Outlier Box Plot( 0 ) ) );
                    // optionally, close the dialog. Or, you might want to run it again...
                    w &amp;lt;&amp;lt; closeWindow; // just the dialog, not the report
                )
            )
        )
     )
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Line_plot.JPG" style="width: 538px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/25804i8B44F5C462A5970F/image-size/large?v=v2&amp;amp;px=999" role="button" title="Line_plot.JPG" alt="Line_plot.JPG" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Scatter_plot.JPG" style="width: 591px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/25805i790CCC55D852B100/image-size/large?v=v2&amp;amp;px=999" role="button" title="Scatter_plot.JPG" alt="Scatter_plot.JPG" /&gt;&lt;/span&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Overlay.JPG" style="width: 830px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/25809i26C70F78975F37FC/image-size/large?v=v2&amp;amp;px=999" role="button" title="Overlay.JPG" alt="Overlay.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Jun 2023 11:04:09 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Is-there-a-way-to-write-a-script-to-that-graphs-2-different/m-p/282882#M54730</guid>
      <dc:creator>GardDog</dc:creator>
      <dc:date>2023-06-11T11:04:09Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to write a script to that graphs 2 different types of plots in one graph?</title>
      <link>https://community.jmp.com/t5/Discussions/Is-there-a-way-to-write-a-script-to-that-graphs-2-different/m-p/283013#M54749</link>
      <description>&lt;P&gt;Here are 2 solutions.&lt;/P&gt;
&lt;P&gt;First solution creates the graph with just the X Coordinate and the Normalized data, and then using Add Graphics Script, adds in the line&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="pl1.PNG" style="width: 444px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/25841i326EB51FB31645B4/image-dimensions/444x361?v=v2" width="444" height="361" role="button" title="pl1.PNG" alt="pl1.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;The second solution, adds in extra rows to the data table, and 1 extra column, and then by specifying which variables to show points for, and which one to show a line for, the Graph Builder comes up with the final plot&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="pl2.PNG" style="width: 449px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/25842i80CC4BB3BF376A25/image-dimensions/449x364?v=v2" width="449" height="364" role="button" title="pl2.PNG" alt="pl2.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;The 2 data tables are attached and the scripts for each version are saved to the respective data tables.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jul 2020 12:30:15 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Is-there-a-way-to-write-a-script-to-that-graphs-2-different/m-p/283013#M54749</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-07-30T12:30:15Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to write a script to that graphs 2 different types of plots in one graph?</title>
      <link>https://community.jmp.com/t5/Discussions/Is-there-a-way-to-write-a-script-to-that-graphs-2-different/m-p/283069#M54758</link>
      <description>&lt;P&gt;This is perfect, thanks so much. I appreciate it so much. I have been trying to figure out how to do this for quite a while.....I was able to get it to work on my dataset....now I just need to see about adding the values for the line graph into the columns. Using your column names, the X coordinates for the line will be dependent on a user input value, so they will change, but the norm2 will always be the same 4 values. I see you replied to the other post I made about this. I will review that one. Thanks again.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jul 2020 13:48:31 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Is-there-a-way-to-write-a-script-to-that-graphs-2-different/m-p/283069#M54758</guid>
      <dc:creator>GardDog</dc:creator>
      <dc:date>2020-07-30T13:48:31Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to write a script to that graphs 2 different types of plots in one graph?</title>
      <link>https://community.jmp.com/t5/Discussions/Is-there-a-way-to-write-a-script-to-that-graphs-2-different/m-p/283107#M54770</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/19818"&gt;@GardDog&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am responding back, to urge you to reevaluate the first option that I showed you.&amp;nbsp; It has the distinct advantage of not messing with your data.&amp;nbsp; Below is a rework of the script that Graph Builder produced for the first option.&amp;nbsp; The reworked code will show you how to incorporate calculated values directly into the graphical output.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Current Data Table();

// Determine your X Matrix
// Here it is just being assigned, but you can easily create it in your code
xMat = [25000, 25000, 100000, 100000];
// The yMat is static, so it would be input as is
yMat = [1, 0.92, 0.92, 1];

gb = dt &amp;lt;&amp;lt; Graph Builder(
	Size( 534, 456 ),
	Show Control Panel( 0 ),
	Variables( X( :X Coordinate ), Y( :Normalized ) ),
	Elements( Points( X, Y, Legend( 5 ) ) )
);

Report( gb )[FrameBox( 1 )] &amp;lt;&amp;lt; Add Graphics Script(
	Pen Color( "orange" );
	Pen Size( 2 );
	Line( xmat, ymat );
);
report(gb)[AxisBox(2)] &amp;lt;&amp;lt; min(.91);&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 30 Jul 2020 17:57:28 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Is-there-a-way-to-write-a-script-to-that-graphs-2-different/m-p/283107#M54770</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-07-30T17:57:28Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to write a script to that graphs 2 different types of plots in one graph?</title>
      <link>https://community.jmp.com/t5/Discussions/Is-there-a-way-to-write-a-script-to-that-graphs-2-different/m-p/283126#M54771</link>
      <description>&lt;P&gt;&lt;a href="https://community.jmp.com/t5/user/viewprofilepage/user-id/2687"&gt;@txnelson&lt;/a&gt;&lt;/P&gt;&lt;P&gt;This is great, I really like this solution. Thanks for sending this one.&lt;/P&gt;&lt;P&gt;Could I bother you with one more question? I am struggling with getting the calculated values into the xMat. My program asks the user for a value, I take that value and the calculation for the first two xMat values should be calculated (76200-"user input value"), and the second two xMat values would be calculated (76200 + "user input value"). Thanks in advance for any assistance.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jul 2020 19:49:20 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Is-there-a-way-to-write-a-script-to-that-graphs-2-different/m-p/283126#M54771</guid>
      <dc:creator>GardDog</dc:creator>
      <dc:date>2020-07-30T19:49:20Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to write a script to that graphs 2 different types of plots in one graph?</title>
      <link>https://community.jmp.com/t5/Discussions/Is-there-a-way-to-write-a-script-to-that-graphs-2-different/m-p/283137#M54772</link>
      <description>&lt;OL&gt;
&lt;LI&gt;Please read the section on Matrices in the Scripting Guide&lt;/LI&gt;
&lt;LI&gt;Here is an example
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names default to here(1);
framex_value = 5000;

xMat = matrix(76200 - framex_value) |/ matrix(76200 - framex_value) |/ 
	matrix(76200 + framex_value) |/ matrix(76200 + framex_value);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Thu, 30 Jul 2020 20:09:50 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Is-there-a-way-to-write-a-script-to-that-graphs-2-different/m-p/283137#M54772</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-07-30T20:09:50Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to write a script to that graphs 2 different types of plots in one graph?</title>
      <link>https://community.jmp.com/t5/Discussions/Is-there-a-way-to-write-a-script-to-that-graphs-2-different/m-p/283144#M54776</link>
      <description>&lt;P&gt;Thanks for this example. I don't know if I am bringing in the user input incorrectly or not but I get an error when I add this to the script and try to run it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cannot convert argument to a number [or matrix] in access or evaluation of 'Subtract' , 76200 - /*###*/framex_value/*###*/.&lt;/P&gt;&lt;P&gt;I have attached my script again with all the updates if needed to help.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again in advance. I really appreciate the help.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;framex_value = "";
w = New Window( "Frame size X", // opens a window with a title and this content...
		&amp;lt;&amp;lt;Return Result,
    Border Box( top( 20 ), bottom( 20 ), Left( 20 ), Right( 20 ), // window dressing 
        V List Box( // V and H lists nest to organize the display boxes
            H Center Box( Text Box( "Frame size X" ) ), // a second title, centered
            Spacer Box( size( 1, 30 ) ), // a little vertical space
            H List Box( Text Box( "Frame size X: " ), framex = Number Edit Box( "" ) ), // data entry
            Spacer Box( size( 1, 10 ) ), // a little vertical space
            H Center Box( // center the button
                Button Box( "Create graph", // this script runs when the button is pressed...
                  framex_value = framex &amp;lt;&amp;lt; get text();
                   
                    column("X coordinate")&amp;lt;&amp;lt;data type(Numeric)&amp;lt;&amp;lt;Modeling Type(Continuous)&amp;lt;&amp;lt;Format(Best,12);
					New Column ( "New Y", Numeric, Nominal, Width( 5), Formula(Round(Y coordinate)));
					dt =Current Data Table();
					dt &amp;lt;&amp;lt; select where( :New Y != 50503 );
					dt &amp;lt;&amp;lt; delete rows;
					New Column ( "Normalized", Numeric, Continuous, Width( 10 ), Precision ( 7 ), Formula(IntenCD/Col Max(IntenCD)) );
                    
					// Determine your X Matrix
					// Here it is just being assigned, but you can easily create it in your code
					xMat = matrix(76200 - framex_value) |/ matrix(76200 - framex_value) |/ 
						matrix(76200 + framex_value) |/ matrix(76200 + framex_value);
					// The yMat is static, so it would be input as is
					yMat = [1, 0.92, 0.92, 1];

					gb = dt &amp;lt;&amp;lt; Graph Builder(
						Size( 534, 456 ),
						Show Control Panel( 0 ),
						Variables( X( :X Coordinate ), Y( :Normalized ) ),
						Elements( Points( X, Y, Legend( 5 ) ) )
					);

					Report( gb )[FrameBox( 1 )] &amp;lt;&amp;lt; Add Graphics Script(
						Pen Color( "orange" );
						Pen Size( 2 );
						Line( xmat, ymat );
					);
					report(gb)[AxisBox(2)] &amp;lt;&amp;lt; min(.91);
                    
                    w &amp;lt;&amp;lt; closeWindow; // just the dialog, not the report
                )
            )
        )
     )
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jul 2020 21:14:39 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Is-there-a-way-to-write-a-script-to-that-graphs-2-different/m-p/283144#M54776</guid>
      <dc:creator>GardDog</dc:creator>
      <dc:date>2020-07-30T21:14:39Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to write a script to that graphs 2 different types of plots in one graph?</title>
      <link>https://community.jmp.com/t5/Discussions/Is-there-a-way-to-write-a-script-to-that-graphs-2-different/m-p/283145#M54777</link>
      <description>&lt;P&gt;You are changing the value of "framex_value" from numeric to character when you specify&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt; framex_value = framex &amp;lt;&amp;lt; get text();&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;You are telling JMP to get the value of framex as "text"&lt;/P&gt;
&lt;P&gt;You should be specifying&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt; framex_value = framex &amp;lt;&amp;lt; get ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Look in the Scripting Guide under "NumberEditBox" and you will see all messages that can be handled by "NumberEditBox", and examples for each one.&lt;/P&gt;
&lt;P&gt;On another related issue you are specifying&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;framex = Number Edit Box( "" )&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;which is telling JMP to apply a character value to you Numeric Input Box.&amp;nbsp; Because it is a numeric field, you should be specifying either a valid number, or a period, "."&amp;nbsp; &amp;nbsp;The "." is handled as a missing value.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jul 2020 21:26:32 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Is-there-a-way-to-write-a-script-to-that-graphs-2-different/m-p/283145#M54777</guid>
      <dc:creator>txnelson</dc:creator>
      <dc:date>2020-07-30T21:26:32Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to write a script to that graphs 2 different types of plots in one graph?</title>
      <link>https://community.jmp.com/t5/Discussions/Is-there-a-way-to-write-a-script-to-that-graphs-2-different/m-p/283163#M54783</link>
      <description>&lt;P&gt;Perfect, my script is working awesome! Thanks again for all your help!&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jul 2020 22:41:05 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Is-there-a-way-to-write-a-script-to-that-graphs-2-different/m-p/283163#M54783</guid>
      <dc:creator>GardDog</dc:creator>
      <dc:date>2020-07-30T22:41:05Z</dc:date>
    </item>
  </channel>
</rss>

