cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar

Semicon wafer map plot. How to I fix error?

Names Default To Here(1);

// Function to recode a selected column
recode_column = Function({dataTable, columnToRecode, newColumnName},
    // Check if column exists
    If(Column(dataTable, columnToRecode) != {},
        // Create a mapping for recoding
        aa_recode = Associative Array();
        For(i = 1, i <= N Row(dataTable), i++,
            aa_recode[Column(dataTable, columnToRecode) << Get Value(i)] = Column(dataTable, columnToRecode) << Get Value(i);
        );
        dataTable << New Column(newColumnName, Character, Nominal, << Set Each Value(
            aa_recode[Column(dataTable, columnToRecode)]
        ));
        cols = {};
        For(i = 1, i <= N Col(dataTable), i++,
            cols[N Items(cols) + 1] = Column(dataTable, i) << Get Name
        );
        recodeColListBox << Set Items(cols);
        colorColListBox << Set Items(cols); // Refresh heatmap plotting list
        Show Message("Column recoded and new column added: " || newColumnName);
    ,
        Show Message("Selected column does not exist.")
    );
);

// Function to plot the heatmap
PlotHeatmap = Function({dataTable, colorColumnName},
    If(colorColumnName != "",
        Graph Builder(
            Size(1500, 800),
            Show Control Panel(0),
            Data Table(dataTable),
            Variables(
                X(:x_Location),
                Y(:y_Location),
                Color(Column(dataTable, colorColumnName))
            ),
            Elements(Heatmap(X, Y, Legend(4)))
        )
    ,
        Show Message("Please select a column for color.")
    )
);

list = {};
For(i = 1, i <= N Table(), i++,
    list[i] = Data Table(i) << Get Name
);

// Create the window
win = New Window("JMP ADDIN",
    H List Box(
        V List Box(
            Panel Box("Choose a source data table",
                dtListBox = List Box(list, max selected(1))
            )
        ),
        
        Button Box("Get Columns",
            chosen = Data Table((dtListBox << Get Selected)[1]);
            If(chosen != {},
                cols = {};
                For(i = 1, i <= N Col(chosen), i++,
                    cols[N Items(cols) + 1] = Column(chosen, i) << Get Name
                );
                recodeColListBox << Set Items(cols);
                colorColListBox << Set Items(cols); // Refresh for heatmap plotting
            ,
                Show Message("Please select a valid data table.")
            );
        ),
        
        // Panel for selecting columns to recode
        V List Box(
            Panel Box("Select Columns for Recode",
                recodeColListBox = List Box("")
            )
        ),
        
        // Button to recode a column
        Button Box("Recode Column",
            chosen = Data Table((dtListBox << Get Selected)[1]);
            recode_col = recodeColListBox << Get Selected;
            If(recode_col != "",
                new_col_name = "Recode_" || recode_col; // Define new column name
                recode_column(chosen, recode_col, new_col_name);
                // Refresh column list after recoding
                cols = {};
                For(i = 1, i <= N Col(chosen), i++,
                    cols[N Items(cols) + 1] = Column(chosen, i) << Get Name
                );
                recodeColListBox << Set Items(cols);
                colorColListBox << Set Items(cols); // Ensure the new column is available for heatmap plotting
            ,
                Show Message("Please select a column to recode.")
            );
        ),
        
        // Panel for selecting columns to plot heatmap
        V List Box(
            Panel Box("Select Columns for Heatmap",
                colorColListBox = List Box("")
            )
        ),
        
        // Button to plot the heatmap
        Button Box("Plot Heatmap",
            selectedColorColumn = colorColListBox << Get Selected;
            If(selectedColorColumn != "",
                chosen = Data Table((dtListBox << Get Selected)[1]);
                If(chosen != {},
                    PlotHeatmap(chosen, selectedColorColumn);
                ,
                    Show Message("Selected data table is invalid.")
                );
            ,
                Show Message("Please select a column for color.")
            );
        )
    )
);

WorkFlow: Select Table--> Select Column to Recode--> Recode column(need help to allow recoding for both character and numerical column)--->Refresh column list--> select one or many columns --> Plot Heat Map
Need Help 1) debug the currect script where i can recode only numeric data type columns
2) How to include selection of Character type columns to recode?
3) Can I otherwise open the recode ui preset by jmp(columns--> Recode) as part of the ui?

17 REPLIES 17

Re: Semicon wafer map plot. How to I fix error?

Is there a way to do it? Or another approach to automate these tasks in that order?
Thanks
jthi
Super User

Re: Semicon wafer map plot. How to I fix error?

I think you should re-think the specifications you have for your script. What you have to have, what users could do using JMP's platforms, could they run your script after they have used recode and select those new columns,... and so on

-Jarmo
txnelson
Super User

Re: Semicon wafer map plot. How to I fix error?

What is the rule to be used for the Recoding?  From your example, it appears that the recoding is simply to take rows 1&2 and group them, then take rows 3&4 and to group them, etc. with the first grouping being given a value of 1, and the second grouping the value of 2, etc.

If this is the case, the recoded column formula is simply 

Ceiling(Row() / 2)

Is this what you are looking for?  It will work for both character and numeric data since it does not depend on the values of lot_no or tester, but only on the row number

Jim

Re: Semicon wafer map plot. How to I fix error?

The recoding has to be selected using the ui and can change depending on the user. once the Recode columns is triggered the user can recode as he wants and then add the new column. Then user is prompted to select the new column and use that to configure the plot.. the above was just an example
hogi
Level XII

Re: Semicon wafer map plot. How to I fix error?

one Column List could be enough - via the 2 Buttons the user can decide if he wants to recode or plot the selected columns:

hogi_0-1724330761708.png

 

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

For Each( {col}, {:age, :height, :weight}, col << Set Modeling Type( "Nominal" ) );

New Window( "simple GUI", << Type("Dialog"),
	lb = Filter Col Selector( width( 150 ) ),
	Button Box( "recode",
		cols = lb << get selected();
		dt << select columns( cols );
		dt << Recode;
	),
	Button Box( "plot",
		cols = lb << get selected();
		If( N Items( cols) >= 2 ,
			xcol = cols[1];
			ycol = cols[2];
			Graph Builder( Variables( X(Eval(xcol) ), Y( Eval(ycol) ) ), Elements( Heatmap( X, Y ) ) );
		, 
			Caption( "select 2 columns" )
		);
	)
);

Re: Semicon wafer map plot. How to I fix error?

Okay thanks.. Is there a way I can recode a column and then plot a graph using that column? or open a new gui to plot it?

hogi
Level XII

Re: Semicon wafer map plot. How to I fix error?

Yes.

Just select the column, recode it (via replace) then click on the plot button.
At the moment one needs 2 columns selected (for x and y) to generate a meningful heatmap. Just adjust the code to generate the plot you need.
hogi
Level XII

Re: Semicon wafer map plot. How to I fix error?

Could you explain why you want to set up a workflow which combines the 2 steps:
- recode

- plot

 

Recode is a very common step - but in most cases it's part of a data curation workflow - which is kind of separate from the data analysis. Why do you want to combine the 2 steps?
Do the users have to recode the columns every time before they can plot them.
After User A recoded the column, user B can take the recoded column and doesn't have to recode again. Or do you prefer some "virtual columns" [transform columns]  which will disappear after user A such that user B can define his own recoding.

 

Could you give an example of the plot you want to generate. Is it always the same type of plot? A Heatmap? Which columns should be plotted?
the original column vs. the recoded one? some 3rd column vs. the recoded column? recode 2 columns and plot them?