<?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: Add variable in Graph builder in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Add-variable-in-Graph-builder/m-p/915609#M107596</link>
    <description>&lt;P&gt;Not exactly sure what type of plot you are going for, but one example would be something like this&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1); 

dt = open("$SAMPLE_DATA/Big Class.jmp");

cols_to_plot = {"age", "sex"};

graph = dt &amp;lt;&amp;lt; Graph Builder();


For Each ({col},cols_to_plot,
	Eval(EvalExpr(
		graph &amp;lt;&amp;lt; Add Variable({Expr(NameExpr(AsColumn(dt, col))), Role("X")});
	));
 );

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Check correct syntax from Scripting Index for &amp;lt;&amp;lt; Add Variable and use expression evaluation to get column reference in correct format&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1764243332023.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/87823iF1FB223968918BDF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1764243332023.png" alt="jthi_0-1764243332023.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;(Depending on your final plot, you might want to go other route where you build the whole graph builder expression)&lt;/P&gt;</description>
    <pubDate>Thu, 27 Nov 2025 11:35:50 GMT</pubDate>
    <dc:creator>jthi</dc:creator>
    <dc:date>2025-11-27T11:35:50Z</dc:date>
    <item>
      <title>Add variable in Graph builder</title>
      <link>https://community.jmp.com/t5/Discussions/Add-variable-in-Graph-builder/m-p/915598#M107595</link>
      <description>&lt;P&gt;I have data table with multiple columns and rows&lt;/P&gt;
&lt;P&gt;I want to loop through each column and add it to graph builder on x -axis&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is my simple script&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = Open( filepath );
all_cols = dt &amp;lt;&amp;lt; Get Column Names( "String" );

cols_to_plot={};
For Each ({col}, all_cols,
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;If(col == "A" || col == "B",,
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Insert into (cols_to_plot, col);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;)
);
graph = dt &amp;lt;&amp;lt; Graph Builder();

For Each ({col},cols_to_plot,
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;graph &amp;lt;&amp;lt; Add Variable ("X", Column(dt, col)); // Also tried&amp;nbsp;&amp;nbsp;graph &amp;lt;&amp;lt; Add Variable (X, Column(dt, col));
&amp;nbsp;);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;This script is always giving me below error&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;
&lt;P&gt;argument value is invalid in access or evaluation of 'Add Variable' , Bad Argument( "X" ), Add Variable( "X", Column( dt, col ) ) /*###*/at line 600&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just as a check if I run below script it works fine, but I want to plot it for ~1000 columns&lt;/P&gt;
&lt;DIV&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;graph = dt &amp;lt;&amp;lt; Graph Builder(
Variables(X(cols_to_plot[1]),X(cols_to_plot[2]),X(cols_to_plot[3]));
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;/DIV&gt;
&lt;P&gt;what am I missing here, appreciate your help&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Edit (jthi): added jsl formatting&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Thu, 27 Nov 2025 11:32:26 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Add-variable-in-Graph-builder/m-p/915598#M107595</guid>
      <dc:creator>ravij</dc:creator>
      <dc:date>2025-11-27T11:32:26Z</dc:date>
    </item>
    <item>
      <title>Re: Add variable in Graph builder</title>
      <link>https://community.jmp.com/t5/Discussions/Add-variable-in-Graph-builder/m-p/915609#M107596</link>
      <description>&lt;P&gt;Not exactly sure what type of plot you are going for, but one example would be something like this&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1); 

dt = open("$SAMPLE_DATA/Big Class.jmp");

cols_to_plot = {"age", "sex"};

graph = dt &amp;lt;&amp;lt; Graph Builder();


For Each ({col},cols_to_plot,
	Eval(EvalExpr(
		graph &amp;lt;&amp;lt; Add Variable({Expr(NameExpr(AsColumn(dt, col))), Role("X")});
	));
 );

