cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
ccroisetiere
Level I

How to add Caption Box with CV in Graph Builder

Hi there,

 

Is there a way to modify the script so I can use CV as summary statistic (instead of Std Dev) in the caption box of the Graph Builder?

 

image.png

 

Graph Builder(
	Size( 599, 561 ),
	Show Control Panel( 0 ),
	Fit to Window( "Off" ),
	Variables(
		X( :Run ),
		Y( :Name( "Average Size [bp]" ) ),
		Y( :Name( "Pre PCR cleanup Conc. [ng/µl]" ) ),
		Y( :Name( "Post PCR cleanup Conc (ng/µl)" ) )
	),
	Relative Sizes( "Y", [102 101 102] ),
	Elements(
		Position( 1, 1 ),
		Points( X, Y, Legend( 99 ) ),
		Caption Box( X, Y, Legend( 105 ), Per Factor( 1 ) ),
		Caption Box(
			X,
			Y,
			Legend( 106 ),
			Summary Statistic( "Std Dev" ),
			Per Factor( 1 )
		)
	),
	Elements(
		Position( 1, 2 ),
		Points( X, Y, Legend( 100 ) ),
		Caption Box( X, Y, Legend( 103 ) )
	),
	Elements(
		Position( 1, 3 ),
		Points( X, Y, Legend( 101 ) ),
		Caption Box( X, Y, Legend( 104 ) )
	),
	SendToReport(
		Dispatch( {}, "Run", ScaleBox, {Max( 5.90697674418605 )} ),
		Dispatch(
			{},
			"Average Size [bp]",
			ScaleBox,
			{Min( 361.848159509202 ), Max( 408.460716230722 ), Inc( 5 ),
			Minor Ticks( 1 )}
		),
		Dispatch(
			{},
			"Pre PCR cleanup Conc. [ng/µl]",
			ScaleBox,
			{Min( 49.5574534161491 ), Max( 84.3709251186297 ), Inc( 5 ),
			Minor Ticks( 1 )}
		),
		Dispatch(
			{},
			"Post PCR cleanup Conc (ng/µl)",
			ScaleBox,
			{Min( 37.3742331288344 ), Max( 64.8704881628966 ), Inc( 5 ),
			Minor Ticks( 1 )}
		)
	)
);

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
gzmorgan0
Super User (Alumni)

Re: How to add Caption Box with CV in Graph Builder

Congratulations on your progress. One note with Col stats()  they do not recognize excluded rows. If you have excluded rows use something like this: 

   

Col Mean( :height * If( Excluded( Row State() ), Empty(), 1 ), :age )

This will ignore the exclusions and compte the menn height for each age group.  BTW I have been using JMP and JSL for many years, yet I always learn something new. I have been using a variant of the JSL formula above to ensure exclusions are not used in the aggregate statistics.  Yet just last week, from a post on the blog, I saw an alternate method, which has simpler syntax and will likely work as well

Col Mean( :height, :age, Excluded( Row State() ) )

In other words, something new!

Good luck with scripting the x-axis labels. Send a copy of your script, if you get stuck. 

View solution in original post

6 REPLIES 6
gzmorgan0
Super User (Alumni)

Re: How to add Caption Box with CV in Graph Builder

I found no method to specify CV as a Summary Statistic caption as a GraphBuilder element.  Creating custom labels is an option, however, beware, this will not automatically update the summary with exclusions. Another option not shown here is to add columns of the required summary statistics to the data table,and make those columns labels.

 

The attached script creates the graph below

image.png

  

ccroisetiere
Level I

Re: How to add Caption Box with CV in Graph Builder

Can I create a table summary (by group)  and use the calculated CV as a label for a graph made with the original table?

gzmorgan0
Super User (Alumni)

Re: How to add Caption Box with CV in Graph Builder

Labels appear when hovering over points or for specific points, and there is not much control for the placement of the labels. One JMP developer in a past blog post suggested adding the mean as one of the Y variables. There is not much control on teh placement of labels.

 

Another option is to create a custom x-axis labels or create custom Legend labels that include the statistics.  The attached script does the following:

  • creates the summary table for the by group, computing the group mean and CV
  • adds those values to the table
  • creates a column, referenced by xlabel, that includes the group name and requisite summary statistics
  • creates the graphbuilder plot (see graph and items to note below)

image.pngItems to Note:

  •  Since xlabel is a character column, the column property Value Ordering is required to get the expected order. List ord is created for this purpose.
  • "\!N" is a special character sequenec to add a new line (line break) in the xlabel string.
  • For the 3 line label to appear, the X Title needs to be empty and a two more X Axis labels are added. This allows multiple line axis labels. This is done with the graphbuilder Dispatch statements, 
  • I recommend that the data points are displayed for boxplots to show the distribution/density patterns. i use this solid color customization, only to be eye catching, and since the point of this is to show off the labels. 
  • At the end of this script, xlabel is made a data table label column.  See the script notes.  The picture depicts hovering over a point in January that displays the group summary and that data point's sales value  
piqizuqo
Level I

Re: How to add Caption Box with CV in Graph Builder

I hope it could get solved as i have the same issue.

ccroisetiere
Level I

Re: How to add Caption Box with CV in Graph Builder

This is my first time using script or aggregate summary statistic in JMP so I am learning at the same time. 

 

I was able to modify the script with my own data and graph builder. However this is something I will have to do often or give to colleague with no scripting experience.

 

I was able to use the formula editor to calculate aggregate CV in a new column of my data table:

(Col Std Dev(
	:Concentration,
	:Experiment,
	:Name( "Input DNA (ng)" )
) / Col Mean(
	:Concentration,
	:Experiment,
	:Name( "Input DNA (ng)" )
)) * 100

Graph Builder

GB CV.PNG

Graph Builder(
	Size( 590, 414 ),
	Show Control Panel( 0 ),
	Variables(
		X( :Experiment ),
		X( :Name( "Input DNA (ng)" ), Position( 1 ) ),
		Y( :Concentration )
	),
	Elements(
		Box Plot( X( 1 ), X( 2 ), Y, Legend( 40 ) ),
		Points( X( 1 ), X( 2 ), Y, Legend( 41 ) )
	),
	SendToReport( Dispatch( {}, "graph title", TextEditBox, {Set Text( "" )} ) )
);

 

Next I will try to remove the axis and add the xlabel like your script and just add this to any Graph Builder script when I need. Unless there is another way.

gzmorgan0
Super User (Alumni)

Re: How to add Caption Box with CV in Graph Builder

Congratulations on your progress. One note with Col stats()  they do not recognize excluded rows. If you have excluded rows use something like this: 

   

Col Mean( :height * If( Excluded( Row State() ), Empty(), 1 ), :age )

This will ignore the exclusions and compte the menn height for each age group.  BTW I have been using JMP and JSL for many years, yet I always learn something new. I have been using a variant of the JSL formula above to ensure exclusions are not used in the aggregate statistics.  Yet just last week, from a post on the blog, I saw an alternate method, which has simpler syntax and will likely work as well

Col Mean( :height, :age, Excluded( Row State() ) )

In other words, something new!

Good luck with scripting the x-axis labels. Send a copy of your script, if you get stuck.