cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
nathan-clark
Level VI

Graphics script to detect graph title

I would like to set up a custom graphics script so each graph gets a unique line based on information contained in an associative array. In the example below, I want to have a graph on the line differently for each category... for my actual use, I will need the graph to 'recognize' the heading it's under so I can use the correct values for the line creation.

 

For the example image below, I manually updated the "F" graphics script to be "F". So I am looking to find syntax to "gather the graph info" ... in my head, if I can grab the outline box title, I can manipulate that to get what I need... but I am not sure if that is the only/best option.

 

Names Default To Here( 1 );

dt = Open( "$SAMPLE_DATA\Big Class.jmp" );

dt << Bivariate(
	Y( :height ),
	X( :weight ),
	By( :sex ),
	SendToReport(
		Dispatch(
			{},
			"1",
			ScaleBox,
			{Format( "Fixed Dec", 12, 0 ), Min( 30 ), Max( 180 ), Inc( 20 ),
			Minor Ticks( 1 )}
		),
		Dispatch(
			{},
			"Bivar Plot",
			FrameBox,
			{Add Graphics Script(
				2,
				Description( "" ),
				test = Associative Array( {{"F", {0.1, 50}}, {"M", {.8, 0}}} );
				///gather graph info to get "F" or "M" from output
				graphInfo = "M";// need to extract so it's "F" for female graph
				Y Function( test[graphInfo][1] * x + test[graphInfo][2], x );
			), Grid Line Order( 1 ), Reference Line Order( 3 )
			}
		)
	)
);
 

nathan-clark_1-1619112295335.png

 

11 REPLIES 11
Craige_Hales
Super User

Re: Graphics script to detect graph title

If you make the entire graphic script a function, it gets a this parameter that is the frame box. You can climb up to the outline to grab the title. The benefit is knowing you got the outline containing this graph.

Outline title copied into graph by graphic scriptOutline title copied into graph by graphic script

dt = Open( "$sample_data/big class.jmp", invisible );
bv = dt << Bivariate( Y( :weight ), X( :height ), Fit Line );
(bv << report)[framebox( 1 )] << addgraphicsscript(
	// if a function is used, it must be the only statement in the graphic script
	Function( {this},{titlebox=this},
		// the function can use this to find the frame box, climb to an Outline title...
		While( (titlebox << classname) != "OutlineBox", titlebox = titlebox << parent ); 
		// then other graphics commands
		Text( center justified, {60, 120}, (titlebox << gettitle) );
		Circle( {60, 120}, 30 );
		this<<backgroundcolor(rgbcolor(.9,.9,1.0)); // make the frame box light blue
	)
);
Craige
nathan-clark
Level VI

Re: Graphics script to detect graph title

@Mark_Bailey Thanks for that idea! It's good to know that summarize will match the order of how the graphs will be created in the report. That's something I can see uses for in several of my scripts

 

@Craige_Hales That's a really cool idea with the function, I'll have to play with that, too!