<?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 Using expressions for theme format in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Using-expressions-for-theme-format/m-p/398923#M64968</link>
    <description>&lt;P&gt;I am trying to make the formatting of multiple similar plots into an expression so I can change a single section of the code to update all plots that look alike. However, I have a hard time implementing it into code. I am including a minimal working example showing how I would like a plot to look like and how I would like my code to look like, storing a piece of code for the formatting and a compact code for each plot. Any idea on how I can modify this to make it work? I am working on JMP version 15.2.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = New Table( "Minimal Working Example",
	Add Rows( 400 ),
	New Column( "X", Numeric, Set Values( Repeat( 1 :: 20, 20 ) ) ),
	New Column( "Y", Numeric, Set Values( Sort Ascending( Shape( Repeat( 1 :: 20, 20 ), 1 ) ) ) ),
	New Column( "Size", Numeric, &amp;lt;&amp;lt;Formula( Random Uniform( 0, 1 ) ) )
);

// How I would like the plot to look like
dt &amp;lt;&amp;lt; Graph Builder(
	Variables( X( :X ), Y( :Y ), Color( :Size ) ),
	Elements( Points( X, Y, Legend( 8 ) ) ),
	SendToReport(
		Dispatch(
			{},
			"400",
			ScaleBox,
			{Legend Model(
				8,
				Properties(
					0,
					{gradient( {Color Theme( "White to Red" )} )},
					Item ID( "Size", 1 )
				)
			)}
		),
		Dispatch(
			{},
			"400",
			LegendBox,
			{Legend Position( {8, [0, -1]} ), Position( {0, -1} )}
		)
	)
);

// A theme format I could change for a gazillion of plots
formats = Expr(
	SendToReport(
		Dispatch(
			{},
			"400",
			ScaleBox,
			{Legend Model(
				8,
				Properties(
					0,
					{gradient( {Color Theme( "White to Red" )} )},
					Item ID( "Size", 1 )
				)
			)}
		),
		Dispatch(
			{},
			"400",
			LegendBox,
			{Legend Position( {8, [0, -1]} ), Position( {0, -1} )}
		)
	)
);

