cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Sign-in to the JMP Community will be unavailable intermittently Dec. 6-7 due to a system update. Thank you for your understanding!
  • We’re retiring the File Exchange at the end of this year. The JMP Marketplace is now your destination for add-ins and extensions.
  • JMP 19 is here! Learn more about the new features.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
miguello
Level VII

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.?

 

1 ACCEPTED SOLUTION

Accepted Solutions
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

View solution in original post

5 REPLIES 5
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 VII

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 VII

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".

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

Hi @txnelson , 

That's a great example, but I think you meant to write "Remove Graphics Script" instead of "Delete Graphics Script".

By the way, the Scripting Index is online now. https://jsl.jmp.com 

You can link directly to functions and messages: 

https://jsl.jmp.com/All%20Categories/Display%20Boxes/FrameBox.html#remove-graphics-script

You won't be able to run directly from the web page like you can from the Scripting Index in JMP, but there's a convenient copy button for each script in the top right corner.  The online Scripting Index can help JMP Live user's edit their scripts on a device that doesn't have JMP installed. 

John_Powell_JMP_0-1761328071728.png

I hope you find this useful.  

~John

 

 

Recommended Articles