cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
The Discovery Summit 2025 Call for Content is open! Submit an abstract today to present at our premier analytics conference.
Choose Language Hide Translation Bar
SpannerHead
Level V

Annotate Graphs Automatically

I have a string stored in the Notes for a series of columns in a table and I have assigned this to the object "Notes".  When I plot these columns in a variability chart, I would like the Notes to show up automatically as an annotation.  My initial thought was to somehow include the annotation in the original plot but I'm thinking I should create the plots and annotate afterwards.  Any clue how to do this, the code below doesn't work?

spud = Variability Chart( );


spud << Add Text Annotation(
				Text( "Category: " || Notes ),
				Fixed Size( 0 ),
				Text Box( {1, -30, 382, 184} ),
				Filled( 0 )
			);

Slán



SpannerHead
1 ACCEPTED SOLUTION

Accepted Solutions
SpannerHead
Level V

Re: Annotate Graphs Automatically

I make a facsimile of the Variability Plot Interface and Annotate from there.  Will probably need refinement but seems to work.

 

Names Default To Here( 1 );
dt = Current Data Table();
If( !Namespace Exists( "Custom Dialog" ),
dialogRecallNS = New Namespace(
"Custom Dialog",
{
ycolRecall =
{
}
,
standRecall =
{
}
,
xcolRecall =
{
}
,
freqRecall =
{
}
,
partRecall =
{
}
,
byRecall =
{
}
}
)
,
dialogRecallNS = Namespace( "Custom Dialog" )
);
nc = N Col( dt );
lbWidth = 130;
pgm = Expr(
nw = New Window( "Annotated Multiple Plots",
For( i = 1, i <= N Items( exy ), i++,
Notes = Try( Column( dt, exy[i] ) << Get Property( "Notes" ) );
Try(
Variability Chart(
Y( exy[i] ),
X( Eval( exx ) ),
Standard( Eval( Standy ) ),
Freq( Eval( Freqy ) ),
By( Eval( Byy ) ),
SendToReport(
Dispatch(
{},
"",
AxisBox( 2 ),
Add Text Annotation(
Text( "Category: " || Notes ),
Fixed Size( 0 ),
Text Box( {0, -255, 0, 0} ),
Filled( 0 )
)
)
)
)
);
)
)
);
clearRoles = Expr(
colListY << RemoveAll;
colListX << RemoveAll;
Stand << RemoveAll;
Freq << RemoveAll;
Part << RemoveAll;
By << RemoveAll;
);
recallRoles = Expr(
dialogRecallNS:ycolRecall = colListY << GetItems;
dialogRecallNS:xcolRecall = colListX << GetItems;
dialogRecallNS:standRecall = Stand << GetItems;
dialogRecallNS:freqRecall = Freq << GetItems;
dialogRecallNS:partRecall = Part << GetItems;
dialogRecallNS:byRecall = By << GetItems;
);
customDlg = New Window( "Example of a Custom Dialog",
Border Box( Left( 3 ), top( 2 ),
V List Box(
H List Box(
V List Box(
Panel Box( "Select Columns",
colListData =
Filter Col Selector(
All,
width( lbWidth ),
nLines( Min( nc, 10 ) )
)
)
),
Panel Box( "Cast Selected Columns into Roles",
Lineup Box( N Col( 2 ), Spacing( 3 ),
Button Box( "Y, Response",
colListY << Append( colListData << GetSelected )
),
colListY = Col List Box( width( lbWidth ), nLines( 5 ) ),
Button Box( "Standard",
Stand << Append( colListData << GetSelected )
),
Stand = Col List Box( width( lbWidth ), nLines( 1 ) ),
Button Box( "X, Grouping",
colListX << Append( colListData << GetSelected )
),
colListX = Col List Box( width( lbWidth ), nLines( 2 ) ),
Button Box( "Freq",
Freq << Append( colListData << GetSelected )
),
Freq = Col List Box( width( lbWidth ), nLines( 1 ) ),
Button Box( "Part, Sample ID",
Part << Append( colListData << GetSelected )
),
Part = Col List Box( width( lbWidth ), nLines( 1 ) ),
Button Box( "By",
By << Append( colListData << GetSelected )
),
By = Col List Box( width( lbWidth ), nLines( 2 ) )
),
Text Box(
"Operator, Instrument are examples of possible Grouping Columns"
)
),
Panel Box( "Action",
Lineup Box( N Col( 1 ),
Button Box( "OK",
recallRoles;
exy = colListY << get items;
exx = colListX << get items;
Standy = Stand << Get Items;
Freqy = Freq << Get Items;
Party = Stand << Get Items;
Byy = By << Get Items;
pgm;
customDlg << CloseWindow;
),
Button Box( "Cancel", customDlg << CloseWindow ),
Button Box( "Reset", clearRoles ),
Text Box( " " ),
Button Box( "Remove",
colListY << RemoveSelected;
colListX << RemoveSelected;
Stand << RemoveSelected;
Freq << RemoveSelected;
Part << RemoveSelected;
By << RemoveSelected;
),
Button Box( "Recall",
clearRoles;
Try(
colListY << Append( dialogRecallNS:ycolRecall );
colListX << Append( dialogRecallNS:xcolRecall );
Stand << Append( dialogRecallNS:standRecall );
Freq << Append( dialogRecallNS:freqRecall );
Part << Append( dialogRecallNS:partRecall );
By << Append( dialogRecallNS:byRecall );
);
)
)
)
)
)
)
);
colListx << set min items( 1 );
colListy << set min items( 1 );

 


