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] Color Gradient Output

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

Jun 21, 2017 7:55 PM
(3144 views)

R1=(dt<< Tabulate(

Show Control Panel( 0 ),

Show Tooltip( 1 ),

Add Table(

Column Table( Statistics( N )),

Column Table( Grouping Columns( :Name( "TEST" ) ), Statistics( Row %, N )),

Row Table( Grouping Columns( :Radius ) )

)

)) << Make Into Data Table;

R1:"N(1)"<< Set Property( "Color Gradient", {"White to Orange", Range( {0, 547, 187.945945945946} )} )

<< Color Cell by Value;

R1:"N(8)"<< Set Property( "Color Gradient", {"White to Orange", Range( {0, 547, 187.945945945946} )} )

<< Color Cell by Value;

R1:"N(9)"<< Set Property( "Color Gradient", {"White to Orange", Range( {0, 547, 187.945945945946} )} )

<< Color Cell by Value;

The output of the script above is combined together. Therefore the colour gradient that is set for N(1), N(8), N(9) has combined, how do i seperate each N(s) to have their own specific colour gradient

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

The script fails because there is not a column defined called:

Zero to Three 3

The log issues the following error

Scoped data table access requires a data table column or variable in access or evaluation of 'dt:zero to three 3' , dt:zero to three 3/*###*/

This can be handled in several ways. If you want to continue using "Hard Coding" you can overcome the issue with the "Try" function:

```
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\big class.jmp" );
dt << New Column( "zero to three", formula( Random Integer( 0, 3 ) ) );
dt << New Column( "zero to three 2", formula( Random Integer( 0, 3 ) ) );
dt << New Column( "zero to three 4", formula( Random Integer( 0, 3 ) ) );
Try( dt:zero to three << Set Property( "Color Gradient", {"White to Orange"} ) << Color Cell by Value );
Try( dt:zero to three 2 << Set Property( "Color Gradient", {"White to Orange"} ) << Color Cell by Value );
Try( dt:zero to three 3 << Set Property( "Color Gradient", {"White to Orange"} ) << Color Cell by Value );
Try( dt:zero to three 4 << Set Property( "Color Gradient", {"White to Orange"} ) << Color Cell by Value );
```

Or, you can get a little more advanced and look and see if what names match the pattern you want, and if it does match it, then apply the color gradient:

```
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\big class.jmp" );
dt << New Column( "zero to three", formula( Random Integer( 0, 3 ) ) );
dt << New Column( "zero to three 2", formula( Random Integer( 0, 3 ) ) );
dt << New Column( "zero to three 4", formula( Random Integer( 0, 3 ) ) );
ColNames = dt << get column names( string, numeric );
For( i = 1, i <= N Items( ColNames ), i++,
If( Contains( Uppercase( ColNames[i] ), "ZERO TO THREE" ) == 1,
Column( dt, ColNames[i] ) << Set Property( "Color Gradient", {"White to Orange"} ) << Color Cell by Value
)
);
```

Is this the issue you are trying to work around?

Jim

10 REPLIES 10

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

Re: [Script] Color Gradient Output

Can you provide the R1 data table?

Jim

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

Re: [Script] Color Gradient Output

Hi, the attachment is the R1 data table

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

Re: [Script] Color Gradient Output

I hope this is what you are asking for.

To change the color pattern, all you have to do is to change the Gradient Pattern and/or the color range. Below I have taken the first column N(1) and changed it's gradient

```
R1:"N(1)" << Set Property( "Color Gradient", {"Blue to Green to Red", Range( {31, 284, 150} )} ) << Color Cell by Value;
R1:"N(8)" << Set Property( "Color Gradient", {"White to Orange", Range( {0, 547, 187.945945945946} )} ) << Color Cell by Value;
R1:"N(9)" << Set Property( "Color Gradient", {"White to Orange", Range( {0, 547, 187.945945945946} )} ) << Color Cell by Value;
```

Jim

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

Re: [Script] Color Gradient Output

Hi,

