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
kevinatkodak
Level III

Putting a selected column name in a formula

11 REPLIES 11
gzmorgan0
Super User (Alumni)

Re: Putting a selected column name in a formula

First a couple notes:

  • oc is a column reference the syntax oc( Connect Points(1) ) could not be interpretted by JMP.  
  • It seems the syntax shown in the Scripting Index for the Overlay Plot requires the column name, see example below. It will also accept :Name("Volume")(Connect Color (0) );
obj = Overlay Plot(
	X( :Date ),
	Y( :High, :Low, :Close, :Volume ),
	Y Scale( Left, Left, Left, Right )
);
obj << Connect Points( 1 );
obj << :Volume( Connect Color( 0 ) );
obj << :Low( Connect Color( "Red" ) );
  • The overlay plot has some nice features, however, JMP developers would probably recommend using Graph Builder. For the structure of your data table, Overlay might be easier to use, so I will use Overlay.
  • The script below started with a subset of the Football data table, none of th ecolumns you added. Then computes teh Moving Average. The script creates an overlay plot and uses Eval(Parse(EvalInsert())) to construct the syntax shown in the Scripting Index with the quoted name and option to turn off points.
  • The second part of the script demonstartes an alternate method. Turn on lines and points for all overlay columns.  Then use Xpath() to create a list of references to the line segments and the marker segments.  To turn off a line, set the line width to 0. To turn off points, set the transparency to 0.  I find working with the segments uses simpler syntax.  However, Xpath() while extremely useful, is probably consisdered more advanced.  Hope that helps.  

 

Names default to here(1);

dt = current data table();

colnme = "Speed";

oc = Column(dt, colnme);
nc = dt << New Column( colnme || " Moving Average",

     Numeric,
     Formula(Col Moving Average(oc[],1,4,16) )
     
 );
 
 ovp = Overlay Plot( Y(oc, nc));
 ovp << Connect Thru Missing(1);
 ncnme = nc << get name;
 
 //The syntax is ovp << :col( opt1);
Eval( Parse(EvalInsert("ovp <<  :name(\!"^ncnme^\!")(Show Points(0))" ) ) ) ;

//alternate method 

 ovl = Overlay Plot( Y(oc, nc));
 ovl << Connect Thru Missing(1);

lines  = ovl << Xpath("//LineSeg");
points = ovl << Xpath("//MarkerSeg");

wait(2); 
lines[1] << Line width(0); //turn off line 1
wait(2);
lines[1] << Line width(2); //turn on line 1
wait(2);
lines[1] << Line width(0); //turn off line 1
wait(2);
points[2] << Transparency(0); //turn off points 2

 

 

kevinatkodak
Level III

Re: Putting a selected column name in a formula

gzmorgan,

You are a wizard. I tried both methods that you illustrated with success. More importantly, I learned more scripting technique. Many thanks.