cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
ChrisM_X
Level III

Overlay Plot customize color (row colors)

For plotting overlay plots, I have a JMP DataTable where I have programmatically color coded the rows for each device. (large table with 100,000s rows) The color show correctly when I plot at overlay plot X vs Y (points are row colors).  There are a few thousand points for each device, and all of the data from each device is always the same row color.

 

When I group my plot by the device, JMP assigns its own color scheme, not the color of my rows. (Not what I want in this case)

For my plots, I don’t want to show the points, instead I want to connect the points with a line, and  I want the connector color to be the color of my rows.

JMP makes the connector color a constant color, not the color of my rows. The only way I can get different connector color is by grouping by device. But  if I group by device, the colors no long match the color of my rows!

My DataTable does have columns for R,G,B values so I could use this, but wasn’t sure of a what to do?

BTW I run into similar problems using GraphBuilder for this task as well…

 

Any suggestions would be appreciated!

 

Thanks,

Chris

2 ACCEPTED SOLUTIONS

Accepted Solutions
txnelson
Super User

Re: Overlay Plot customize color (row colors)

Here is a script that should give you an idea of how to deal with the RGB colors in setting the Row State colors and/or setting the Value Colors column property

Names Default To Here( 1 );

// Open a sample data table, and modify it to
// have 3 new columns representing the RGB values
dt = Open( "$SAMPLE_DATA\Big Class.jmp" );

dt << New Column( "R" );
dt << New Column( "G" );
dt << New Column( "B" );

For Each Row(
	If(
		:Sex == "F",
			:R = Color To RGB( "red" )[1];
			:G = Color To RGB( "red" )[2];
			:B = Color To RGB( "red" )[3];,
		:R = Color To RGB( "purple" )[1];
		:G = Color To RGB( "purple" )[2];
		:B = Color To RGB( "purple" )[3];,
	)
);

// Here are a couple of examples of setting colors
// The first one just sets the row colors based upon
// the RGB colors from the :R, :G, :B columns
For( i = 1, i <= N Rows( dt ), i++,
	colorList = {};
	colorList[1] = :R[i];
	colorList[2] = :G[i];
	colorList[3] = :B[i];
	Row State( i ) = Color State( colorList );
);

Wait( 10 );
dt << clear row states;
Wait( 5 );

// The next example, sets the row state colors by
// first setting the "Value Colors", column 
// property, and then sets the row state colors
// based upon the "Value Colors"

// To set the "Value Colors", the below commented
// statement needs to be created using JSL
/*dt:sex << set property("value colors",
	{"F" = {0.670588235294118, 0.0313725490196078, 0.988235294117647}, 
	"M" = {0.941176470588235, 0.196078431372549, 0.274509803921569}});*/

// First we will create the female RGB color list
// Find a row that has the RGB colors we desire
rowList = dt << get rows where( :Sex == "F" );

// Since all values of R,G & B will be the same, only used the first
// selected row to create the list for the females
fColorList = {};
fColorList[1] = :R[rowList[1]];
fColorList[2] = :G[rowList[1]];
fColorList[3] = :B[rowList[1]];

// Repeat for the males
rowList = dt << get rows where( :Sex == "M" );

mColorList = {};
mColorList[1] = :R[rowList[1]];
mColorList[2] = :G[rowList[1]];
mColorList[3] = :B[rowList[1]];

// Substitute into a template of the Set Property structure
// the created RGB lists for females and males
Eval(
	Substitute(
			Expr(
				dt:sex << set property( "value colors", {"F" = __fList__, "M" = __mList__} )
			),
		Expr( __fList__ ), fColorList,
		Expr( __mList__ ), mColorList
	)
);

// Set the row state colors
dt << Color by Column( :Sex );
	
Jim

View solution in original post

markschahl
Level V

Re: Overlay Plot customize color (row colors)

10 REPLIES 10
txnelson
Super User

Re: Overlay Plot customize color (row colors)

I would think that you will have better luck in keeping the desired colors you want, by setting the column property, "Value Colors" for the columns you are working with.  For the most part, "Value Colors" are what JMP defaults to.

Jim
ChrisM_X
Level III

Re: Overlay Plot customize color (row colors)

This is helpful, when I "mark" a column (Label / Unlabel), and color by that column,  the row colors now match the color when I plot and group by that column, but now my question is how do I programitically set the RGB values for different groups in that column.   I want the ability to set what each of the colors are by the RGB values. Not sure of the JSL sytex.  I have a column for R, G and B, and could create a concateanted column that has all 3, then color by that column, but wasn't sure of how to programitcally set the propertes for the different groups.

cwillden
Super User (Alumni)

Re: Overlay Plot customize color (row colors)

It's hard for me to visualize what you got based on your description, but you might need to look at how Overlay Plot applies custom colors to your groups by choosing some colors manually and saving the script.  Then I would think you could write your own script that specifies the desired RGB values for each group instead.  You might need to build the script through a loop or something, but I'm sure it's possible.

