cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Register to attend Discovery Summit 2025 Online: Early Users Edition, Sept. 24-25.
  • New JMP features coming to desktops everywhere this September. Sign up to learn more at jmp.com/launch.
Choose Language Hide Translation Bar
lala
Level IX

Can the width of the X-axis of the grouped graphics be set separately?

For example, after I draw the graph like this, the widths of these two x-axes are set to be different.

 

Thanks!

dt=Open("$SAMPLE_DATA/Big Class.jmp");
d2=dt<<Summary(Group(2,3),sum(4),Freq("0"),Weight("0"),Link to original data table(0),statistics column name format("column"));
Column(d2,3)<<set name("S");
d1=dt<<Summary(Group(3),Freq("0"),Weight("0"),Link to original data table(0),statistics column name format("column"));
d2<<Update(With(d1),Match Columns(sex=sex));Close(d1,nosave);
p1=d2<< Graph Builder(
	Size(480, 495),
	Variables(X(:height), Y(:age), Group X(:sex), Color(:S)),
	Elements(Bar(X, Y, Legend(4)))
);

2025-05-01_11-07-14.png

15 REPLIES 15
hogi
Level XII

Re: Can the width of the X-axis of the grouped graphics be set separately?

After thinking again:
I don't recommend to create a graph like this - very dangerous.
I had to use Merged to zip the labels on the Y axis. Why?
JMP doesn't allow a user to disable "variables" when they are nested :

hogi_0-1746590682221.png


Without the Merged option, the plot would look like this - Female and Male ages nested:
hogi_2-1746587902895.png

On the other hand:
a) 
Merged leads to the wrong labels on the Y axis: 1,2,3... instead of 12,13,14 ...

b) It's systematic, but dangerous:
To see the issue, just generate the plot with one missing entry (e.g. NO female, 15 years):

hogi_4-1746587980573.png

As "Merge" replaces the labels with 1, 2, 3 ... this makes the bars for Female shift and misaligns them to the male bars (!) 

 

the topic is interesting, it illustrates how JMP handles data with missing entries.
By the way - on my system, the default setting is

hogi_0-1746587546485.png

So, If your graph is empty:

hogi_5-1746588298468.png

go to the red-triangle-menu and activate the option.

hogi
Level XII

Re: Can the width of the X-axis of the grouped graphics be set separately?

with the two options:


@hogi wrote:

in addition, either split color or the age axis:

better forget the second one - and use the first one:

hogi_6-1746590097900.png

 

Graph Builder(
	Transform Column( "N_M", Formula( If( :sex == "M", :N Rows ) ) ),
	Transform Column( "N_F", Formula( If( :sex == "F", :N Rows ) ) ),
	Variables( X( :height F ), X( :height M ), Y( :age ), Color( :N_F ), Color( :N_M ) ),
	Relative Sizes( "X", [360 237] ),
	Elements( Position( 1, 1 ), Bar( X, Y, Color( 1 ), Legend( 1 ) ) ),
	Elements( Position( 2, 1 ), Bar( X, Y, Color( 2 ), Legend( 2 ) ) ),
)
lala
Level IX

Re: Can the width of the X-axis of the grouped graphics be set separately?

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
d1=dt << Summary(
	Group( :age, :sex ),
	Sum( :height ),
	statistics column name format( "column" )
);
New Column( "height M",	Formula( If( :sex == "M", :height ) ));
New Column( "height F",	Formula( If( :sex == "F", :height ) ));

p2=d1<< Graph Builder(
	Transform Column( "age_F", Nominal, Formula( If( :sex == "F", :age ) ) ),
	Transform Column( "age_M", Nominal, Formula( If( :sex == "M", :age ) ) ),
	Size( 433, 323 ),
	Show Control Panel( 0 ),
	Summary Statistic( "Median" ),
	Graph Spacing( 4 ),
	Variables(
		X( :height F ),
		X( :height M ),
		Y( :age_M, Combine( "Merged" ) ),
		Y( :age_F, Position( 1 ), Combine( "Merged" ) ),
		Color( :N Rows )
	),
	Relative Sizes( "X", [360 237] ),
	Elements( Position( 1, 1 ), Bar( X, Y( 2 )) ),
	Elements( Position( 2, 1 ), Bar( X, Y( 1 ) ) ),
	SendToReport(
		Dispatch( {}, {:height F}, ScaleBox, {Max( 800 ), Inc( 100 ), Minor Ticks( 0 )} )
));

rpt = p2 << Report;
frames = rpt << XPath( "//FrameBox" );
For( i = 1, i <= N Items( frames ), i++,
	frames[i] << Set Graphlet(
		Picture(
			try(Close(d2,nosave));
			current data table(dt);
			d2=dt<<Subset(Output Table("B00"),Selected Rows(0),Rows(dt<<Get Selected Rows()),Selected columns only(0));
		),
		Reapply(1)
	)
);
hogi
Level XII

Re: Can the width of the X-axis of the grouped graphics be set separately?

you prefer the approach via age?
Then perhaps add a check that both subsets contain exactly the same age groups.

lala
Level IX

Re: Can the width of the X-axis of the grouped graphics be set separately?

This is given by AI. It can run, but I still don't know how to get the position of the column number of the graphic I clicked.

Could you please give me a code, expert?Thank you very much!

hogi
Level XII

Re: Can the width of the X-axis of the grouped graphics be set separately?

Caption(Char(dt<<Get Selected Rows()))

Recommended Articles