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

Changing color of bar graph

Hi all,

I have a quick question regarding changing legend color. Below is the script that I copied directly from my data table. I understand the number within "Fill Color" specifies what color I want for the respective group shown in Item ID. However, can anyone tell me what number "28" means and what number "8/7/6" here mean. I tried searching through their syntax document but couldn't find anything on this.

 

Thank you!

 

{Legend Model(
				28,
				Properties( 8, {Fill Color( 35 )}, Item ID( "B1 D14", 1 ) ),
				Properties( 7, {Fill Color( 36 )}, Item ID( "B4 D14", 1 ) ),
				Properties( 6, {Fill Color( 37 )}, Item ID( "C4 D14", 1 ) )		
			)}
1 ACCEPTED SOLUTION

Accepted Solutions

Re: Changing color of bar graph

I fully agre4e with mark, if by any chance possible avoid it to modify "send to report" parts as it will be less robust and hard to debug.

 

That is what I would think about the behaviour you see in your code snippet:

Properties( 3, {Fill Color( 3 )}, Item ID( "A", 1 ) ),
Properties( 2, {Fill Color( 5 )}, Item ID( "B", 1 ) ),
Properties( 1, {Fill Color( 4 )}, Item ID( "C", 1 ) ),
Properties( 0, {Fill Color( 8 )}, Item ID( "D", 1 ) )


// compared to 
Properties( 1, {Fill Color( 3 )}, Item ID( "A", 1 ) ),
Properties( 2, {Fill Color( 5 )}, Item ID( "B", 1 ) ),
Properties( 3, {Fill Color( 4 )}, Item ID( "C", 1 ) ),
Properties( 4, {Fill Color( 8 )}, Item ID( "D", 1 ) )

In the properties call you have always the "Item ID" included. This is a clear identifier which is stronger than the order at the beginning. I'm pretty sure if you remove the identifier, you will see a change in the color

Properties( 3, {Fill Color( 3 )} ),
Properties( 2, {Fill Color( 5 )}),
Properties( 1, {Fill Color( 4 )}),
Properties( 0, {Fill Color( 8 )})

// compared to 

Properties( 0, {Fill Color( 3 )}, Item ID( "A", 1 ) ),
Properties( 1, {Fill Color( 5 )}, Item ID( "B", 1 ) ),
Properties( 2, {Fill Color( 4 )}, Item ID( "C", 1 ) ),
Properties( 3, {Fill Color( 8 )}, Item ID( "D", 1 ) )

Once more: Avoid playing with these if possible. Just one change in a variable reducing the levels might have an impact.

/****NeverStopLearning****/

View solution in original post

9 REPLIES 9
ih
Super User (Alumni) ih
Super User (Alumni)

Re: Changing color of bar graph

Check out this link, 35 is the 4th item in the 'medium light' series, so it is a medium-light red.

 

https://www.jmp.com/support/help/en/15.1/index.shtml#page/jmp/specify-colors.shtml

 

The 8,7,6 numbers should refer to the position within the legend.

hxnduke
Level III

Re: Changing color of bar graph

@ih 

The 8,7,6 numbers should refer to the position within the legend.

Did you mean the order within the legend? Because if I shuffle the "0,1,2,3" numbers in the script below in whichever way, I would still get the same order within my legend.

 

New Table( "Untitled 119",
	Add Rows( 4 ),
	New Script(
		"Value vs. Group",
		Graph Builder(
			Size( 534, 463 ),
			Show Control Panel( 0 ),
			Variables( X( :Group ), Y( :Value ), Overlay( :Group ) ),
			Elements( Bar( X, Y, Legend( 6 ) ) ),
			SendToReport(
				Dispatch(
					{},
					"400",
					ScaleBox,
					{Legend Model(
						6,
						Properties( 0, {Fill Color( 3 )}, Item ID( "A", 1 ) ),
						Properties( 1, {Fill Color( 5 )}, Item ID( "B", 1 ) ),
						Properties( 2, {Fill Color( 4 )}, Item ID( "C", 1 ) ),
						Properties( 3, {Fill Color( 8 )}, Item ID( "D", 1 ) )
					)}
				)
			)
		)
	),
	New Column( "Group", Character, "Nominal", Set Selected ),
	New Column( "Value", Numeric, "Continuous", Format( "Best", 12 ), Set Selected )
)
hxnduke
Level III

Re: Changing color of bar graph

Please see picture below as example. Picture on the left was achieved by running the script I attached on the previous reply. Picture on the right was done by reversing the order to:

