World Statistics Day was yesterday, but we’re celebrating all week long! This celebration means acknowledging the impact statistics has on our world. Who is your favorite statistician? Share with us who they are and why they top your favorites list.
Choose Language Hide Translation Bar
Highlighted
Level III

## Help with Overlay Plot by Get Column Names

Hi all, hope somebody can help me.

I need to create a chart where in the number of numeric columns changes time to time, but at the end I need to plot all my numeric columns in Overlay plot as shown in below script.

``````Names Default To Here( 1 );
dt = Open( "\$SAMPLE_DATA/Big Class.jmp" );
Overlay Plot( X( :name ), Y( :height, :weight ), Connect Thru Missing( 1 ) );``````

This is what I have tried but charts are created separated, I am wondering hot to accept the instruction for the Y axis. Thanks in advance.

``````dt = Data Table ("Big Class");
list = dt << get column names(numeric, continuous);
show (list);
For( i = 1, i <= N Items(list), i++,
Overlay Plot(
Y( Column( list[i] ) ),
X( :name ), Connect Thru Missing( 1 ) ) );``````
3 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
Super User

## Re: Help with Overlay Plot by Get Column Names

The argument of Y(...) seems not to evaluated at runtime by the Overlay Plot platform.

Here's one way to force replace the list variable with an explicit list of columns before creating the plot:

``````dt = Open("\$SAMPLE_DATA/Big Class.jmp");
list = dt << get column names(numeric, continuous);
op = Expr(
Overlay Plot(Y((Expr(list))), X(:name), Connect Thru Missing(1))
);
Eval(Eval Expr(op));``````
Highlighted
Staff

## Re: Help with Overlay Plot by Get Column Names

FYI, this also works:

``````myOP = dt << Overlay Plot(Y(dt << get column names(numeric, continuous)), X(:name), Connect Thru Missing(1));
``````
Highlighted
Super User

## Re: Help with Overlay Plot by Get Column Names

Sorry, this still is not "crystal".  When you refer to the first column, is that the fitrst column in the table or the first continuous column? Same question regarding the last 2 columns.  Also, do you know the names of the columns you want to exclude? Should this be case sensitive?

I have a feeling, you might be asking how to skip certain columns. Not knowing exactly what you are looking for, here is an example that might help. nolist is a list of known names to skip.

``````Names Default to Here(1);

dt = Open("\$sample_data/Semiconductor Capability.jmp");

cnames = dt << get column names("numeric", "String");
nolist = {"wafer", "site", "datetime"};

nw = New Window("Overlay Plots", lub = LineUpBox(ncol(3)));

For(i=1,i<=nitems(cnames), i++,
if (contains(nolist, lowercase(cnames[i]) ), continue() ); //next i
if( Col Number(column(cnames[i]) ) == 0 | Col Std Dev(column(cnames[i])) == 0, continue() );  //next i, no need to plot a constant.
//otherwise
vl = VlistBox(op = Overlay Plot(Y( Column(cnames[i])), X(:lot_id) ) );
Report(op)[OutlineBox(1)] << set title("Overlay Plot: " || cnames[i] || " vs. lot_id");
lub << append(vl);
);

``````

If you do not know the names to skip, you just know they are in certain positions in the table, create a nolist

``````//or create nolist

nolist = {};
Insert Into(nolist, Column(dt,1) << get name);
Insert Into(nolist, Column(dt, ncol(dt)-1) << get name);
Insert Into(nolist, Column(dt, ncol(dt)) << get name);
show(nolist);

``````

You can also remove these names from cnames. [I am not sure exactly where these positions come from.]  If you just wanted to remove the 1 and the last 2 continuous columns, simply get all continuous columns as show in the script, then

``cnames = cnames[ 2::nitems(cnames)-2 ]; ``

now cnames no longer have those values.

9 REPLIES 9
Highlighted
Super User

## Re: Help with Overlay Plot by Get Column Names

The argument of Y(...) seems not to evaluated at runtime by the Overlay Plot platform.

Here's one way to force replace the list variable with an explicit list of columns before creating the plot:

``````dt = Open("\$SAMPLE_DATA/Big Class.jmp");
list = dt << get column names(numeric, continuous);
op = Expr(
Overlay Plot(Y((Expr(list))), X(:name), Connect Thru Missing(1))
);
Eval(Eval Expr(op));``````
Highlighted
Staff

## Re: Help with Overlay Plot by Get Column Names

FYI, this also works:

``````myOP = dt << Overlay Plot(Y(dt << get column names(numeric, continuous)), X(:name), Connect Thru Missing(1));
``````
Highlighted
Level III

