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

Constant legend color

Hi,

 

I build a graph (bar chart) and changed the legend color (and therfore the bar color) by right-clicking and copy the script

SendToReport(
		Dispatch(
			{},
			"400",
			ScaleBox,
			{Legend Model(
				8,
				Properties( 0, {Fill Color( 10 )}, Item ID( "category", 1 ) ),

This is part of a bigger graph.

 

When I run the script and include a local data filter, the color for the categories are changing. This is detrimental because I want to have the same color for a category independently of a filter.

 

Kind regards,

 

 

3 ACCEPTED SOLUTIONS

Accepted Solutions

Re: Constant legend color

You can lock the legend colours by using the column property - Value Colors. This will ensure whatever platform you are and what ever local data filter is applied the colours for each group will not change.

View solution in original post

txnelson
Super User

Re: Constant legend color

You should be able to unclick the "Include" checkbox in the filter, to allow the chart's colors to stay the same. The "Include" checkbox tells the filter to Include/Exclude values in calculating the chart, so when it is not checked, it uses all of the values, thus the colors are calculated the save from filtered value to filtered value.
Jim

View solution in original post

txnelson
Super User

Re: Constant legend color

You can not change the Fill Color by changing the Cell Color nor by changing the Row State of Color to a specified color.  A bar chart is a calculated column, that does not have a direct relationship from the display and each individual row.  Therefore, you need to deal with the whole bar by changing the Fill Color within the Graph Builder Code.  Below is an example on how to do this:

Graph Builder(
	Size( 534, 418 ),
	Show Control Panel( 0 ),
	Variables( Y( :height ), Y( :weight, Position( 1 ) ) ),
	Elements( Bar( Y( 1 ), Y( 2 ), Legend( 3 ) ) ),
	SendToReport(
		Dispatch(
			{},
			"400",
			ScaleBox,
			{Legend Model(
				3,
				Properties( 0, {Fill Color( 5 )}, Item ID( "Mean(height)", 1 ) ),
				Properties( 1, {Fill Color( 5 )}, Item ID( "Mean(weight)", 1 ) )
			)}
		)
	)
);

 

Jim

View solution in original post

5 REPLIES 5

Re: Constant legend color

You can lock the legend colours by using the column property - Value Colors. This will ensure whatever platform you are and what ever local data filter is applied the colours for each group will not change.
TWE
TWE
Level III

Re: Constant legend color

Thanks,

I'm afraid that the answer of the next question is obviously, but how can I change all values in a column to a single color, via script?

TWE
TWE
Level III

Re: Constant legend color

I colored all cells in two columns (heigt and weight) to get the same color in a bar chart but it didnt work

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

:height << Color Cell By Value( 1 ); // turn on the cell coloring
For( i = 1, i <= N Row( dt ), i++,

	If( Column( dt, "height" )[i] >= 0,

		Column( dt, "height" ) << Color Cells( 5, {i} ),

		Column( dt, "height" ) << Color Cells( 0, {i} )

	));
:weight << Color Cell By Value( 1 ); // turn on the cell coloring
For( i = 1, i <= N Row( dt ), i++,
	If( Column( dt, "weight" )[i] >= 0,

		Column( dt, "weight" ) << Color Cells( 5, {i} ),

		Column( dt, "weight" ) << Color Cells( 0, {i} )

	));

Graph Builder(
	Size( 534, 418 ),
	Show Control Panel( 0 ),
	Variables( Y( :height ), Y( :weight, Position( 1 ) ) ),
	Elements( Bar( Y( 1 ), Y( 2 ), Legend( 3 ) ) )
);
txnelson
Super User

Re: Constant legend color

You can not change the Fill Color by changing the Cell Color nor by changing the Row State of Color to a specified color.  A bar chart is a calculated column, that does not have a direct relationship from the display and each individual row.  Therefore, you need to deal with the whole bar by changing the Fill Color within the Graph Builder Code.  Below is an example on how to do this:

Graph Builder(
	Size( 534, 418 ),
	Show Control Panel( 0 ),
	Variables( Y( :height ), Y( :weight, Position( 1 ) ) ),
	Elements( Bar( Y( 1 ), Y( 2 ), Legend( 3 ) ) ),
	SendToReport(
		Dispatch(
			{},
			"400",
			ScaleBox,
			{Legend Model(
				3,
				Properties( 0, {Fill Color( 5 )}, Item ID( "Mean(height)", 1 ) ),
				Properties( 1, {Fill Color( 5 )}, Item ID( "Mean(weight)", 1 ) )
			)}
		)
	)
);

 

Jim
txnelson
Super User

Re: Constant legend color

You should be able to unclick the "Include" checkbox in the filter, to allow the chart's colors to stay the same. The "Include" checkbox tells the filter to Include/Exclude values in calculating the chart, so when it is not checked, it uses all of the values, thus the colors are calculated the save from filtered value to filtered value.
Jim