Share your ideas for the JMP Scripting Unsession at Discovery Summit by September 17th. We hope to see you there!
Choose Language Hide Translation Bar
Highlighted
shaira
Level IV

How to remove Points or Smooth Legend for Graph Builder using JSL?

Hi,

By default if there are points and smoothing line in Graph Builder, there are legends for both. Sometimes, having two legends is redundant and I would like to get rid of one. What is the syntax for this?

 

I made a graph builder function (see below). But I can't seem to remove the Legend even if I put Legend (0) in Points.

 

//Variable //Definition
 //listin ==> list object which contains the following arguments:
 //1. Ncol for Line Up Box output
 //2. Frame size length
 //3. Frame size height
 //4. X axis column
// 5+. Y axis columns
// grp ==> grouping variable for X
//ovl ==> grouping variable for overlay (fitting)
// plotout ==> line up box object output

dgbplot = Function({listin,grp,ovl},{plotout},
                  plotout=Lineup Box(N Col(listin[1]),);
                  For (i=5, i<=Nitems(listin), i++,
                       gb = Graph Builder(
                                          Size( Eval(listin[2]), Eval(listin[3]) ),
                                          Show Control Panel( 0 ),
                                          Variables(
                                                     X( Column(Eval(listin[4]))),
                                                     Y( Column(Eval(listin[i]))),
                                                     Group X(Column(grp)),
                                                     Overlay(Column(ovl))
                                                    ),
                                          Elements( Points( X, Y ), Smoother( X, Y, Legend(0), Lambda(5))),
                                        );
                        gbr = gb << report;

                        );
                    plotout;
                   );

On the other hand, I tried making some "trial" script and it does what I want. I can't understand why.

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
Graph Builder(
	Size( 960, 300 ),
	Show Control Panel( 0 ),
	Variables(
		X( :weight ),
		Y( :height ),
		Group X( :sex ),
		Overlay( :sex )
	),
	Elements(
		Points( X, Y, ),
		Smoother( X, Y, Lambda( 5 ) )
	)
)

Thanks,

Shaira

 

 

1 REPLY 1
Highlighted
txnelson
Super User

Re: How to remove Points or Smooth Legend for Graph Builder using JSL?

I believe that your function had an issue with what it was returning.  Your "plotout" element was being defined withing the function as:

plotout=Lineup Box(N Col(listin[1]),);

This is a completed object, which contains an empty lineup box.  Nothing else in the function adds to it.  However, it is the element that you specify that should be returned from the function.  The script below will generate the plots you want.  Please note the simple change in the function, that incorporates the Graph Builder code inside of the Lineup Box() 

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

dgbplot = Function( {listin, grp, ovl},
	{plotout},
	plotout = Lineup Box( N Col( listin[1] ),
		For( i = 5, i <= N Items( listin ), i++,
			gb = Graph Builder(
				Size( Eval( listin[2] ), Eval( listin[3] ) ),
				Show Control Panel( 0 ),
				Variables(
					X( Column( Eval( listin[4] ) ) ),
					Y( Column( Eval( listin[i] ) ) ),
					Group X( Column( grp ) ),
					Overlay( Column( ovl ) )
				),
				Elements( Points( X, Y ), Smoother( X, Y, Legend( 0 ), Lambda( 5 ) ) )
			// uncomment the lines below to remove smoother legend and keep points
			/*,SendToReport(
				Dispatch(
					{},
					"400",
					LegendBox,
					{Legend Position( {2, [0, 1], 1, [-1, -1]} ), Position( {0, 1, -1, -1} )}
				)
			)*/
			);
			gbr = gb << report;
		)
	);
	plotout;
);

listin = {1, 960, 300, "weight", "height"};

nw = New Window( "test", vlb = V List Box() );
myplot = dgbplot( listin, "sex", "sex" );

vlb << append( myplot );
Jim
Article Labels

    There are no labels assigned to this post.