BookmarkSubscribeRSS Feed
Choose Language Hide Translation Bar
robin_preston_d

Community Trekker

Joined:

Aug 3, 2016

Bar Chart fill color

Good day to all.

 

I cannot for the life of me work out how to make a 100 % stacked bar chart. Attached is the "normal" stacked bar chart output from GraphBuilder in JMPP but how does one convert to the raltive proportion, adding up to 100 %?

 Graph Builder.jpg

Any ideas will be greatly appreciated

 

 

1 REPLY 1
XanGregg

Staff

Joined:

Jun 23, 2011

Re: Bar Chart fill color

The Mosaic element does that automatically. To get the effect in a regular stacked bar chart, you have to compute the proportions and stack those. Here is a script where I did so with inline transformations:

 

 

Open("$SAMPLE_DATA/Big Class.jmp");
Graph Builder(
	Variables(
		X( :age ),
		Y(
			Transform Column(
				"proportion",
				Formula( Col Sum( :height, :age, :sex ) / Col Sum( :height, :age ) )
			)
		),
		Overlay( :sex )
	),
	Elements( Bar( X, Y, Bar Style( "Stacked" ) ) ),
);

In "Col Sum( :height, :age, :sex )", the variables after the first are BY variables. Use Col Number() if you just want the counts instead of the sums.