cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
tsolomon
Level III

For loop variable graph reference line

I am generating a series of graphs (10 or more graphs in total) with a for loop; however, after the sixth graph the reference lines do not appear in the graph. After about the 10th or 11th graph, the reference lines appear again in the graphs. I have tried adding wait(0); in multiple locations but that hasn't helped. I have tried using different types of graph, standard bivariate vs graph builder, I have tried reducing the size of my original dataset to see if it is a memory issue. None of these attempts have worked and I am looking for any suggestions. The second issue I would like to address which is less of a problem than the first issue is how to close the temp table created without closing the graphs I have created and saved in my output window. I have tried using link to table (0), tried closing the tables after generating the output window and still does not work. Any suggestions is greatly appreciated.

 

For( w = 1, w <= row_count, w++,
	Stmt = CofA_dt10:Parameter[w];
	CofA_dt9 << clear column selection;
	CofA_dt9 << select where( :Parameter == Eval( Parse( Eval Insert( "Stmt" ) ) ) );
	CofA_dt9a = CofA_dt9 << Subset( Output Table( "TempTable" || Char( w ) ), );
 
 
	Mean_4sigmaUCL = CofA_dt9a:UCL_Line[w];
	Mean_4sigmaLCL = CofA_dt9a:LCL_Line[w];
 
 
	output2 << append(
		V List Box(
			CofA_dt9a << 
 
			Bivariate(
				Y( :test_value ),
				X( :shelf_life_start_date ), 
 
				SendToReport(
					Dispatch(
						{},
						"Bivariate Fit of test_value By shelf_life_start_date",
						OutlineBox,
						{Set Title(
							"Parameter Value by shelf_life_start_date -" || Eval(
								Parse( Eval Insert( "Stmt" ) )
							)
						)}
					), 
 
					Dispatch(
						{},
						"2",
						ScaleBox,
						{Add Ref Line( Mean_4sigmaUCL, "Solid", "Red", "Mean_4s_UCL", 1 ),
						Add Ref Line( Mean_4sigmaLCL, "Solid", "Red", "Mean_4s_LCL" )}
					),
					Dispatch( {}, "1", ScaleBox, {Label Row( Label Orientation( "Angled" ) )} ),
					Dispatch( {}, "test_value", TextEditBox, {Set Text( "Parameter Value" )} ), 
 
					Dispatch(
						{},
						"Bivar Plot",
						FrameBox,
						{Frame Size( 1018, 423 ), Row Legend(
							Flagging,
							Color( 1 ),
							Color Theme( "JMP Default" ),
							Marker( 1 ),
							Marker Theme( "Standard" ),
							Continuous Scale( 0 ),
							Reverse Scale( 1 ),
							Excluded Rows( 0 )
 
						)}
					)
				)
			)
		)
	)
 
	;
); //end row loop

 

1 ACCEPTED SOLUTION

Accepted Solutions
Craige_Hales
Super User

Re: For loop variable graph reference line

Try something like this

dt = Open( "$sample_data/big class.jmp" );

output2 = V List Box(); // vlist box of all the results