Any chance you can provide a minimal working example for a data set to illustrate what you're describing?

-- Cameron Willden
txnelson
Super User

Re: Overlay Plot customize color (row colors)

Here is a script that should give you an idea of how to deal with the RGB colors in setting the Row State colors and/or setting the Value Colors column property

Names Default To Here( 1 );

// Open a sample data table, and modify it to
// have 3 new columns representing the RGB values
dt = Open( "$SAMPLE_DATA\Big Class.jmp" );

dt << New Column( "R" );
dt << New Column( "G" );
dt << New Column( "B" );

For Each Row(
	If(
		:Sex == "F",
			:R = Color To RGB( "red" )[1];
			:G = Color To RGB( "red" )[2];
			:B = Color To RGB( "red" )[3];,
		:R = Color To RGB( "purple" )[1];
		:G = Color To RGB( "purple" )[2];
		:B = Color To RGB( "purple" )[3];,
	)
);

// Here are a couple of examples of setting colors
// The first one just sets the row colors based upon
// the RGB colors from the :R, :G, :B columns
For( i = 1, i <= N Rows( dt ), i++,
	colorList = {};
	colorList[1] = :R[i];
	colorList[2] = :G[i];
	colorList[3] = :B[i];
	Row State( i ) = Color State( colorList );
);

Wait( 10 );
dt << clear row states;
Wait( 5 );

// The next example, sets the row state colors by
// first setting the "Value Colors", column 
// property, and then sets the row state colors
// based upon the "Value Colors"

// To set the "Value Colors", the below commented
// statement needs to be created using JSL
/*dt:sex << set property("value colors",
	{"F" = {0.670588235294118, 0.0313725490196078, 0.988235294117647}, 
	"M" = {0.941176470588235, 0.196078431372549, 0.274509803921569}});*/

// First we will create the female RGB color list
// Find a row that has the RGB colors we desire
rowList = dt << get rows where( :Sex == "F" );

// Since all values of R,G & B will be the same, only used the first
// selected row to create the list for the females
fColorList = {};
fColorList[1] = :R[rowList[1]];
fColorList[2] = :G[rowList[1]];
fColorList[3] = :B[rowList[1]];

// Repeat for the males
rowList = dt << get rows where( :Sex == "M" );

mColorList = {};
mColorList[1] = :R[rowList[1]];
mColorList[2] = :G[rowList[1]];
mColorList[3] = :B[rowList[1]];

// Substitute into a template of the Set Property structure
// the created RGB lists for females and males
Eval(
	Substitute(
			Expr(
				dt:sex << set property( "value colors", {"F" = __fList__, "M" = __mList__} )
			),
		Expr( __fList__ ), fColorList,
		Expr( __mList__ ), mColorList
	)
);

// Set the row state colors
dt << Color by Column( :Sex );
	
Jim
ChrisM_X
Level III

Re: Overlay Plot customize color (row colors)

Jim, thanks for the code, I think I understand. I really appreciate the syntax examples!    Now for my case, I will need to generalize it (I will need to build string that has all the bins, which won't be known until run time) ,

I assume __fList__ is just a list of values from the column of interest that you want a particular color.  So I assume this expression could get bigger,  and my list can be 1000s of items big, and I could have several different color bins in the expression.. 

I may have time to try this later today, I will let you know how it goes.

 

The hardest challenge i see is buiilding the expression below for my generalized case, but I will try  a hard coded example initially as proof of concept, I may come back to the forum if I get stuck on the expression. 

 

Thanks again!


Chris

 

 

 

 

Eval(
Substitute(
Expr(
dt:sex << set property( "value colors", {"F" = __fList__, "M" = __mList__} )
),
Expr( __fList__ ), fColorList,
Expr( __mList__ ), mColorList
)
);
 
 
Eval(
Substitute(
Expr(
dt:sex << set property( "value colors", {"F" = __fList__, "M" = __mList__} )
),
Expr( __fList__ ), fColorList,
Expr( __mList__ ), mColorList
)
);

// Set the row state colors
dt << Color by Column( :Sex );

 

txnelson
Super User

Re: Overlay Plot customize color (row colors)

Chris,

Be comforted that you are using JSL to do what you are attempting to do.  JSL has all of the functions and capabilities to build your generic script.

Jim
ChrisM_X
Level III

Re: Overlay Plot customize color (row colors)

Jim,

Can you define
__fList__
and
__mList__

The variables are used in you code example but aren't initialize / defined?

Thanks,

Chris
txnelson
Super User

Re: Overlay Plot customize color (row colors)

__fList__ and __mList__ are place holders in the Substitute() function.  See

     Help==Scripting Index==>Functions==>Substitute

for definition and example(s)

Jim
markschahl
Level V

Re: Overlay Plot customize color (row colors)