cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Register to attend Discovery Summit 2025 Online: Early Users Edition, Sept. 24-25.
  • New JMP features coming to desktops everywhere this September. Sign up to learn more at jmp.com/launch.
Choose Language Hide Translation Bar
miguello
Level VI

How alter shapes/text added through Add Graphic Script?

Let's say I want to add custom text or a shape on my graph using "Add Graphics Script":


Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

New Window( "Example",
	gb = Graph Builder(
		Size( 528, 456 ),
		Show Control Panel( 0 ),
		Variables( X( :weight ), Y( :height ), Overlay( :sex ) ),
		Elements( Points( X, Y, Legend( 9 ) ), Smoother( X, Y, Legend( 10 ) ) ), 
	
	)
);
rgb = gb << Report;
framebox = rgb << XPATH( "//FrameBox" );
framebox << Add Graphics Script(
	"Front",
	Description( "CustomText" ),
	{
		Text( "left", 0.05, {100, 55}, "This is my custom text" ) ; 
		Line( {80, 50}, {160, 65} )
	}
);

How do I later change, let's say, font or font size? How do I change line color or style? How do I get references to them to do things like hide, show, delete, etc.?

 

4 REPLIES 4
txnelson
Super User

Re: How alter shapes/text added through Add Graphic Script?

Here is an example taken directly from the Scripting Index for the 

     Delete Graphics Script

message

Names Default To Here( 1 );
Open( "$SAMPLE_DATA/Big Class.jmp" );
biv = Bivariate( Y( :weight ), X( :height ), FitLine );
rbiv = biv << report;
framebox = rbiv[frame box( 1 )];
framebox << Add Graphics Script(
	Transparency( 0.5 );
	Fill Color( {1.0, 0.5, 0.0} );
	Polygon( [60, 72, 57], [75, 120, 120] );
);
framebox << Add Graphics Script(
	Transparency( 0.5 );
	Fill Color( {0.0, 0.5, 1.0} );
	Polygon( [60, 72, 57], [150, 120, 120] );
);
Wait( 2 );
framebox << Remove Graphics Script( 2 );
Jim
miguello
Level VI

Re: How alter shapes/text added through Add Graphic Script?

Ok, that covers some of it.

What if I want that text to be smaller in the first place? Or blue? Or italics? How do I achieve that?

And what if I want line to be dotted and also blue?

jthi
Super User

Re: How alter shapes/text added through Add Graphic Script?

Scripting index has answer to all of these (Text Size, Text Font, Text Color)

Names Default To Here(1);
New Window("Example",
	Graph Box(
		Text Size(100);
		Text Color("Blue");
		Text Font("", "italic");
		Text({50, 20}, "label");
	)
);

Pen Color(), Line Style()

Names Default To Here(1);
New Window("Line Style Example",
	Graph Box(
		Frame Size(500, 400),
		Line Style("Dotted");
		Pen Color("Blue");
		Pen Size(2);
		Line([10 30 90], [88 22 44]);
	);
);

Scripting Guide > Scripting Graphs > Add Lines, Arrows, Points, Shapes, and Text 

 

Edit: added link to Scripting Guide

-Jarmo
miguello
Level VI

Re: How alter shapes/text added through Add Graphic Script?

I figured the rest. They come as separate commands in Graphics Script. Not as properties of or messages to "Text" or "Line".

Recommended Articles