For( w = 1, w <= N Rows( dt ), w++, // for every row in *some* table (the original question uses a different table for this)
    Stmt = dt:height[w]; // get some interesting value to subset with and make a subset...
    // (This simplied answer  is a little bit  non-sensical without another table involved--it will make duplicate graphs)
    dt << Clear Row States; // I think this is what you wanted, rather than clearing the column selection
    dt << select where( dt:height == Stmt );
    CofA_dt9a = dt << Subset( Output Table( "TempTable" || Char( w ) ) ); // make a subset

    row1weight = CofA_dt9a:weight[1]; // use row 1 of the subset to get values that will
    row1age = CofA_dt9a:age[1]; // be visible on the X and Y axes

    output2 << append( // collect all the results here
        V List Box( // a list of 1 box; bivariate attaches to this vlist rather than making a window
            (CofA_dt9a << Bivariate( Y( :weight ), X( :age ),
                SendToReport( // the next line has a hyphen that appears to make stmt negative...
                    Dispatch({},"Bivariate Fit of weight By age",OutlineBox,{Set Title( "Parameter Value by shelf_life_start_date -" || Char( stmt ) )}),
                    Dispatch( {}, "2", ScaleBox, {Add Ref Line( row1weight, "Solid", "Red", "row 1 weight", 1 )} ),
                    Dispatch( {}, "1", ScaleBox, {Label Row( Label Orientation( "Angled" ) ), Add Ref Line( row1age, "Solid", "Red", "row 1 age" )} ), 
                    Dispatch({},"Bivar Plot",FrameBox,{Frame Size( 200, 100 )}
                    )
                )
            ))
        ) << cloneBox // cloning the V List Box and the bivariate platform disconnects the clone from the data table
    );
    Close( CofA_dt9a, nosave ); // the subset is not needed after the clone
); //end row loop

Close( dt, nosave );

New Window( "output2", output2 );
Craige

View solution in original post

5 REPLIES 5
Craige_Hales
Super User

Re: For loop variable graph reference line

Try something like this

dt = Open( "$sample_data/big class.jmp" );

output2 = V List Box(); // vlist box of all the results

For( w = 1, w <= N Rows( dt ), w++, // for every row in *some* table (the original question uses a different table for this)
    Stmt = dt:height[w]; // get some interesting value to subset with and make a subset...
    // (This simplied answer  is a little bit  non-sensical without another table involved--it will make duplicate graphs)
    dt << Clear Row States; // I think this is what you wanted, rather than clearing the column selection
    dt << select where( dt:height == Stmt );
    CofA_dt9a = dt << Subset( Output Table( "TempTable" || Char( w ) ) ); // make a subset

    row1weight = CofA_dt9a:weight[1]; // use row 1 of the subset to get values that will
    row1age = CofA_dt9a:age[1]; // be visible on the X and Y axes

    output2 << append( // collect all the results here
        V List Box( // a list of 1 box; bivariate attaches to this vlist rather than making a window
            (CofA_dt9a << Bivariate( Y( :weight ), X( :age ),
                SendToReport( // the next line has a hyphen that appears to make stmt negative...
                    Dispatch({},"Bivariate Fit of weight By age",OutlineBox,{Set Title( "Parameter Value by shelf_life_start_date -" || Char( stmt ) )}),
                    Dispatch( {}, "2", ScaleBox, {Add Ref Line( row1weight, "Solid", "Red", "row 1 weight", 1 )} ),
                    Dispatch( {}, "1", ScaleBox, {Label Row( Label Orientation( "Angled" ) ), Add Ref Line( row1age, "Solid", "Red", "row 1 age" )} ), 
                    Dispatch({},"Bivar Plot",FrameBox,{Frame Size( 200, 100 )}
                    )
                )
            ))
        ) << cloneBox // cloning the V List Box and the bivariate platform disconnects the clone from the data table
    );
    Close( CofA_dt9a, nosave ); // the subset is not needed after the clone
); //end row loop

Close( dt, nosave );

New Window( "output2", output2 );
Craige
tsolomon
Level III

Re: For loop variable graph reference line

Thank You! This helped me to solve both issues.
tsolomon
Level III

Re: For loop variable graph reference line

Hi Craig, I found one unintended consequence of using the << clonebox. in
my script. I am saving the output as an interactive html and for some
reason when the html is saved, the markers just show up as black dots
versus the standard formatting I am using in the legend. Somehow, the
legend is being deactivated. The interesting thing is in the open window,
the graphs are display correctly, it is just when I open the html file that
I observe the markers do not match the legend. If I save the output as
journal, the legend also works. I have narrowed it down to using the
clonebox (when I comment it out, the html is saved correctly) but havent
been able to find much documentation on how to format the clone box.

