Add Graphics Script Not Updating When Rows Hidden/ExcludedI 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 )}
)
)
);Re: Add Graphics Script Not Updating When Rows Hidden/ExcludedThe local data filter has a private table and I do not know how to get a handle to it. However, you can get correct the calculation by:
- get the filtered rows from the local data, these are rows remaining after applying the restriction, it does not account for excluded
- get the excluded rows from the data table
- remove the excluded from the filtered
- then calculate the statistics
This issue with the histogram is that placement in the frambox is screwy in my opinion. Maybe someone on the forum, can explain how to set teh text as an offset from the top left corner. I would probably writ it out in its own text box it ?? The screenshot below shows the text matches the summary table. The script is attached.
Re: Add Graphics Script Not Updating When Rows Hidden/ExcludedI see now that the local data filter will cause it to fail. I could put the filter at the table level as a work around, so it would hide/exclude, but this will work close enough for my immediate needs. Thanks.
Re: Add Graphics Script Not Updating When Rows Hidden/ExcludedThanks. 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.
Re: Add Graphics Script Not Updating When Rows Hidden/ExcludedSee 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;
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
)
);
Re: Add Graphics Script Not Updating When Rows Hidden/ExcludedI do not see a way to underline the text, except if you added a line() function under the word
Re: Add Graphics Script Not Updating When Rows Hidden/ExcludedThanks. 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?

Re: Add Graphics Script Not Updating When Rows Hidden/Excludedit appears that the Y axis position is Y/100
Re: Add Graphics Script Not Updating When Rows Hidden/ExcludedAny guidance on how to choose the _y_ value? the _x_ value seems tied ot the x-axis scale, but the _y_ doesn't.
Re: Add Graphics Script Not Updating When Rows Hidden/ExcludedI 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.
Re: Add Graphics Script Not Updating When Rows Hidden/ExcludedThe 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 )}
)
)
);