Choose Language Hide Translation Bar
Highlighted
MarkDayton
Level IV

Add Graphics Script Not Updating When Rows Hidden/Excluded

I want to add text labels to a histogram with the mean and the standard deviation. I figured out how to do it through the customize function to add a graphics script. I'm still unclear on how to set the y-value, since it doesn't seem to be connected to the axis units, but I can work around that. My problem is that the labels do not update in response to a local data filter, or by hidding/excluding rows. The only thing that works is to delete rows. I am using col mean() & col std dev(); should I be using something else?

 

NamesDefaultToHere(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");

dt << Distribution(
	Stack( 1 ),
	Automatic Recalc( 1 ),
	Continuous Distribution(
		Column( :height ),
		Summary Statistics( 1 ),
		Horizontal Layout( 1 ),
		Vertical( 0 ),
		Count Axis( 1 ),
		Set Quantile Increment( 0.25 ),
		Customize Summary Statistics(
			Std Err Mean( 0 ),
			Upper Mean Confidence Interval( 0 ),
			Lower Mean Confidence Interval( 0 ),
			N( 0 ),
			Median( 0 )
		)
	),
	Histograms Only,
	Local Data Filter( Grouped by AND( 1 ), Add Filter( columns( :height ) ) ),
	SendToReport(
		Dispatch(
			{"height"},
			"Distrib Histogram",
			FrameBox,
			{Frame Size( 414, 428 ),
			Add Graphics Script(
				2,
				Description( "Script" ),
				Text(
					Right Justified,
					{72, 0.11},
					"Mean: " || Format( Col Mean( :height ), "Fixed Dec", 12, 2 )
				);
				Text(
					Right Justified,
					{72, 0.105},
					"StdDev: " || Format(
						Col Std Dev( :height ),
						"Fixed Dec",
						12,
						2
					)
				);
			), Grid Line Order( 1 ), Reference Line Order( 3 )}
		)
	)
);
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
gzmorgan0
Super User

Re: Add Graphics Script Not Updating When Rows Hidden/Excluded

****Ignore this suggestion . This is a local data filter, so the table rows are not excuded*** 

 

An alternative is to use only non-excluded rows

Text(
	Right Justified,
	{72, 0.11},
	"Mean: " || Format( Col Mean( If(Excluded(),empty(),1)*:height ), "Fixed Dec", 12, 2 )
);
Text(
	Right Justified,
	{72, 0.105},
	"StdDev: " || Format(
		Col Std Dev(If(Excluded(),empty(),1) *:height ),
		"Fixed Dec",
		12,
		2
	)
);

 

View solution in original post

11 REPLIES 11
Highlighted
txnelson
Super User

Re: Add Graphics Script Not Updating When Rows Hidden/Excluded

The issue you are having is that Col Mean() and Col Std Dev() functions do not follow the Excluded data rules.  So you need to have some way to get the values you want.  Below is one way to do it.

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

dis = dt << Distribution(
	Stack( 1 ),
	Automatic Recalc( 1 ),
	Continuous Distribution(
		Column( :height ),
		Summary Statistics( 1 ),
		Horizontal Layout( 1 ),
		Vertical( 0 ),
		Count Axis( 1 ),
		Set Quantile Increment( 0.25 ),
		Customize Summary Statistics(
			Std Err Mean( 0 ),
			Upper Mean Confidence Interval( 0 ),
			Lower Mean Confidence Interval( 0 ),
			N( 0 ),
			Median( 0 )
		)
	),
	Histograms Only,
	Local Data Filter( Grouped by AND( 1 ), Add Filter( columns( :height ) ) ),
	SendToReport(
		Dispatch(
			{"height"},
			"Distrib Histogram",
			FrameBox,
			{Frame Size( 414, 428 ), Add Graphics Script(
				2,
				Description( "Script" ),
				Text(
					Right Justified,
					{72, 0.11},
					"Mean: " || Format(report(dis)[numbercolbox(1)][1]/* Col Mean( :height )*/, "Fixed Dec", 12, 2 )
				);
				Text(
					Right Justified,
					{72, 0.105},
					"StdDev: " || Format(report(dis)[numbercolbox(1)][2]/* Col Std Dev( :height )*/, "Fixed Dec", 12, 2 )
				);
			), Grid Line Order( 1 ), Reference Line Order( 3 )}
		)
	)
);
Jim
Highlighted
MarkDayton
Level IV

Re: Add Graphics Script Not Updating When Rows Hidden/Excluded

I included the summary statistics in my example to show what I was expecting to happen, but had not planned to use it in my application. I guess I could enable it, but have it minimized so it won't be included when I copy the graph for insertion into a presentation. Seems a kludge, and that these functions are behaving in an unexpected way, but it will get the job done. Thanks.

Highlighted
MarkDayton
Level IV

Re: Add Graphics Script Not Updating When Rows Hidden/Excluded

Any guidance on how to choose the _y_ value? the _x_ value seems tied ot the x-axis scale, but the _y_ doesn't.

Highlighted
txnelson
Super User

Re: Add Graphics Script Not Updating When Rows Hidden/Excluded

it appears that the Y axis position is Y/100

Jim
Highlighted
MarkDayton
Level IV

Re: Add Graphics Script Not Updating When Rows Hidden/Excluded

Thanks. Do you know of any way to underline the text? I've added headers, and for now I've made the text bigger and offset it, but it would look better underlined. 

 

Also, do you have any idea how to get this to work in Graph Builder, since it doesn't have Summary Statistics to pull from?

Graph Builder.png

 

Highlighted
txnelson
Super User

Re: Add Graphics Script Not Updating When Rows Hidden/Excluded

I do not see a way to underline the text, except if you added a line() function under the word

Jim
Highlighted
gzmorgan0
Super User

Re: Add Graphics Script Not Updating When Rows Hidden/Excluded

See my post about the Col Mean(). Also if  yu are using a TextBox (your code is not visible) you can use markup to underline text. This is the JMP scripting Index example for Display Box > TextBox > Markup

Names Default To Here( 1 );
win = New Window( "Example", fontobj = text = Text Box( "Example Text" ) );
text << setText(
	"This is <b>bold</b> text. This is <i>italic</i> text. This is <u>underlined</u> text. This is <b><i><u>bold, italic, underlined</u></i></b> text."
);
text << markup;

 

Highlighted
MarkDayton
Level IV

Re: Add Graphics Script Not Updating When Rows Hidden/Excluded

Thanks.  The code I used for the Graph Builder example is using the same Text(Center Justified, {_x_, _y_}, "_text_"); command that I used for the Distribution platform example, so I'm not clear on how the syntax would work.

Highlighted
gzmorgan0
Super User

Re: Add Graphics Script Not Updating When Rows Hidden/Excluded

****Ignore this suggestion . This is a local data filter, so the table rows are not excuded*** 

 

An alternative is to use only non-excluded rows

Text(
	Right Justified,
	{72, 0.11},
	"Mean: " || Format( Col Mean( If(Excluded(),empty(),1)*:height ), "Fixed Dec", 12, 2 )
);
Text(
	Right Justified,
	{72, 0.105},
	"StdDev: " || Format(
		Col Std Dev(If(Excluded(),empty(),1) *:height ),
		"Fixed Dec",
		12,
		2
	)
);

 

View solution in original post

Article Labels

    There are no labels assigned to this post.