Properties( 3, {Fill Color( 3 )}, Item ID( "A", 1 ) ),
						Properties( 2, {Fill Color( 5 )}, Item ID( "B", 1 ) ),
						Properties( 1, {Fill Color( 4 )}, Item ID( "C", 1 ) ),
						Properties( 0, {Fill Color( 8 )}, Item ID( "D", 1 ) )

Legend Order.png

ih
Super User (Alumni) ih
Super User (Alumni)

Re: Changing color of bar graph

Unfortunately I don't fully understand the interaction between Base and Properties in this context, and so far haven't found a good reference explaining the difference. Hopefully someone else can chime in here.

hxnduke
Level III

Re: Changing color of bar graph

Yeah, I couldn't quite figure out what it does. I could literally change those numbers to anything and would still get the same graph. However, if I delete the numbers, the colors will not follow what are defined in the "Fill Color".

Thank you for your input nevertheless!

Re: Changing color of bar graph

As has been stated many times in many discussions such as this, the Send To Report() mechanism is not intended for you. Send To Report() was devised as a way for JMP to save customizations to the report layer of a platform. Of course, you can use it, but then you usually run into such issues and a lot of confusion. You can avoid this mess entirely by sending the appropriate message to the platform instead. For example, I can change the color theme for the bars without using Send to Report() like this illustration:

 

Names Default to Here( 1 );

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

gb = dt << Graph Builder(
	Size( 534, 448 ),
	Show Control Panel( 0 ),
	Variables( X( :age ), Y( :weight ), Overlay( :age ) ),
	Elements( Bar( X, Y, Legend( 8 ) ) )
);

Wait( 2 );

gb << Categorical Color Theme( "Pastel" );
hxnduke
Level III

Re: Changing color of bar graph

@Mark_Bailey The script I attached was made by first creating the graph via Graph Builder then saving it as a script. I copied the entire script to here so I'm not even sure what "Send To Report" does. I wanted to customize the color of individual group so simply setting a color theme wouldn't do that. 

It really doesn't matter much since I got the script to do what I wanted it to. I was simply curious as I'm still trying to learn scripting piece by piece via reading JMP-generated script.

Re: Changing color of bar graph

I fully agre4e with mark, if by any chance possible avoid it to modify "send to report" parts as it will be less robust and hard to debug.

 

That is what I would think about the behaviour you see in your code snippet:

Properties( 3, {Fill Color( 3 )}, Item ID( "A", 1 ) ),
Properties( 2, {Fill Color( 5 )}, Item ID( "B", 1 ) ),
Properties( 1, {Fill Color( 4 )}, Item ID( "C", 1 ) ),
Properties( 0, {Fill Color( 8 )}, Item ID( "D", 1 ) )


// compared to 
Properties( 1, {Fill Color( 3 )}, Item ID( "A", 1 ) ),
Properties( 2, {Fill Color( 5 )}, Item ID( "B", 1 ) ),
Properties( 3, {Fill Color( 4 )}, Item ID( "C", 1 ) ),
Properties( 4, {Fill Color( 8 )}, Item ID( "D", 1 ) )

In the properties call you have always the "Item ID" included. This is a clear identifier which is stronger than the order at the beginning. I'm pretty sure if you remove the identifier, you will see a change in the color

Properties( 3, {Fill Color( 3 )} ),
Properties( 2, {Fill Color( 5 )}),
Properties( 1, {Fill Color( 4 )}),
Properties( 0, {Fill Color( 8 )})

// compared to 

Properties( 0, {Fill Color( 3 )}, Item ID( "A", 1 ) ),
Properties( 1, {Fill Color( 5 )}, Item ID( "B", 1 ) ),
Properties( 2, {Fill Color( 4 )}, Item ID( "C", 1 ) ),
Properties( 3, {Fill Color( 8 )}, Item ID( "D", 1 ) )

Once more: Avoid playing with these if possible. Just one change in a variable reducing the levels might have an impact.

/****NeverStopLearning****/
hxnduke
Level III

Re: Changing color of bar graph

@martindemel : Thank you, you've answered both of my questions. Looks like when the Item ID parts are removed, the colors are now specified by the order numbers of the groups. Also, removing the SendToReport brackets doesn't seem to impact the rest of the code so I'll remember to remove them in the future.

As I mentioned, I really did not include that part of the code on purpose. I'm not at all experienced in scripting so have had to rely on copying scripts generated by the different JMP report options. To get the original code that I included, I needed to first generate the graph and make changes in GraphBuilder then save it as a script to Data Table. I really had no idea what the SendToReport or Dispatch functions do. I tried searching through JMP scripting index but sometimes it's not as easy to find what I'm looking for, especially for common functions such as "Properties" that are used by many types of reports. Discussions like this are definitely helpful for new users like myself!