Share your ideas for the JMP Scripting Unsession at Discovery Summit by September 17th. We hope to see you there!
Choose Language Hide Translation Bar
Highlighted
Juber
Level II

Plot Y axis with different names as the function gets called

Hi,

I'm trying to create a generic graph function for various data tables. So the Y axis column's names also vary and I couldn't find a way to plot it based on the title  pass it. 

title = "no. of people";
gb = graph_func(stackdt,title);

graph_func = function({stackdt,title},{Default Local},				
				gb = Graph Builder(
					Size( 1342, 905 ),
					Variables(
						Y( :title),
						Group X( :Type ),
						Group X( :Stat ),
						Overlay( :MATRIX_GROUP )
					),
					Elements( Box Plot( Y, Legend( 25 ) ), Caption Box( Y, Legend( 26 ) ) ),
					);
				return(gb);
);

Stackdt has a column that's named as no. of people and this name will vary if i call a function for a different data table. I know title is not a column, so it doesn't recognize it but how can i plot this. I've also tried passing in the column but I couldn't get it to work either probably because it didn't get copied. 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
txnelson
Super User

Re: Plot Y axis with different names as the function gets called

If I am understanding what the issue is, I believe all you need to do is to use the As Column() function to clarify to JMP to use the memory variable "title" as a column.  See my example below:

names default to here(1);
stackdt=open("$SAMPLE_DATA/big class.jmp");

graph_func = function({stackdt,title},{Default Local},
Graph Builder(
	Size( 525, 490 ),
	Show Control Panel( 0 ),
	Variables( X( :age ), Y( as column( title ) ), Group X( :sex ) ),
	Elements( Points( X, Y, Legend( 4 ) ) )
));

title = "height";
gb = graph_func(stackdt,title);
Jim

View solution in original post

2 REPLIES 2
Highlighted
txnelson
Super User

Re: Plot Y axis with different names as the function gets called

If I am understanding what the issue is, I believe all you need to do is to use the As Column() function to clarify to JMP to use the memory variable "title" as a column.  See my example below:

names default to here(1);
stackdt=open("$SAMPLE_DATA/big class.jmp");

graph_func = function({stackdt,title},{Default Local},
Graph Builder(
	Size( 525, 490 ),
	Show Control Panel( 0 ),
	Variables( X( :age ), Y( as column( title ) ), Group X( :sex ) ),
	Elements( Points( X, Y, Legend( 4 ) ) )
));

title = "height";
gb = graph_func(stackdt,title);
Jim

View solution in original post

Highlighted
Juber
Level II

Re: Plot Y axis with different names as the function gets called

Thanks, that did the job :).

Article Labels

    There are no labels assigned to this post.