&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Check correct syntax from Scripting Index for &amp;lt;&amp;lt; Add Variable and use expression evaluation to get column reference in correct format&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="jthi_0-1764243332023.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/87823iF1FB223968918BDF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="jthi_0-1764243332023.png" alt="jthi_0-1764243332023.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;(Depending on your final plot, you might want to go other route where you build the whole graph builder expression)&lt;/P&gt;</description>
      <pubDate>Thu, 27 Nov 2025 11:35:50 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Add-variable-in-Graph-builder/m-p/915609#M107596</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2025-11-27T11:35:50Z</dc:date>
    </item>
    <item>
      <title>Re: Add variable in Graph builder</title>
      <link>https://community.jmp.com/t5/Discussions/Add-variable-in-Graph-builder/m-p/915610#M107597</link>
      <description>&lt;P&gt;I tried this method and also tried&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;For Each ({col}, cols_to_plot,

col_ref = Column(dt, col);

graph &amp;lt;&amp;lt; Add variable (col_ref, Role("X"));

);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;In both cases my jsl hangs, I only have 1000 columns and 500 rows in my data table&lt;/P&gt;
&lt;P&gt;is it the efficient way of doing it, or is there any better way to plot all columns of the table on X axis at once, if I try the same on GUI it is much faster&lt;/P&gt;</description>
      <pubDate>Thu, 27 Nov 2025 11:58:52 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Add-variable-in-Graph-builder/m-p/915610#M107597</guid>
      <dc:creator>ravij</dc:creator>
      <dc:date>2025-11-27T11:58:52Z</dc:date>
    </item>
    <item>
      <title>Re: Add variable in Graph builder</title>
      <link>https://community.jmp.com/t5/Discussions/Add-variable-in-Graph-builder/m-p/915620#M107598</link>
      <description>&lt;P&gt;What type of plot are you trying to create?&lt;/P&gt;</description>
      <pubDate>Thu, 27 Nov 2025 12:43:35 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Add-variable-in-Graph-builder/m-p/915620#M107598</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2025-11-27T12:43:35Z</dc:date>
    </item>
    <item>
      <title>Re: Add variable in Graph builder</title>
      <link>https://community.jmp.com/t5/Discussions/Add-variable-in-Graph-builder/m-p/915626#M107599</link>
      <description>&lt;P&gt;I am trying to create a Simple scatter plot, with all columns on X-axis serially&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Something as below&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ravij_1-1764251140418.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/87827iB4D3843061AD861C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ravij_1-1764251140418.png" alt="ravij_1-1764251140418.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 27 Nov 2025 13:46:04 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Add-variable-in-Graph-builder/m-p/915626#M107599</guid>
      <dc:creator>ravij</dc:creator>
      <dc:date>2025-11-27T13:46:04Z</dc:date>
    </item>
    <item>
      <title>Re: Add variable in Graph builder</title>
      <link>https://community.jmp.com/t5/Discussions/Add-variable-in-Graph-builder/m-p/915628#M107600</link>
      <description>&lt;P&gt;As you have so many columns, I would most likely build the Graph Builder expression instead of adding columns one by one. Create the graph manually, copy the script to see how it has been built and then replicate it using JSL. Below is one example&lt;/P&gt;
&lt;P&gt;JMP created script&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Graph Builder(
	Size(528, 458),
	Show Control Panel(0),
	Variables(
		X(:"0.642539"n, Combine("Parallel Merged")),
		X(:"0.645736349"n, Position(1), Combine("Parallel Merged")),
		X(:"0.648933698"n, Position(1), Combine("Parallel Merged")),
		X(:"0.652131047"n, Position(1), Combine("Parallel Merged")),
		X(:"0.655328396"n, Position(1), Combine("Parallel Merged")),
		X(:"0.658525745"n, Position(1), Combine("Parallel Merged")),
		X(:"0.661723094"n, Position(1), Combine("Parallel Merged")),
		X(:"0.664920443"n, Position(1), Combine("Parallel Merged")),
		X(:"0.668117792"n, Position(1), Combine("Parallel Merged")),
		X(:"0.671315141"n, Position(1), Combine("Parallel Merged")),
		X(:"0.67451249"n, Position(1), Combine("Parallel Merged")),
		X(:"0.677709839"n, Position(1), Combine("Parallel Merged")),
		X(:"0.680907188"n, Position(1), Combine("Parallel Merged")),
		X(:"0.684104537"n, Position(1), Combine("Parallel Merged")),
		X(:"0.687301886"n, Position(1), Combine("Parallel Merged")),
		X(:"0.690499235"n, Position(1), Combine("Parallel Merged"))
	),
	Elements(Points(X(1), X(2), X(3), X(4), X(5), X(6), X(7), X(8), X(9), X(10), X(11), X(12), X(13), X(14), X(15), X(16), Legend(4)))
);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;To create this with JSL you could do something like this&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Functional Data/NMR DoE.jmp");

nrmcols = dt &amp;lt;&amp;lt; get column group("NMR Spectra");

colnames = Transform Each({col}, nrmcols,
	AsColumn(dt, col) &amp;lt;&amp;lt; get name;
);

colnames = colnames[1::20];

var_expr = Expr(Variables());
points_expr = Expr(Points());

For Each({colname, idx}, colnames,
	x_expr = EvalExpr(X(Expr(NameExpr(AsColumn(dt, colname))), Position(1), Combine("Parallel Merged")));
	point_expr = EvalExpr(X(Expr(idx)));
	
	Insert Into(var_expr, Name Expr(x_expr));
	Insert Into(points_expr, Name Expr(point_expr));
);

gb = Eval(Substitute(
	Expr(dt &amp;lt;&amp;lt; Graph Builder(
		Size(528, 458),
		Show Control Panel(0),
		_var_,
		Elements(_points_)
	)),
	Expr(_var_), Name Expr(var_expr),
	Expr(_points_), Name Expr(points_expr)
));

