Stumped by Graph BuilderA customer would like to build a graph where there is a stacked bar chart and points above the bar. I've mocked an example using Big Class (see script below). I can get close to what she needs by nesting age within sex and also including age in the color role but can't get the stacked bars different colors or patterns. The second graph has age in the overlay role but the points are not above the bars - the customer really likes the color shading by age on the bar charts and the different colors for the stacked Y variables. So necessary elements are:
- points above bars
- ability to see stacked Y variables in the bar
- ability to denote age
The customers graph is a bit more involved than my example in that it is a trellis Grouped by Y and X variables.
Names default to here(1);
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
// New formula column: height+weight
dt << New Column( "height+weight",
Numeric,
"Continuous",
Format( "Best", 12 ),
Formula( :height + :weight )
);
dt << Graph Builder(
Size( 822, 623 ),
Variables(
X( :sex ),
X( :age, Position( 1 ) ),
Y( :height ),
Y( :weight, Position( 1 ) ),
Y( :"height+weight"n, Position( 1 ) ),
Color( :age )
),
Elements(
Points( X( 1 ), X( 2 ), Y( 3 ), Legend( 5 ) ),
Bar( X( 1 ), X( 2 ), Y( 1 ), Y( 2 ), Legend( 6 ), Bar Style( "Stacked" ) )
)
);
dt << Graph Builder(
Size( 570, 619 ),
Variables(
X( :sex ),
Y( :height ),
Y( :weight, Position( 1 ) ),
Y( :"height+weight"n, Position( 1 ) ),
Overlay( :age )
),
Elements(
Bar( X, Y( 1 ), Y( 2 ), Legend( 4 ), Bar Style( "Stacked" ) ),
Points( X, Y( 3 ), Legend( 5 ) )
)
);
Re: Stumped by Graph BuilderThe points are a different Y variable than what is stacked in the graph so I don't think it will work. I did play around with that idea and it doesn't seem to do the trick.
Re: Stumped by Graph BuilderCan you put the different Y variable on the Y2 axis to get it to work? While also adding it to the overlay or color role?
Re: Stumped by Graph BuilderThe points still won't be above the bars - because overlaying by a categorical variable will separate the bars but not points.
Re: Stumped by Graph BuilderI don't think the problem is necessarily the color; below is a graph where colors have been used for the categories, and a continuous gradient for :weight (color or mark by column). Not sure this is what is wanted though.

Re: Stumped by Graph BuilderBrady and I got on the phone and discussed this one. We came up with a couple options that would need to be scripted. Will let you know what we come up with.
Re: Stumped by Graph BuilderWhat about using Y2 axis?
Graph Builder(
Size( 534, 450 ),
Show Control Panel( 0 ),
Variables(
X( :sex ),
Y( :"height+weight"n, Side( "Right" ) ),
Y( :height, Position( 1 ) ),
Overlay( :age )
),
Elements(
Bar( X, Y( 2 ), Legend( 9 ), Bar Style( "Stacked" ) ),
Points( X, Y( 1 ), Legend( 8 ) )
),
SendToReport(
Dispatch(
{},
"400",
LegendBox,
{Legend Position( {9, [6, 7, 8, 9, 10, 11], 8, [0, 1, 2, 3, 4, 5]} )}
)
)
)
