- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Add Graphics Script H line with variable
Hi all,
I'm trying to add a horizontal line to graph builder object with variable, in this way its works
x = 139.4;
Show( x ); //x = 139.4;
gbReport[Framebox( 1 )] << addGraphicsScript(
H Line( x )
);
But if I'm doing something like that
TR1_row = dt_lims << get selected rows;
TR1 = Column( dt_lims, "CL" )[TR1_row] ;
gbReport[Framebox( 1 )] << addGraphicsScript(
H Line(TR1 )
);
It's not working, any ideas?
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Add Graphics Script H line with variable
Attached is a script that uses a RowState Handler to change limits.
Names Default to Here(1);
dt = Open("$Sample_Data/Big Class.jmp");
dt << sort(By(:sex, :age), Replace Table(1));
dt << New Column( "Order", Numeric);
dt:Order << Set Each Value( If( row()==1 | :sex != lag(:sex,1), 1, lag(:Order,1) +1)) ;
dtsum = dt << Summary( Group(:sex), Min(:height), mean(:height), Max(:height));
dtlims = dtsum << Stack(
columns(
:Name( "Min(height)" ),
:Name( "Mean(height)" ),
:Name( "Max(height)" )
),
Source Label Column( "Label" ),
Stacked Data Column( "Limits" )
);
Close(NoSave, dtsum);
f= Function({a}, {TR1, i},
print(a, fb);
// show(a, fb);
for(i=1, i<=nitems(fb), i++,
Try( fb[i] << Remove Graphics Script (1) )
);
TR1 = :Limits[dtlims << get selected rows];
Eval (EvalExpr( fb << Add Graphics Script( H Line( Expr( TR1) ) ) ) );
);
gb = dt << Graph Builder(
Size( 528, 456 ),
Show Control Panel( 0 ),
Variables( X( :Order ), Y( :height ), Group X(:sex) ),
Elements( Points( X, Y, Legend( 3 ) ), Line( X, Y, Legend( 5 ) ) )
);
fb = gb << Xpath("//FrameBox");
rs = dtlims << Make RowState Handler(f );
Select one or multiple rows or clear all row selections and see the changes on all frameboxes.
This script was tested on JMP 14 & 15. Attached is slight modification of the script at line 26 so that the script works on JMP 13.
So there must be something else wrong with your script, because this works woth a RowState Handler script.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Add Graphics Script H line with variable
The syntax for H Line() is H Line(y), H Line( x1, x2, y). Also, if you have a vector of values, try this script.
Names Default To Here( 1 );
v = [10, 50, 20];
New Window( "Example",
Graph Box(
Pen Size( 2 );
H Line( v );
)
);
Produces this plot:
Check if this script works for you. If it doesn't, please specify which version of JMP and OS you are using.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Add Graphics Script H line with variable
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Add Graphics Script H line with variable
Here is a script that uses JMP sample data table Big Class and selectively uses only Males and adds 3 limits at once.
Names Default to Here(1);
dt = Open("$Sample_Data/Big Class.jmp");
dt << sort(By(:sex, :age), Replace Table(1));
dt << New Column( "Order", Numeric);
dt:Order << Set Each Value( If( row()==1 | :sex != lag(:sex,1), 1, lag(:Order,1) +1)) ;
dtsum = dt << Summary( Group(:sex), Min(:height), mean(:height), Max(:height));
dtlims = dtsum << Stack(
columns(
:Name( "Min(height)" ),
:Name( "Mean(height)" ),
:Name( "Max(height)" )
),
Source Label Column( "Label" ),
Stacked Data Column( "Limits" )
);
Close(NoSave, dtsum);
TR1_row = dtlims << get rows where( :sex =="M");
TR1 = column(dtlims, "Limits")[TR1_row];
gb = dt << Graph Builder( where (:sex=="M"),
Size( 528, 456 ),
Show Control Panel( 0 ),
Variables( X( :Order ), Y( :height ) ),
Elements( Points( X, Y, Legend( 3 ) ), Line( X, Y, Legend( 5 ) ) )
);
gbreport = report(gb);
gbreport[FrameBox(1)] << Add Graphics Script( HLine( TR1 ) );
It produces this plot.
Not sure what seems to be the issue, unless there are no selected rows.
Good Luck!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Add Graphics Script H line with variable
Maybe because I do it inside a function and call this function from MakeRowStateHandler, when I try it outside the function it is working.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Add Graphics Script H line with variable
Attached is a script that uses a RowState Handler to change limits.
Names Default to Here(1);
dt = Open("$Sample_Data/Big Class.jmp");
dt << sort(By(:sex, :age), Replace Table(1));
dt << New Column( "Order", Numeric);
dt:Order << Set Each Value( If( row()==1 | :sex != lag(:sex,1), 1, lag(:Order,1) +1)) ;
dtsum = dt << Summary( Group(:sex), Min(:height), mean(:height), Max(:height));
dtlims = dtsum << Stack(
columns(
:Name( "Min(height)" ),
:Name( "Mean(height)" ),
:Name( "Max(height)" )
),
Source Label Column( "Label" ),
Stacked Data Column( "Limits" )
);
Close(NoSave, dtsum);
f= Function({a}, {TR1, i},
print(a, fb);
// show(a, fb);
for(i=1, i<=nitems(fb), i++,
Try( fb[i] << Remove Graphics Script (1) )
);
TR1 = :Limits[dtlims << get selected rows];
Eval (EvalExpr( fb << Add Graphics Script( H Line( Expr( TR1) ) ) ) );
);
gb = dt << Graph Builder(
Size( 528, 456 ),
Show Control Panel( 0 ),
Variables( X( :Order ), Y( :height ), Group X(:sex) ),
Elements( Points( X, Y, Legend( 3 ) ), Line( X, Y, Legend( 5 ) ) )
);
fb = gb << Xpath("//FrameBox");
rs = dtlims << Make RowState Handler(f );
Select one or multiple rows or clear all row selections and see the changes on all frameboxes.
This script was tested on JMP 14 & 15. Attached is slight modification of the script at line 26 so that the script works on JMP 13.
So there must be something else wrong with your script, because this works woth a RowState Handler script.