cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Try the Materials Informatics Toolkit, which is designed to easily handle SMILES data. This and other helpful add-ins are available in the JMP® Marketplace
Choose Language Hide Translation Bar
Raybob
Level II

Hide graph axes and add x axis min/max values to the graph title

I have graphs plotted, and I would like to have a table script that I can use to remove the axes, and send the x-axis values of the graph to the graph title before it is saved as a PPT. I do not want to hide the axes in the graphs until after I have had a chance to manually re-scale them(too much variation in the data to use set values), so I can use them later as inset graphs for presentations. Is this feasible?

2 ACCEPTED SOLUTIONS

Accepted Solutions
txnelson
Super User

Re: Hide graph axes and add x axis min/max values to the graph title

Here are the 2 pieces of code that will remove the axes and then the code to redisplay the axes

Names Default To Here( 1 );
obj = Current Report();
(obj << xpath( "//AxisBox" )) << visibility( "collapse" );
Names Default To Here( 1 );
obj = Current Report();
(obj << xpath( "//AxisBox" )) << visibility( "visible" );
Jim

View solution in original post

Georg
Level VII

Re: Hide graph axes and add x axis min/max values to the graph title

In addition to @txnelson here is an example how this could work.

Use of XPath is a little tricky, because it will address all items of that type, you need to look which specifically (or all) to change/evaluate.

To get the x values (min max) my best idea was to evaluate the script. May be there is another option.

Names Default To Here( 1 );

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

obj = dt << Graph Builder(
	Size( 528, 454 ),
	Show Control Panel( 0 ),
	Graph Spacing( 5 ),
	Variables( X( :height ), Y( :weight ) ),
	Elements( Points( X, Y, Legend( 3 ) ), Smoother( X, Y, Legend( 4 ) ) )
);
obj << bring window to front();
Wait( 1 );

// change the x-axis of the graph
obj << SendToReport( Dispatch( {}, "height", ScaleBox, {Min( 60.50 ), Max( 65 ), Inc( 2 ), Minor Ticks( 0 )} ) );

Wait( 3 );

// get title of x-axis and show result in log
x_axis_text = (obj << xpath( "//TextEditBox" ))[3] << get text();
Show( x_axis_text );

// collapse x-axis
(obj << xpath( "//AxisBox" ))[1] << visibility( "collapse" );

// get script of Graph Builder to evaluate min and max values
script = obj << get script();
min_txt = Regex( Char( Name Expr( script ) ), "Min\([0-9]+[.]*[0-9]*\)" );
max_txt = Regex( Char( Name Expr( script ) ), "Max\([0-9]+[.]*[0-9]*\)" );
Show( min_txt, Type( max_txt ) );

// set graph title accordingly
(obj << xpath( "//TextEditBox" ))[1] << set text( x_axis_text || " from " || min_txt || " to " || max_txt );

Georg

View solution in original post

4 REPLIES 4
txnelson
Super User

Re: Hide graph axes and add x axis min/max values to the graph title

Here are the 2 pieces of code that will remove the axes and then the code to redisplay the axes

Names Default To Here( 1 );
obj = Current Report();
(obj << xpath( "//AxisBox" )) << visibility( "collapse" );
Names Default To Here( 1 );
obj = Current Report();
(obj << xpath( "//AxisBox" )) << visibility( "visible" );
Jim
Georg
Level VII

Re: Hide graph axes and add x axis min/max values to the graph title

In addition to @txnelson here is an example how this could work.

Use of XPath is a little tricky, because it will address all items of that type, you need to look which specifically (or all) to change/evaluate.

To get the x values (min max) my best idea was to evaluate the script. May be there is another option.

Names Default To Here( 1 );

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

obj = dt << Graph Builder(
	Size( 528, 454 ),
	Show Control Panel( 0 ),
	Graph Spacing( 5 ),
	Variables( X( :height ), Y( :weight ) ),
	Elements( Points( X, Y, Legend( 3 ) ), Smoother( X, Y, Legend( 4 ) ) )
);
obj << bring window to front();
Wait( 1 );

// change the x-axis of the graph
obj << SendToReport( Dispatch( {}, "height", ScaleBox, {Min( 60.50 ), Max( 65 ), Inc( 2 ), Minor Ticks( 0 )} ) );

Wait( 3 );

// get title of x-axis and show result in log
x_axis_text = (obj << xpath( "//TextEditBox" ))[3] << get text();
Show( x_axis_text );

// collapse x-axis
(obj << xpath( "//AxisBox" ))[1] << visibility( "collapse" );

// get script of Graph Builder to evaluate min and max values
script = obj << get script();
min_txt = Regex( Char( Name Expr( script ) ), "Min\([0-9]+[.]*[0-9]*\)" );
max_txt = Regex( Char( Name Expr( script ) ), "Max\([0-9]+[.]*[0-9]*\)" );
Show( min_txt, Type( max_txt ) );

// set graph title accordingly
(obj << xpath( "//TextEditBox" ))[1] << set text( x_axis_text || " from " || min_txt || " to " || max_txt );

Georg
Raybob
Level II

Re: Hide graph axes and add x axis min/max values to the graph title

Thank you very much Georg!

Raybob
Level II

Re: Hide graph axes and add x axis min/max values to the graph title

thank you so much Jim!