Slán



SpannerHead

View solution in original post

3 REPLIES 3
jthi
Super User

Re: Annotate Graphs Automatically

Might depend on a bit where you wish to add the annotation to

Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Variability Data/2 Factors Crossed.jmp");
obj = dt << Variability Chart(Y(:Measurement), X(:Operator, :part#));
report(obj) << Add Text Annotation(
	Text("We need to discuss this at the next meeting."),
	Text Box({65, 35, 200, 77})
);
-Jarmo
SpannerHead
Level V

Re: Annotate Graphs Automatically

This works well but it needs predefined inputs.  I'm after something that allows inputs to be selected and then annotates those.

 

 

 

 


Slán



SpannerHead
SpannerHead
Level V

Re: Annotate Graphs Automatically

I make a facsimile of the Variability Plot Interface and Annotate from there.  Will probably need refinement but seems to work.

 

Names Default To Here( 1 );
dt = Current Data Table();
If( !Namespace Exists( "Custom Dialog" ),
dialogRecallNS = New Namespace(
"Custom Dialog",
{
ycolRecall =
{
}
,
standRecall =
{
}
,
xcolRecall =
{
}
,
freqRecall =
{
}
,
partRecall =
{
}
,
byRecall =
{
}
}
)
,
dialogRecallNS = Namespace( "Custom Dialog" )
);
nc = N Col( dt );
lbWidth = 130;
pgm = Expr(
nw = New Window( "Annotated Multiple Plots",
For( i = 1, i <= N Items( exy ), i++,
Notes = Try( Column( dt, exy[i] ) << Get Property( "Notes" ) );
Try(
Variability Chart(
Y( exy[i] ),
X( Eval( exx ) ),
Standard( Eval( Standy ) ),
Freq( Eval( Freqy ) ),
By( Eval( Byy ) ),
SendToReport(
Dispatch(
{},
"",
AxisBox( 2 ),
Add Text Annotation(
Text( "Category: " || Notes ),
Fixed Size( 0 ),
Text Box( {0, -255, 0, 0} ),
Filled( 0 )
)
)
)
)
);
)
)
);
clearRoles = Expr(
colListY << RemoveAll;
colListX << RemoveAll;
Stand << RemoveAll;
Freq << RemoveAll;
Part << RemoveAll;
By << RemoveAll;
);
recallRoles = Expr(
dialogRecallNS:ycolRecall = colListY << GetItems;
dialogRecallNS:xcolRecall = colListX << GetItems;
dialogRecallNS:standRecall = Stand << GetItems;
dialogRecallNS:freqRecall = Freq << GetItems;
dialogRecallNS:partRecall = Part << GetItems;
dialogRecallNS:byRecall = By << GetItems;
);
customDlg = New Window( "Example of a Custom Dialog",
Border Box( Left( 3 ), top( 2 ),
V List Box(
H List Box(
V List Box(
Panel Box( "Select Columns",
colListData =
Filter Col Selector(
All,
width( lbWidth ),
nLines( Min( nc, 10 ) )
)
)
),
Panel Box( "Cast Selected Columns into Roles",
Lineup Box( N Col( 2 ), Spacing( 3 ),
Button Box( "Y, Response",
colListY << Append( colListData << GetSelected )
),
colListY = Col List Box( width( lbWidth ), nLines( 5 ) ),
Button Box( "Standard",
Stand << Append( colListData << GetSelected )
),
Stand = Col List Box( width( lbWidth ), nLines( 1 ) ),
Button Box( "X, Grouping",
colListX << Append( colListData << GetSelected )
),
colListX = Col List Box( width( lbWidth ), nLines( 2 ) ),
Button Box( "Freq",
Freq << Append( colListData << GetSelected )
),
Freq = Col List Box( width( lbWidth ), nLines( 1 ) ),
Button Box( "Part, Sample ID",
Part << Append( colListData << GetSelected )
),
Part = Col List Box( width( lbWidth ), nLines( 1 ) ),
Button Box( "By",
By << Append( colListData << GetSelected )
),
By = Col List Box( width( lbWidth ), nLines( 2 ) )
),
Text Box(
"Operator, Instrument are examples of possible Grouping Columns"
)
),
Panel Box( "Action",
Lineup Box( N Col( 1 ),
Button Box( "OK",
recallRoles;
exy = colListY << get items;
exx = colListX << get items;
Standy = Stand << Get Items;
Freqy = Freq << Get Items;
Party = Stand << Get Items;
Byy = By << Get Items;
pgm;
customDlg << CloseWindow;
),
Button Box( "Cancel", customDlg << CloseWindow ),
Button Box( "Reset", clearRoles ),
Text Box( " " ),
Button Box( "Remove",
colListY << RemoveSelected;
colListX << RemoveSelected;
Stand << RemoveSelected;
Freq << RemoveSelected;
Part << RemoveSelected;
By << RemoveSelected;
),
Button Box( "Recall",
clearRoles;
Try(
colListY << Append( dialogRecallNS:ycolRecall );
colListX << Append( dialogRecallNS:xcolRecall );
Stand << Append( dialogRecallNS:standRecall );
Freq << Append( dialogRecallNS:freqRecall );
Part << Append( dialogRecallNS:partRecall );
By << Append( dialogRecallNS:byRecall );
);
)
)
)
)
)
)
);
colListx << set min items( 1 );
colListy << set min items( 1 );

 


Slán



SpannerHead