Well I am doing it this way, but as the data size increases to N(99), all columns would not apply the colour patterns.

Is there another way to apply the colour patterns?

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

Re: [Script] Color Gradient Output

Can you please explain why going above 99 columns would be a limitation? I don't understand your comment.

Jim

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

Re: [Script] Color Gradient Output

I would like the output from picture 2

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

Re: [Script] Color Gradient Output

I must be missing something, because the color gradient, and the specified range you can control. So I don't see why there is an issue with the colors not being set as you desire. Below is an example of letting the coloring being set by JMP evalueating the range of the values, and a second example of you setting the values.

These values can be set by calculating the column means, or whatever method you want

```
Names default to here(1);
dt=open("$SAMPLE_DATA\big class.jmp");
dt<<new column("zero to three", formula(random integer(0,3)));
dt<<new column("zero to three 2", formula(random integer(0,3)));
dt:zero to three << Set Property( "Color Gradient", {"White to Orange"} ) << Color Cell by Value;
dt:zero to three 2 << Set Property( "Color Gradient", {"White to Orange",Range( {0,3,1.5} )}) << Color Cell by Value;
```

Now, if you want to explicitly set a color to a specific cell, then you can do that.

```
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
:Age << Color Cells( "Red",5 );
```

Jim

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

Re: [Script] Color Gradient Output

Ok, I have understood the problem of my script. Try running this.

```
Names default to here(1);
dt=open("$SAMPLE_DATA\big class.jmp");
dt<<new column("zero to three", formula(random integer(0,3)));
dt<<new column("zero to three 2", formula(random integer(0,3)));
```

dt<<new column("zero to three 4, formula(random integer(0,3)));
dt:zero to three << Set Property( "Color Gradient", {"White to Orange"} ) << Color Cell by Value;
dt:zero to three 2 << Set Property( "Color Gradient", {"White to Orange"}) << Color Cell by Value;

dt:zero to three 3 << Set Property( "Color Gradient", {"White to Orange"}) << Color Cell by Value;

dt:zero to three 4 << Set Property( "Color Gradient", {"White to Orange"}) << Color Cell by Value

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

The script fails because there is not a column defined called:

Zero to Three 3

The log issues the following error

Scoped data table access requires a data table column or variable in access or evaluation of 'dt:zero to three 3' , dt:zero to three 3/*###*/

This can be handled in several ways. If you want to continue using "Hard Coding" you can overcome the issue with the "Try" function:

```
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\big class.jmp" );
dt << New Column( "zero to three", formula( Random Integer( 0, 3 ) ) );
dt << New Column( "zero to three 2", formula( Random Integer( 0, 3 ) ) );
dt << New Column( "zero to three 4", formula( Random Integer( 0, 3 ) ) );
Try( dt:zero to three << Set Property( "Color Gradient", {"White to Orange"} ) << Color Cell by Value );
Try( dt:zero to three 2 << Set Property( "Color Gradient", {"White to Orange"} ) << Color Cell by Value );
Try( dt:zero to three 3 << Set Property( "Color Gradient", {"White to Orange"} ) << Color Cell by Value );
Try( dt:zero to three 4 << Set Property( "Color Gradient", {"White to Orange"} ) << Color Cell by Value );
```

Or, you can get a little more advanced and look and see if what names match the pattern you want, and if it does match it, then apply the color gradient:

```
Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA\big class.jmp" );
dt << New Column( "zero to three", formula( Random Integer( 0, 3 ) ) );
dt << New Column( "zero to three 2", formula( Random Integer( 0, 3 ) ) );
dt << New Column( "zero to three 4", formula( Random Integer( 0, 3 ) ) );
ColNames = dt << get column names( string, numeric );
For( i = 1, i <= N Items( ColNames ), i++,
If( Contains( Uppercase( ColNames[i] ), "ZERO TO THREE" ) == 1,
Column( dt, ColNames[i] ) << Set Property( "Color Gradient", {"White to Orange"} ) << Color Cell by Value
)
);
```

Is this the issue you are trying to work around?

Jim