cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
SDF1
Super User

How to place label next to data point in GB using JSL

Hi All,

 

  Still working on improving a script I'm writing, and I've gotten a lot of help from @jthi and @txnelson on this -- thank you!

 

  One "last little thing" (there's always something to improve isn't there?). I'd like to put a number label next to the peaks that are identified when looking at the spectral density. Something similar to the Control Chart Builder when you test for warnings beyond limits and the graph puts a little circle around the data point and a small * next to it (see below).

 

SDF1_0-1692296335091.png

 

  But, I don't need the circle or asterisk, just the peak number (1, 2, 3, etc.) to help the user better identify the table box values and the graphical display (see mock up below, numbers highlighted in yellow are what I want to add -- highlighting just for visual ease in this post). The screenshot is the actual interface window from the script -- but without the added text boxes in the graph builder panel. I have an idea of how to build the list of numbers, that's not a problem, it's how to get them to display on the GB that I'm not sure how to do. Fine tuning the positions is a smaller detail I can work on later -- the bigger challenge right now is getting the numbers to show up using JSL.

 

SDF1_1-1692297598815.png

 

  I'd like to do this all in JSL so it's automated. Again, I'm using the Air.jmp data table as a test bed for this. Happy to add my code if you're interested -- just let me know.

 

  Hope this makes sense. Thanks for any help/suggestions you might have!

 

Thanks!,

DS

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: How to place label next to data point in GB using JSL

I would look into using << Add Graphics Script.  You can step through the data table, and when you find a row with the value of 1 for PeriodogramPeaks( @jthi script) you can use the X (Period) and Y (Spectral Density) values to place a Text() value at that point.

Jim

View solution in original post

3 REPLIES 3
jthi
Super User

Re: How to place label next to data point in GB using JSL

What I would try first is to set Marker to the rows you wish to label and then use Label column property. This might not work correctly if you wish to show different points in different plots

jthi_0-1692299482254.png

For few other ideas, see "gpin" (you can do same things you could with hover labels) from scripting index or Graphics/Text

-Jarmo
txnelson
Super User

Re: How to place label next to data point in GB using JSL

I would look into using << Add Graphics Script.  You can step through the data table, and when you find a row with the value of 1 for PeriodogramPeaks( @jthi script) you can use the X (Period) and Y (Spectral Density) values to place a Text() value at that point.

Jim
SDF1
Super User

Re: How to place label next to data point in GB using JSL

Hi @txnelson & @jthi ,

 

  Once again, thanks for the wonderful suggestions. This time, I ended up going with @txnelson 's suggestion of using the <<Add Graphics Script because it gave me a little more flexibility in how I wanted to place the text as well as putting it inside a For() loop to loop through all the peak ranks. I had vectors of the all the Period, Frequency, and Spectral Density (or Periodogram) values, so looping through was easier than searching through the table. It works great, thank you!

 

  One thing to note for any others reading this thread and trying something similar, when adding multiple graphics scripts to the GB or whatever graphic, it's important that you Substitute() the actual variables so that each new text will be placed in a unique location and not just overwritten by the last Add Graphics Script. What I mean by this, is that you need to do something like the following in order to add multiple different texts to the graphic:

Eval(
	Substitute(
			Expr(
				gbframebox_1 << Add Graphics Script( Text( Eval( {__xpos__, __ypos__} ), __gb_text__ ) );
				gbframebox_2 << Add Graphics Script( Text( Eval( {__fpos__, __ypos__} ), __gb_text__ ) );
			),
		Expr( __xpos__ ), xpos,
		Expr( __fpos__ ), fpos,
		Expr( __ypos__ ), ypos,
		Expr( __gb_text__ ), gb_text
	)
);

  All of that needs to be within a For() loop, of course, and with each iteration you redefine what the Expr() variables are so that each added text is unique. Here, the Expr() variables start and end with two underscore characters __ (I believe I adopted this from a previous suggestion I got from @txnelson on handling specification parameters using JSL). Note, for me there are two frame boxes because I am plotting the same y-variable against two different x-variables using graph builder.

 

Thanks again for all your help!,

DS