cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • JMP 19 is here! See the new features at jmp.com/new.
  • Register to attend Discovery Summit 2025 Online: Early Users Edition, Sept. 24-25.
Choose Language Hide Translation Bar
scott1588
Level IV

Problems with drawing lines and arrows on graphs

I'm trying some experiments to figure out how to draw lines and arrows on a graph in JSL. There is not much that has helped me in the Scripting Guide and I didn't see anything previously posted in the community. I have uploaded my JSL script and data table below.

 

In the data table, I have calculated the coordinates for a unit circle at 5 degree intervals. I plotted these with Graph Builder...

 

scott1588_0-1758696854623.png

 Initially, what I would like to do is script an arrow from the origin to each point. Here is the script I am using. I don't get any errors when I run it but it never draws the arrows. I have tried putting the FOR loop within the Graph Builder block as shown here and also outside the block. I can't seem to get either to work.

 

Names Default To Here (1);

dt = "Circle Arrow Data";


Graph Builder(
	Size( 540, 540 ),
	Graph Spacing( 10 ),
	Spacing Borders( 1 ),
	Variables( X( :x coord ), Y( :y coord ) ),
	Elements( Points( X, Y, Legend( 3 ) ) ),
	For( i=0, i<360, i+=5,
		Arrow( {0,:x coord[i]}, {0, :y coord[i]})
	)
);

Ultimately, my goal is to only have the arrows appear when a row or rows are selected but obviously I need to get this working first. This is really about showing wind direction on a graph but I'm taking baby steps in understanding how to draw on graphs.

 

Thanks in advance for any guidance provided.

 

 

 

 

2 REPLIES 2
hogi
Level XIII

Re: Problems with drawing lines and arrows on graphs

excellent timing : )

 

new in JMP19:
Can Vector Field Charts Help Explain Performance in the Last Super Bowl? 

hogi_0-1758702668096.png

 




New Column( "x_0",	Formula( 0 ));
New Column( "y_0",	Formula( 0 ));

Graph Builder(
	Variables( X( :x_0 ), X( :x coord, Position( 1 ) ), Y( :x_0 ), Y( :y coord, Position( 1 ) ) ),
	Elements(
		Line(
			X( 1 ),	X( 2 ),
			Y( 1 ),	Y( 2 ),
			Ordering( "Within Row" ),
			Connection( "Arrow" )
		)
	)
);

 

scott1588
Level IV

Re: Problems with drawing lines and arrows on graphs

Hey @hogi thanks for the script. It works great.

 

I'm trying to understand it though... so a couple of questions.

 

1) What does the Position parameter do?

2) Where do the 1 and 2 come from in the X and Y arguments?

3) What does the Ordering ("Within Row") do? 

 

There seems to be very incomplete documentation on these functions in the scripting help and scripting index.

 

Again, thanks.

Recommended Articles