## Re: Help with Overlay Plot by Get Column Names

This is also a different approach,

thank you for the support @ian_jmp and @ms

Highlighted
Super User

## Re: Help with Overlay Plot by Get Column Names

There are 2 good solutions to your question. I am adding this as an FYI, for a 3rd alternative.

i like to work with the column names as text. When you have a list of column names (string) certain platforms (not all) require Eval List(), so I suggest to use it pro forma (a standard).

``````dt = Open("\$SAMPLE_DATA/Big Class.jmp");
mylist = dt << get column names(numeric, continuous, string);
op = Overlay Plot(Y(EvalList(mylist)), X(:name), Connect Thru Missing(1));
``````

Highlighted
Level III

## Re: Help with Overlay Plot by Get Column Names

I have an additional question, if the case is that I have several columns numeric, continuous in my table but I just want to create my Overlay Plot with some columns.

What is the best approach to select the list of columns from a loop?

Let's say I want the loop to select only from the column 3 (column 3 numeric, continues to <=N Items), or loop from column 1 (column 1 numeric, continues to less by 2 total N Items).

Highlighted
Super User

## Re: Help with Overlay Plot by Get Column Names

I do not understand your question exactly, so I will give you a couple pointers. You should read up on lists and working with lists. For example,

``````mylist = words("abcdefghijklmnopqrstuvwxyz","");
show(mylist); // see the log list of characters a-z

show( mylist[ 3::nitems(mylist)-2 ] ); //see log c-x
``````

I assume if  you are wanting to start after column 3, you know what the first 3 columns might be. So one approach would be to get the all continuous column names, and remove the names of the first 3 columns.

Highlighted
Level III

## Re: Help with Overlay Plot by Get Column Names

Hi @gzmorgan0 sorry for not being so clear with my question.

Let me try to explain deeper, some times my tables contain 5 or up to 7 columns, then from the columns numeric/continuous, I want to exclude the first column, or another script would be to exclude only the last 2 columns. when I said exclude, I am referring that get column names can exclude them.

Is there a way to do it through loop?

Another option is, my unwished columns (if it is the case) are always in first column or last 2 columns regarding of the column type (numeric, charcater, etc), is there also a way to pick up trhough get the column names using loop?

Thank you!!!

Highlighted
Super User

## Re: Help with Overlay Plot by Get Column Names

Sorry, this still is not "crystal".  When you refer to the first column, is that the fitrst column in the table or the first continuous column? Same question regarding the last 2 columns.  Also, do you know the names of the columns you want to exclude? Should this be case sensitive?

I have a feeling, you might be asking how to skip certain columns. Not knowing exactly what you are looking for, here is an example that might help. nolist is a list of known names to skip.

``````Names Default to Here(1);

dt = Open("\$sample_data/Semiconductor Capability.jmp");

cnames = dt << get column names("numeric", "String");
nolist = {"wafer", "site", "datetime"};

nw = New Window("Overlay Plots", lub = LineUpBox(ncol(3)));

For(i=1,i<=nitems(cnames), i++,
if (contains(nolist, lowercase(cnames[i]) ), continue() ); //next i
if( Col Number(column(cnames[i]) ) == 0 | Col Std Dev(column(cnames[i])) == 0, continue() );  //next i, no need to plot a constant.
//otherwise
vl = VlistBox(op = Overlay Plot(Y( Column(cnames[i])), X(:lot_id) ) );
Report(op)[OutlineBox(1)] << set title("Overlay Plot: " || cnames[i] || " vs. lot_id");
lub << append(vl);
);

``````

If you do not know the names to skip, you just know they are in certain positions in the table, create a nolist

``````//or create nolist

nolist = {};
Insert Into(nolist, Column(dt,1) << get name);
Insert Into(nolist, Column(dt, ncol(dt)-1) << get name);
Insert Into(nolist, Column(dt, ncol(dt)) << get name);
show(nolist);

``````

You can also remove these names from cnames. [I am not sure exactly where these positions come from.]  If you just wanted to remove the 1 and the last 2 continuous columns, simply get all continuous columns as show in the script, then

``cnames = cnames[ 2::nitems(cnames)-2 ]; ``

now cnames no longer have those values.

Highlighted
Level III

## Re: Help with Overlay Plot by Get Column Names

Thank you @gzmorgan0  witht the nolist = {}; and cnames = cnames[ 2::nitems(cnames)-2 ];  I have the options I was looking for.

Sorry for not beig so clear.

I just wanted to figure out how to get the column names (regardless of the column type)  for specific columns based on their position.