Graph Builder, stack bar with N as summary and % of factor as labelHi y'all.
Is there a way to have the labels be different from the summary statistic in a stacked bar chart?
I basically want the bar chart to look like this script but instead of the labels being the raw count, I want it to be percentages of M/F per age.
Without drawing myself via scripting, (I can do it if that's the only way).
Names default to here( 1 );
dt = open("$SAMPLE_DATA\Big Class.jmp");
dt << Graph Builder(
Variables( X( :age ), Overlay( :sex ) ),
Elements(
Bar(
X,
Legend( 4 ),
Bar Style( "Stacked" ),
Summary Statistic( "N" ),
Label( "Label by Value" )
)
)
);
Automation and ScriptingBasic Data Analysis and ModelingRe: Graph Builder, stack bar with N as summary and % of factor as labelMoving Age from the X-Axis role to the Group X role, with Label set to Label by Percent, will label the bars with the percentage within each age group without scripting. However this seems to lose the Y-Axis title and labeling.
I was able to get the Y-Axis back by adding a dummy variable (in this case, Weight) to the Y-Axis role. Maybe someone else can chime in with a more proper way to retain the Y-Axis "Counts" labeling when there is nothing in the X-Axis role.

Re: Graph Builder, stack bar with N as summary and % of factor as labelAs an alternative, you can use Label by row - and calculate the percentages manually.
OK to generate the graph - but doesn't feel like JMP, more like Photoshop.
The big disadvantage:
In Graph Builder there is not command to specify which column should be used as label.
If you activate the Label to make this Graph show the right information, you will destroy all the other graphs : (
Names default to here( 1 );
dt = open("$SAMPLE_DATA\Big Class.jmp");
dt:name << Label( 0 );
percent = dt << New Column( "percent",
Format( "Percent", 12, 0 ),
Formula( Col Number( :height, :age, :sex ) / Col Number( :height, :age ) ),
);
percent << label(1);
Graph Builder(
Variables( X( :age ), Overlay( :sex ) ),
Elements(
Bar(
X,
Bar Style( "Stacked" ),
Summary Statistic( "N" ),
Label( "Label by Row" )
)
)
);Re: Graph Builder, stack bar with N as summary and % of factor as labelIn 2020 @shampton82 submitted this wish to optimize the Graph builder bar chart data label control .
It is still collecting Kudos - and additional ideas.
I just added a comment to add a functionality to specify the columns used as row label (via GraphBuilder GUI and via JSL)
At the moment, it's very dangerous to use such row labels - enabling them for one graph will destroy all the other graphs.
The proposed label control will fix this issue.
nice side effect: It will be possible to use Transform columns as row Labels - no need to "pollute" the data table.