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
CG
CG
Level III

Fix color based on value (graph builder overlay)

JMP users,

I need some suggestion how to fix color assignment to a value in a column and be fixed while plotting it in graph builder.

I have one column with 1 (pass) and 0 (fail) values which populates based on some formula's from other columns.

I am using graph builder and using this *column* to distinguish pass/fail. I am looking to fix 1 as "Green" and 0 as "Red".

 

it works fine in graph builder when both values are present in column i.e. 0 is red and 1 is green. Sample code below -

{Legend Model(47,
Properties( 0, {Line Color( "Red" )} ),
Properties( 1, {Line Color( "Green" )} )
)}

 

The issue I encounter when there is only one of the value present in the column i.e. either 0 or 1 (in other words all values are pass or all values are fail). In this case, graph builder doesn't pick assigned color

 

I have tried to set property and fix color in the column as well but doesn't seem helping when either one of is missing.

Is there a better way to have fix color to both values and graph builder would show accordingly?

 

I am using JMP12.1.0

 

Thanks for help in advance.

12 REPLIES 12

Re: Fix color based on value (graph builder overlay)

Why don't you use the Color row state to drive the color of the markers in Graph Builder?

 

Open the data table and select Rows > Color or Mark by Column. The default is to set the color and uses the same default color scheme as the platforms for markers and lines. Select the pass / fail data column and you should see the two levels. You can click on the assigned color for a level and select another color.

 

The Color row state is used by JMP everywhere so you only have to define it once and use it ever after.

CG
CG
Level III

Re: Fix color based on value (graph builder overlay)

Mark,

I think i am missing something.

I tried as below as example -

 

 

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
Column( dt, "Age" ) << data type( Numeric ) << Modeling Type( Continuous );

dt << Color or Mark by Column( :Age );

Graph Builder(
	Variables( X( :weight ), Y( :height ), Overlay( :age ) ),
	Elements( Points( X, Y, Legend( 3 ) ) )
);

 

 

Above works with distinct values in column Age.

but moment I change to a unique value in column Age across all rows, above code defaults to certain color and legend is also missing in graph builder.

Not sure if there is a way i can assign a specific color to a value (in my case i only have 2 values that will be populated i.e. either 0 or 1 or both).

Re: Fix color based on value (graph builder overlay)

Have you tried to add the Value Colors column property to the pass / fail data column? This property should work if there is one of the two values or both of the values in the data column. Use this column in the Color role in Graph Builder.

CG
CG
Level III

Re: Fix color based on value (graph builder overlay)

It does the same thing.

At this point i am not sure if there is any better way instead of ensuring whether column has distinct or unique value and then write separate graph builder script for each case.

it's not efficient though.

Re: Fix color based on value (graph builder overlay)

I might not understand what you want. Here is what I did.

 

I created a data table as an example with X and Y variables for the scatter plot using Graph Builder. I added a pass or fail column with 0 and 1 values and the Value Colors column property. The 0 value is green and the 1 value is red in plots. It looks like this

 

Data Table with Both Levels.JPG

 

I made the Graph Builder plot with the pass or fail variable in the Color role. It looks like this:

 

Graph Builder with Both Values.JPG

 

I went back to the data table and changed all the pass or fail values to 0. It now looks like this:

 

Data Table with One Level.JPG

 

Graph Builder automatically updated and now shows the lone value:

 

Graph Builder with One Level.JPG

CG
CG
Level III

Re: Fix color based on value (graph builder overlay)

Mark,

thanks for the example.

If you now change all values to 1 and then do plot using graph builder, the color will still be green in your case for all 1 values.

 

What i wanted is 1 which pass should be fixed as "Green" and 0 (Fail) should be "Red".

Re: Fix color based on value (graph builder overlay)

What if you use the Color role instead of the Overlay role?

txnelson
Super User

Re: Fix color based on value (graph builder overlay)

I believe the easiest way to handle this, is to set the Value Color column property for the Overlay variable. Once set, it will use the colors even when one of the overlay values have nor observations.

Jim
CG
CG
Level III

Re: Fix color based on value (graph builder overlay)

Jim,

I tried value Color column property and still same issue (when one of the value is present, it defaults to color assigned.

Not sure if higher version of JMP12 supports this feature.

 

thanks,

Chintan