The script with your suggestions is below incorporated is below.

For( w = 1, w <= row_count, w++,
	Stmt = CofA_dt10:Parameter[w];
	Stmt2 = CofA_dt10:Material Parameter[w];
	CofA_dt9 << Clear Row States;
	CofA_dt9 << select where( :Parameter == Eval( Parse( Eval Insert( "Stmt" ) ) ) );
	CofA_dt9a = CofA_dt9 << Subset( Output Table( "TempTable" || Char( w ) ), );

	Mean_4sigmaUCL = CofA_dt9a:UCL_Line[1];
	Mean_4sigmaLCL = CofA_dt9a:LCL_Line[1];
	Mean_data = CofA_dt9a:Name( "Mean(real_value)" )[1];
	output2 << append(
		V List Box(
			(CofA_dt9a << Bivariate(
				Y( :test_value ),
				X( :received_date ),
				SendToReport(
					Dispatch(
						{},
						"Bivariate Fit of test_value By received_date",
						OutlineBox,
						{Set Title( Eval( Parse( Eval Insert( "Stmt" ) ) ) )}
					),
					Dispatch(
						{},
						"2",
						ScaleBox,
						{Add Ref Line( Mean_4sigmaUCL, "Solid", "Red", "Mean_4s_UCL", 1 ),
						Add Ref Line( Mean_4sigmaLCL, "Solid", "Red", "Mean_4s_LCL" ),
						Add Ref Line( Mean_data, "Solid", "Green", "Mean" )}
					),
					Dispatch( {}, "1", ScaleBox, {Label Row( Label Orientation( "Angled" ) )} ),
					Dispatch(
						{},
						"test_value",
						TextEditBox,
						{Set Text( Eval( Parse( Eval Insert( "Stmt2" ) ) ) )}
					),
					Dispatch(
						{},
						"Bivar Plot",
						FrameBox,
						{Frame Size( 1018, 423 ), Row Legend(
							Flagging,
							Color( 1 ),
							Color Theme( "JMP Default" ),
							Marker( 1 ),
							Marker Theme( "Standard" ),
							Continuous Scale( 0 ),
							Reverse Scale( 1 ),
							Excluded Rows( 0 )
						)}
					)
				)
			))
		) << cloneBox
	);
	Close( CofA_dt9a, nosave );
); //end row loop


This is the script to save the html file, it comes right after creating the
output window so I am at a loss as to why the clonebox would affect the
formatting?

output = Tab Box( "EASY Summary", output1, "Trend Graphs", output2 );
output_window = New Window( "F68 CofA Flagging Summary", output );
output_window << Save Interactive html(
	path || "FlagSummaryAll" || "
Sigma=" || Char( sigma ) || " Days=" || Char( Days ) || ".html"
);
Craige_Hales
Super User

Re: For loop variable graph reference line

@John_Powell_JMP for the HTML question.

 

The clone box operation turns a live report into a static set of display boxes. I'm not sure how much interactivity you can expect (I think none.) You might be able to use <<saveHtml rather than <<saveInteractiveHtml and get the output you expect, or it may do exactly the same thing.

Craige

Re: For loop variable graph reference line

Interactive HTML tries to maintain some interactivity when wrapped in a clonebox, but as Craige notes it ... 

"disconnects the clone from the data table"

When a Row Legend is used, the colors and marker shapes are stored in the table. When the connection to the table is broken using clonebox, I believe new marker attribute data structures are created allowing the desktop windows to retain marker attributes, but these data structures are not exported to Interactive HTML.

 

I agree that SaveHTML should provide correct display in HTML, because images of the graphs (as they look on the desktop) will appear in the HTML.  

 

With Graph Builder, marker colors and shapes are not stored in the table, so if you were able to build the same bivariate plots using Graph Builder, you should be able to retain marker colors and shapes whether or not you wrap graphs in a clonebox. Using Graph Builder it may not be necessary to use a clonebox at all. 

 

~John