Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- JMP User Community
- :
- Discussions
- :
- Script multiple columns grouped in distribution plot

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Feb 23, 2019 9:25 AM
(2670 views)

I'm trying to script a way to plot multiple parameter columns that are grouped together in a distribution (as shown in figure). My problem is the code needs a separate "Continuous Distribution" row for each parameter column. My data pulls have different column names and number of columns to plot depending on what I'm doing. I can't figure out how to take that column name list and have it plotted in a group as show below, rather than looping through and creating individual plots for each parameter.

```
Distribution(
Continuous Distribution( Column( :Parameter1 ) ),
Continuous Distribution( Column( :Parameter2 ) ),
Continuous Distribution( Column( :Parameter3 ) )
);
```

1 ACCEPTED SOLUTION

Accepted Solutions

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Here is one way to generate the code required to produce what you want

```
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/big class.jmp" );
// Get the all of the numeric, continuous column names
colNames = dt << get column names( string, continuous );
// Build a character string that represents the commands that need to be run
theExpr = "dis = dt << Distribution(
Continuous Distribution( column( column(dt, colNames[1])))";
// Loop across the remaining columns in the colNames list and generate the continuous distribution
// commands
For( i = 2, i <= N Items( colNames ), i++,
theExpr = theExpr || ", Continuous Distribution( column( column(dt, colNames[" || Char( i ) || "])))"
);
// place the closing ")" to complete the command string
theExpr = theExpr || ");";
// Execute the code generated and placed into the character string variable
Eval( Parse( theExpr ) );
```

Jim

5 REPLIES 5

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Here is one way to generate the code required to produce what you want

```
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/big class.jmp" );
// Get the all of the numeric, continuous column names
colNames = dt << get column names( string, continuous );
// Build a character string that represents the commands that need to be run
theExpr = "dis = dt << Distribution(
Continuous Distribution( column( column(dt, colNames[1])))";
// Loop across the remaining columns in the colNames list and generate the continuous distribution
// commands
For( i = 2, i <= N Items( colNames ), i++,
theExpr = theExpr || ", Continuous Distribution( column( column(dt, colNames[" || Char( i ) || "])))"
);
// place the closing ")" to complete the command string
theExpr = theExpr || ");";
// Execute the code generated and placed into the character string variable
Eval( Parse( theExpr ) );
```

Jim

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Script multiple columns grouped in distribution plot

exactly what I needed... thanks tx!!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Script multiple columns grouped in distribution plot

Jim @txnelson's script provides you much more control and a solution. This as an alternate option, since I have often been asked how to easily script an unknown number of distributions. This script also includes commands to "wrap" distributions and how to send messages to all distributions by sending a message to the object (Capability Analysis message) and to send a message to the reveal icon.

```
Names default to Here(1);
dt = Open("$Sample_Data/Semiconductor Capability.jmp");
cnames = dt << get column names("Continuous", "string");
//Here I will just use 10
cnames = cnames[1::10];
dist = dt << Distribution(Columns(evalList(cnames)));
//if you want to limit the number per row
dist << arrange in rows(3); //change 3 to 5 or whatever you want
dist << Capability Analysis(0); //turn off the distribution
report(dist)[OutlineBox(2)] << Open all like this(1); //reveal all distributions
report(dist)[OutlineBox(2)] << Close all like this(1); //do not reveal
```

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Script multiple columns grouped in distribution plot

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: Script multiple columns grouped in distribution plot

All you need to do is to modify the list of column names, to meet the requirements. There are many ways to do this, below is one example

```
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/semiconductor capability.jmp" );
// Get the all of the numeric, continuous column names
colNames = dt << get column names( string, continuous );
// Work backwards through the list of columns eliminating those that
// do not meet the pattern one is interested in
For( i = N Items( colNames ), i >= 1, i--,
If( left( colNames[i], 3 ) != "NPN" , colNames = remove( colNames, i, 1 ) );
);
// Build a character string that represents the commands that need to be run
theExpr = "dis = dt << Distribution(
Continuous Distribution( column( column(dt, colNames[1])))";
// Loop across the remaining columns in the colNames list and generate the continuous distribution
// commands
For( i = 2, i <= N Items( colNames ), i++,
theExpr = theExpr || ", Continuous Distribution( column( column(dt, colNames[" || Char( i ) || "])))"
);
// place the closing ")" to complete the command string
theExpr = theExpr || ");";
// Execute the code generated and placed into the character string variable
Eval( Parse( theExpr ) );
```

Jim