Write();&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 27 Nov 2025 14:14:40 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Add-variable-in-Graph-builder/m-p/915628#M107600</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2025-11-27T14:14:40Z</dc:date>
    </item>
    <item>
      <title>Re: Add variable in Graph builder</title>
      <link>https://community.jmp.com/t5/Discussions/Add-variable-in-Graph-builder/m-p/915647#M107602</link>
      <description>&lt;P&gt;This works perfectly, Thanks for the help&lt;/P&gt;</description>
      <pubDate>Thu, 27 Nov 2025 15:52:44 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Add-variable-in-Graph-builder/m-p/915647#M107602</guid>
      <dc:creator>ravij</dc:creator>
      <dc:date>2025-11-27T15:52:44Z</dc:date>
    </item>
    <item>
      <title>Re: Add variable in Graph builder</title>
      <link>https://community.jmp.com/t5/Discussions/Add-variable-in-Graph-builder/m-p/915872#M107628</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have a follow up problem with these graphs I plotted, I am not able to save them in any format I tried .jmpreport .jrp etc, as I don't want to save graph in static png, jpg formates, I want to save interactive graph with data embedded in it&lt;/P&gt;
&lt;DIV&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;
nw = New Window("printing window",
gb = Eval(Substitute(
Expr(dt &amp;lt;&amp;lt; Graph Builder(
    Show Window(1),
    Size(528, 458),
    Show Control Panel(0),
    _var_,
    Elements(_points_)
)),
Expr(_var_), Name Expr(var_expr),
Expr(_points_), Name Expr(points_expr)
));
); &lt;BR /&gt;&lt;BR /&gt;reportpath = ::my_dir_path||"/metadata/"||metaTestfile;
newWindow&amp;lt;&amp;lt; Save(reportpath);&lt;/CODE&gt;&lt;/PRE&gt;
Also tried&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;gb = Eval(Substitute(
		Expr(dt &amp;lt;&amp;lt; Graph Builder(
				Show Window(1),
				Size(528, 458),
				Show Control Panel(0),							
				_var_,
				Elements(_points_)
		)),
		Expr(_var_), Name Expr(var_expr),
		Expr(_points_), Name Expr(points_expr)
));

gb &amp;lt;&amp;lt; Show Window;
newWindow = Window (gb);					
				
reportpath = ::my_dir_path||"/metadata/"||metaTestfile;
newWindow&amp;lt;&amp;lt; Save(reportpath );&lt;/CODE&gt;&lt;/PRE&gt;
The script doesn't throw any error in any case but also not saving the graph&lt;/DIV&gt;</description>
      <pubDate>Fri, 28 Nov 2025 19:05:52 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Add-variable-in-Graph-builder/m-p/915872#M107628</guid>
      <dc:creator>ravij</dc:creator>
      <dc:date>2025-11-28T19:05:52Z</dc:date>
    </item>
    <item>
      <title>Re: Add variable in Graph builder</title>
      <link>https://community.jmp.com/t5/Discussions/Add-variable-in-Graph-builder/m-p/915873#M107629</link>
      <description>&lt;P&gt;Scripting Index usually has the answers for scripting (&amp;lt;&amp;lt;&amp;nbsp;Save Window Report)&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Functional Data/NMR DoE.jmp");

nrmcols = dt &amp;lt;&amp;lt; get column group("NMR Spectra");

colnames = Transform Each({col}, nrmcols,
	AsColumn(dt, col) &amp;lt;&amp;lt; get name;
);

colnames = colnames[1::20];

var_expr = Expr(Variables());
points_expr = Expr(Points());

For Each({colname, idx}, colnames,
	x_expr = EvalExpr(X(Expr(NameExpr(AsColumn(dt, colname))), Position(1), Combine("Parallel Merged")));
	point_expr = EvalExpr(X(Expr(idx)));
	
	Insert Into(var_expr, Name Expr(x_expr));
	Insert Into(points_expr, Name Expr(point_expr));
);

gb = Eval(Substitute(
	Expr(dt &amp;lt;&amp;lt; Graph Builder(
		Size(528, 458),
		Show Control Panel(0),
		_var_,
		Elements(_points_)
	)),
	Expr(_var_), Name Expr(var_expr),
	Expr(_points_), Name Expr(points_expr)
));

gb &amp;lt;&amp;lt; Save Window Report("$DOWNLOADS/test.jrp", embed data(1));

// demo purposes
Close(dt, no save);
wait(1);

Open("$DOWNLOADS/test.jrp");

Write();&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 28 Nov 2025 19:28:17 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Add-variable-in-Graph-builder/m-p/915873#M107629</guid>
      <dc:creator>jthi</dc:creator>
      <dc:date>2025-11-28T19:28:17Z</dc:date>
    </item>
  </channel>
</rss>

