<?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: Making a Bivariate chart with group by column with unknow number of categories ? in Discussions</title>
    <link>https://community.jmp.com/t5/Discussions/Making-a-Bivariate-chart-with-group-by-column-with-unknow-number/m-p/544768#M76341</link>
    <description>&lt;P&gt;Here is one method that can work -- I personally do not use JMP's built-in splines as it creates too much visual clutter with the added control boxes.&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/Fishing.jmp" );
Try( dt &amp;lt;&amp;lt; Delete Columns( "GROUPING" ) );
dt &amp;lt;&amp;lt; New Column( "GROUPING", "Character",
	&amp;lt;&amp;lt;Set Each Value( {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J"}[Random Integer( 1, 10 )] )
);


bivNew = Expr( Bivariate(
	Y( :Fish Caught ),
	X( :People ),
	Automatic Recalc( 1 )
) );

categories = Associative Array( dt:GROUPING ) &amp;lt;&amp;lt; Get Keys;
Summation( i = 1, N Items( categories ),
	Insert Into( bivNew,
		Eval Expr(
			Fit Where( :GROUPING == Expr( categories[i] ), Fit Spline( 1, Standardized ) )
		)
	)
);

Eval( Eval Expr(
	Send( dt, Expr( Name Expr( bivNew ) ) )
) )&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 14 Sep 2022 22:25:49 GMT</pubDate>
    <dc:creator>ErraticAttack</dc:creator>
    <dc:date>2022-09-14T22:25:49Z</dc:date>
    <item>
      <title>Making a Bivariate chart with group by column with unknow number of categories ?</title>
      <link>https://community.jmp.com/t5/Discussions/Making-a-Bivariate-chart-with-group-by-column-with-unknow-number/m-p/544762#M76339</link>
      <description>&lt;P&gt;Hello All&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a big list of columns which I loop through to create a Bivariate chart each of every column in my column list. My x-axis remains the same every time.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am grouping by the same categorical column as well. But the number of groups/categories in that column changes everytime.&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can I use the "Fit Where" function in the bivariate plot so see all categories in one graph for each column when I dont know how many categories would be there?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Generally I do this to create what I want,&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );

dt = Open( "$SAMPLE_DATA/Fishing.jmp" );


bivNew = dt &amp;lt;&amp;lt; Bivariate(
	Y( :Fish Caught ),
	X( :People ),
	Automatic Recalc( 1 ),
	Fit Where( :Validation == 1, Fit Spline( 1, {Line Color( {212, 73, 88} )} ) ),
	Fit Where( :Validation == 2, Fit Spline( 1, {Line Color( {66, 112, 221} )} ) )
);

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;But in this I have hard coded the grouping (Fit Where) for each category in the Validation column. How can I get the same output if I dont know how many categories are there in the Validation column in terms of scripting a automated solution .&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be appreciated.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 11 Jun 2023 11:27:42 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Making-a-Bivariate-chart-with-group-by-column-with-unknow-number/m-p/544762#M76339</guid>
      <dc:creator>ankitgssingh</dc:creator>
      <dc:date>2023-06-11T11:27:42Z</dc:date>
    </item>
    <item>
      <title>Re: Making a Bivariate chart with group by column with unknow number of categories ?</title>
      <link>https://community.jmp.com/t5/Discussions/Making-a-Bivariate-chart-with-group-by-column-with-unknow-number/m-p/544768#M76341</link>
      <description>&lt;P&gt;Here is one method that can work -- I personally do not use JMP's built-in splines as it creates too much visual clutter with the added control boxes.&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/Fishing.jmp" );
Try( dt &amp;lt;&amp;lt; Delete Columns( "GROUPING" ) );
dt &amp;lt;&amp;lt; New Column( "GROUPING", "Character",
	&amp;lt;&amp;lt;Set Each Value( {"A", "B", "C", "D", "E", "F", "G", "H", "I", "J"}[Random Integer( 1, 10 )] )
);


bivNew = Expr( Bivariate(
	Y( :Fish Caught ),
	X( :People ),
	Automatic Recalc( 1 )
) );

categories = Associative Array( dt:GROUPING ) &amp;lt;&amp;lt; Get Keys;
Summation( i = 1, N Items( categories ),
	Insert Into( bivNew,
		Eval Expr(
			Fit Where( :GROUPING == Expr( categories[i] ), Fit Spline( 1, Standardized ) )
		)
	)
);

Eval( Eval Expr(
	Send( dt, Expr( Name Expr( bivNew ) ) )
) )&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 14 Sep 2022 22:25:49 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Making-a-Bivariate-chart-with-group-by-column-with-unknow-number/m-p/544768#M76341</guid>
      <dc:creator>ErraticAttack</dc:creator>
      <dc:date>2022-09-14T22:25:49Z</dc:date>
    </item>
    <item>
      <title>Re: Making a Bivariate chart with group by column with unknow number of categories ?</title>
      <link>https://community.jmp.com/t5/Discussions/Making-a-Bivariate-chart-with-group-by-column-with-unknow-number/m-p/544831#M76344</link>
      <description>&lt;P&gt;Thank you for the quick answer. Solved my problem.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Which splines do you generally prefer for your JMP bivar/graph plots in general? I don't need those additional control boxes as well but I am not able to find better/clear looking splines ?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Sep 2022 00:54:22 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Making-a-Bivariate-chart-with-group-by-column-with-unknow-number/m-p/544831#M76344</guid>
      <dc:creator>ankitgssingh</dc:creator>
      <dc:date>2022-09-15T00:54:22Z</dc:date>
    </item>
    <item>
      <title>Re: Making a Bivariate chart with group by column with unknow number of categories ?</title>
      <link>https://community.jmp.com/t5/Discussions/Making-a-Bivariate-chart-with-group-by-column-with-unknow-number/m-p/545054#M76360</link>
      <description>&lt;P&gt;There are many ways to do this, but one simple way is with a small namespace that holds the relevant functions:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the library that holds the functions / default settings:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;New Namespace( "bivar" );

bivar:default settings = [=&amp;gt;];
bivar:default settings["x size"] = 600;
bivar:default settings["y size"] = 400;
bivar:default settings["lambda"] = 1;
bivar:default settings["standardize splines"] = 1;
bivar:default settings["unselected line width"] = 4;
bivar:default settings["line width"] = 4;
bivar:default settings["selected line width"] = 5;
bivar:default settings["marker size"] = 4;
bivar:default settings["outline lines"] = 1;
bivar:default settings["fade unselected lines"] = 1;
bivar:default settings["spline points"] = 128;
&lt;BR /&gt;&lt;BR /&gt;//this is the only function that a user needs to call
bivar:plot = Function( {table, x column, y column, categorical column, title = "", settings = bivar:default settings},
	{Default Local},
	columns = table &amp;lt;&amp;lt; Get Column Names();
	If( Not( Contains( columns, As Name( x column ) ) ),
		Throw( "Unable to find column \!"" || x column || "\!"" );
	);
	If( Not( Contains( columns, As Name( y column ) ) ),
		Throw( "Unable to find column \!"" || y column || "\!"" );
	);
	If( Not( Contains( columns, As Name( categorical column ) ) ),
		Throw( "Unable to find column \!"" || categorical column || "\!"" );
	);
	If( Column( table, x column ) &amp;lt;&amp;lt; Get Data Type != "Numeric",
		Throw( "X column must be Numeric" );
	);
	If( Column( table, y column ) &amp;lt;&amp;lt; Get Data Type != "Numeric",
		Throw( "Y column must be Numeric" );
	);
	If( Column( table, categorical column ) &amp;lt;&amp;lt; Get Data Type != "Character",
		Throw( "Legend column must be Character" );
	);
	table &amp;lt;&amp;lt; Color or Mark by Column( categorical column );
	olb = Outline Box( "",
		Platform( table,
			Bivariate(
				X( Column( table, x column ) ),
				Y( Column( table, y column ) ),
				Dispatch(
					{}, "Bivar Plot", Frame Box,
					{
						Frame Size( settings["x size"], settings["y size"] ), Marker Size( settings["marker size"] )
					,
						Row Legend( Column( table, categorical column ), Marker( 1 ), Continuous Scale( 0 ), Reverse Scale( 0 ), Excluded Rows( 0 ) )
					}
				)
			)
		)
	);
	If( title != "",
		olb[Outline Box( 2 )] &amp;lt;&amp;lt; Set Title( title )
	);
	
	bivar:add splines( table, olb[Frame Box( 1 )], olb[String Col Box( 1 )], x column, y column, categorical column, settings );
	olb
);

bivar:add splines = Function( {table, frame box, legend box, x column, y column, categorical column, settings = bivar:default settings},
	{Default Local},
	sub table = table &amp;lt;&amp;lt; Summary( Group( categorical column ), Link to Original Data Table( 0 ), Private );
	colors = [=&amp;gt;];
	For Each Row( sub table,
		colors[Column( 1 )[]] = Color Of( Row State() )
	);
	legend values = Column( sub table, 1 ) &amp;lt;&amp;lt; Get Values;
	Close( sub table, No Save );
	
	splines = [=&amp;gt;];
	splines["__items__"] = legend values;
	splines["__settings__"] = settings;
	splines["__colors__"] = colors;

	Summation( i = 1, N Items( legend values ),
		item = legend values[i];
		splines[item] = [=&amp;gt;];
		Eval( Parse( Eval Insert( JSL Quote(
		rows = table &amp;lt;&amp;lt; Get Rows Where( !Excluded( Row State() ) &amp;amp; :Name("^categorical column^") == "^item^" &amp;amp; !Is Missing( :Name("^x column^") ) &amp;amp; !Is Missing( :Name("^y column^") ) )
		) ) ) );
		ordinate = Column( table, y column )[rows];
		abcissa = Column( table, x column )[rows];
		
		If( N Rows( rows ) &amp;gt; 3 &amp;amp; Min( abcissa ) != Max( abcissa ),
			If( settings["standardize splines"],
				x mean = Mean( abcissa );
				x std dev = Std Dev( abcissa );
				abcissa = (abcissa - x mean) / x std dev
			);
			x values = Min( abcissa )::Max( abcissa )::((Max( abcissa ) - Min( abcissa )) / settings["spline points"]);
			spline values = Spline Eval( x values, Spline Coef( abcissa, ordinate, settings["lambda"] ) );
			If( settings["standardize splines"],
				x values = x std dev * x values + x mean
			);
		,
			x values = abcissa;
			spline values = ordinate
		);
		splines[item]["x"] = x values;
		splines[item]["y"] = spline values;
		;0
	);
	
	Eval( Eval Expr(
	frame box &amp;lt;&amp;lt; Add Graphics Script(
		"CUSTOM_SPLINES";
		Local( {splines = Expr( splines ), legend = Expr( legend box ), settings = Expr( settings ), selected, i, items, item, selected items},
			selected = legend &amp;lt;&amp;lt; Get Selected Rows;
			If( N Rows( selected ) == 0,
				Summation( i = 1, N Items( splines["__items__"] ),
					item = splines["__items__"][i];
					Transparency( 1 );
					If( splines["__settings__"]["outline lines"],
						Pen Color( "Black" );
						Pen Size( splines["__settings__"]["line width"] + 1 );
						Line( splines[item]["x"], splines[item]["y"] )
					);
					Pen Color( splines["__colors__"][item] );
					Pen Size( splines["__settings__"]["line width"] );
					Line( splines[item]["x"], splines[item]["y"] );
					;0
				)
			,
				selected items = splines["__items__"][selected];
				Summation( i = 1, N Items( splines["__items__"] ),
					item = splines["__items__"][i];
					If( Not( Contains( selected items, item ) ),
						If( settings["fade unselected lines"],
							Transparency( 1 - Arg( Arg( Get Preferences( Graph Marker Unselected Fade ), 1 ), 1 ) / 100 )
						,
							Transparency( 1 )
						);
						Pen Color( splines["__colors__"][item] );
						Pen Size( splines["__settings__"]["unselected line width"] );
						Line( splines[item]["x"], splines[item]["y"] );
					);
					;0
				);
				Summation( i = 1, N Items( splines["__items__"] ),
					item = splines["__items__"][i];
					If( Contains( selected items, item ),
						Transparency( 1 );
						If( splines["__settings__"]["outline lines"],
							Pen Color( "Black" );
							Pen Size( splines["__settings__"]["selected line width"] + 1 );
							Line( splines[item]["x"], splines[item]["y"] )
						);
						Pen Color( splines["__colors__"][item] );
						Pen Size( splines["__settings__"]["selected line width"] );
						Line( splines[item]["x"], splines[item]["y"] );
					);
					;0
				)
			);
			items = splines["__items__"]
		)
	)
	) )
);
0&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;After the library has executed at least once (add it to the start script of an addin, for example), then you can make use of it very easily:&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-jsl"&gt;Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
dt2 = Open( "$SAMPLE_DATA/Reliability/Adhesive Bond.jmp" );
dt3 = Open( "$SAMPLE_DATA/Cars.jmp" );

settings = bivar:default settings;
settings["outline lines"] = 0;

New Window( "test",
	V List Box(
		bivar:plot( dt3, "year", "wt", "make" )
	,
		bivar:plot( dt3, "year", "wt", "make", "Custom Title", settings ) // show how to change settings
	,
		bivar:plot( dt, "Height", "weight", "sex" )
	,
		bivar:plot( dt2, "weeks", "strength", "censor" )
	)
)&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Now there are no annoying control boxes and I've made it match the selection mode of the markers (assuming you've got the "Unselected Faded" Marker Selection Mode)&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="ErraticAttack_0-1663264415596.png" style="width: 400px;"&gt;&lt;img src="https://community.jmp.com/t5/image/serverpage/image-id/45509i9066B3087C8D9CB1/image-size/medium?v=v2&amp;amp;px=400" role="button" title="ErraticAttack_0-1663264415596.png" alt="ErraticAttack_0-1663264415596.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this helps.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Sep 2022 18:06:34 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Making-a-Bivariate-chart-with-group-by-column-with-unknow-number/m-p/545054#M76360</guid>
      <dc:creator>ErraticAttack</dc:creator>
      <dc:date>2022-09-15T18:06:34Z</dc:date>
    </item>
    <item>
      <title>Re: Making a Bivariate chart with group by column with unknow number of categories ?</title>
      <link>https://community.jmp.com/t5/Discussions/Making-a-Bivariate-chart-with-group-by-column-with-unknow-number/m-p/545130#M76364</link>
      <description>&lt;P&gt;Thanks a lot for this. Indeed very useful.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, this function seems to work for a single x and y column and not when I pass a list of y columns with the same x and grouping column. Would need to update it to work for group of columns.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again for the help on this.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Sep 2022 22:43:53 GMT</pubDate>
      <guid>https://community.jmp.com/t5/Discussions/Making-a-Bivariate-chart-with-group-by-column-with-unknow-number/m-p/545130#M76364</guid>
      <dc:creator>ankitgssingh</dc:creator>
      <dc:date>2022-09-15T22:43:53Z</dc:date>
    </item>
  </channel>
</rss>