// How I would like each plot code to look like
dt &amp;lt;&amp;lt; Graph Builder(
	Variables( X( :X ), Y( :Y ), Color( :Size ) ),
	Elements( Points( X, Y, Legend( 8 ) ) ),
	formats
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 11 Jun 2023 11:15:49 GMT</pubDate>
    <dc:creator>ac7872</dc:creator>
    <dc:date>2023-06-11T11:15:49Z</dc:date>
    <item>
      <title>Using expressions for theme format</title>
      <link>https://community.jmp.com/t5/Discussions/Using-expressions-for-theme-format/m-p/398923#M64968</link>
      <description>&lt;P&gt;I am trying to make the formatting of multiple similar plots into an expression so I can change a single section of the code to update all plots that look alike. However, I have a hard time implementing it into code. I am including a minimal working example showing how I would like a plot to look like and how I would like my code to look like, storing a piece of code for the formatting and a compact code for each plot. Any idea on how I can modify this to make it work? I am working on JMP version 15.2.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;dt = New Table( "Minimal Working Example",
	Add Rows( 400 ),
	New Column( "X", Numeric, Set Values( Repeat( 1 :: 20, 20 ) ) ),
	New Column( "Y", Numeric, Set Values( Sort Ascending( Shape( Repeat( 1 :: 20, 20 ), 1 ) ) ) ),
	New Column( "Size", Numeric, &amp;lt;&amp;lt;Formula( Random Uniform( 0, 1 ) ) )
);

// How I would like the plot to look like
dt &amp;lt;&amp;lt; Graph Builder(
	Variables( X( :X ), Y( :Y ), Color( :Size ) ),
	Elements( Points( X, Y, Legend( 8 ) ) ),
	SendToReport(
		Dispatch(
			{},
			"400",
			ScaleBox,
			{Legend Model(
				8,
				Properties(
					0,
					{gradient( {Color Theme( "White to Red" )} )},
					Item ID( "Size", 1 )
				)
			)}
		),
		Dispatch(
			{},
			"400",
			LegendBox,
			{Legend Position( {8, [0, -1]} ), Position( {0, -1} )}
		)
	)
);

// A theme format I could change for a gazillion of plots
formats = Expr(
	SendToReport(
		Dispatch(
			{},
			"400",
			ScaleBox,
			{Legend Model(
				8,
				Properties(
					0,
					{gradient( {Color Theme( "White to Red" )} )},
					Item ID( "Size", 1 )
				)
			)}
		),
		Dispatch(
			{},
			"400",
			LegendBox,
			{Legend Position( {8, [0, -1]} ), Position( {0, -1} )}
		)
	)
);

// How I would like each plot code to look like
dt &amp;lt;&amp;lt; Graph Builder(
	Variables( X( :X ), Y( :Y ), Color( :Size ) ),
	Elements( Points( X, Y, Legend( 8 ) ) ),
	formats
);&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Jun 2023 11:15:49 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Using-expressions-for-theme-format/m-p/398923#M64968</guid>
      <dc:creator>ac7872</dc:creator>
      <dc:date>2023-06-11T11:15:49Z</dc:date>
    </item>
    <item>
      <title>Re: Using expressions for theme format</title>
      <link>https://community.jmp.com/t5/Discussions/Using-expressions-for-theme-format/m-p/399030#M64981</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Expression handling is powerful, and takes a bit of practice. Here is an example to get you started, but you'll want to read up on things like Eval(), Expr(), NameExpr(), Substitute(), Substitute Into(), etc.&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);

//make a 5-column table
dt = astable((1::20)` || J(20,4,randominteger(0,20)));

//the x column will be the first column
xCol = column (dt, 1);

//the y columns will be the remaining columns
yColList = (dt &amp;lt;&amp;lt; get column names())[2::ncol(dt)];

//write the graph builder script, wrapping it in an expression. Use _XXX_ format for things
//you'll be substituting later. Here, that is just the "y" variable for a particular graph.
gbExpr = expr(
	dt &amp;lt;&amp;lt; Graph Builder(
		Variables( X( xcol ), Y( _Y_ ) ),
		Elements( Points( X, Y, Legend( 8 ) ) ),
		SendToReport(
			Dispatch(
				{},
				"400",
				ScaleBox,
				{Legend Model(
					8,
					Properties(
						0,
						{gradient( {Color Theme( "White to Red" )} )},
						Item ID( "Size", 1 )
					)
				)}
			),
			Dispatch(
				{},
				"400",
				LegendBox,
				{Legend Position( {8, [0, -1]} ), Legend Position( {0, -1} )}
			)
		)
	);
);

//cycling through the items in yColList, we create a graph for each y variable vs the x variable.
//be sure to read up on Name Expr ( ), as it is needed here to prevent evaluation of the Graph
//Builder script... we just want the code itself... we don't want JMP to try to evaluate the code
//until after we've made the substitution.
for (i = 1,i &amp;lt;=nitems(ycolList), i++,
	eval(Substitute( nameExpr(gbExpr),  expr(_Y_) , expr(yColList[i])));
);
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;Brady&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;CODE class=" language-jsl"&gt;
&lt;/CODE&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Jul 2021 22:04:08 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Using-expressions-for-theme-format/m-p/399030#M64981</guid>
      <dc:creator>brady_brady</dc:creator>
      <dc:date>2021-07-06T22:04:08Z</dc:date>
    </item>
    <item>
      <title>Re: Using expressions for theme format</title>
      <link>https://community.jmp.com/t5/Discussions/Using-expressions-for-theme-format/m-p/402945#M65367</link>
      <description>&lt;P&gt;That did not work very well because of the ways X, Y and Color variables change on my data, however I managed to find a closer solution to what I wanted using JSL Quote, Eval Insert, Parse, and Eval:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;// A theme format I could change for a gazillion of plots
formats = JSL Quote(
	SendToReport(
		Dispatch(
			{},
			"400",
			ScaleBox,
			{Legend Model(
				8,
				Properties(
					0,
					{gradient( {Color Theme( "White to Red" )} )},
					Item ID( "Size", 1 )
				)
			)}
		),
		Dispatch(
			{},
			"400",
			LegendBox,
			{Legend Position( {8, [0, -1]} ), Position( {0, -1} )}
		)
	)
);

// How I would like each plot code to look like
Eval(Parse(Eval Insert("dt &amp;lt;&amp;lt; Graph Builder(
	Variables( X( :X ), Y( :Y ), Color( :Size ) ),
	Elements( Points( X, Y, Legend( 8 ) ) ),
	^formats^
);")));&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 21 Jul 2021 14:35:12 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Using-expressions-for-theme-format/m-p/402945#M65367</guid>
      <dc:creator>ac7872</dc:creator>
      <dc:date>2021-07-21T14:35:12Z</dc:date>
    </item>
  </channel>
</rss>

