cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
lala
Level VIII

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?

you can split the height column in two parts:

hogi_0-1746093876569.png


... and generate 2 adjacent plots:

Names Default to Here(1);
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
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 ) ));
Graph Builder(
	Show Control Panel( 0 ),
	Variables( X( :height F ), X( :height M ), Y( :age ), Color( :N Rows ) ),
	Relative Sizes( "X", [360 237] ),
	Elements( Position( 1, 1 ), Bar( X, Y ) ),
	Elements( Position( 2, 1 ), Bar( X, Y ) ),
	SendToReport(
		Dispatch( {}, {:height F}, ScaleBox, {Max( 800 )} )
	)
);


unfortunately, the color in the plot is unexpected: same color for both sexes ?!
seems that color is taken from rows without values in the column which is used for the response axis.
-> interesting / important finding!

hogi_1-1746094027016.png

 

lala
Level VIII

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

Thanks Experts!

hogi
Level XII

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

So, in addition, either split color or the age axis:

hogi_2-1746097026655.png

 

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 )} )
);

With the ability to scale the x axes independently, you also get the "duty" to meaningful ranges (= same range) for the 2 color scales.

hogi
Level XII

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

A much better way: via page
- independent x axes

- synchronous y axis scale - via  Link Page Axes( "Y Only" ),

- synchronous color scale

i hope you don't mind the small gap between the plots

hogi_0-1746097455374.png

 

Graph Builder(
	Size( 527, 455 ),
	Show Control Panel( 0 ),
	Link Page Axes( "Y Only" ),
	Replicate Linked Page Axes( 0 ),
	Summary Statistic( "Median" ),
	Graph Spacing( 4 ),
	Variables( X( :height ), Y( :age ), Page( :sex, Levels per Row( 2 ) ), Color( :N Rows ) ),
	Elements( Bar( X, Y, Legend( 7 ) ) )
);

 

lala
Level VIII

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

This width is the same.

hogi
Level XII

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

Oh, yes, you are right. The Range can be adjusted individually, but the width is again forced to be the same.

Then I fear you need the lengthy code.
let's see what other users suggest ...

lala
Level VIII

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

Thanks Experts!
I'm using this script.
How can we obtain this subset by following the step of taking a screenshot, by hovering over the graphic or clicking on it?
2025-05-07_10-41-13.png

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
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 ) ));

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 )} )
));
lala
Level VIII

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

I tried such code and could only succeed by clicking on the image "F" on the left.

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 )} )
));
frame=(p2<<report)[FrameBox(1)];frame<<Set Graphlet(Picture( current data table(dt);d2=dt<<Subset(Output Table("B00"),Selected Rows(0),Rows(dt<<Get Selected Rows()),Selected columns only(0));  ),Reapply(1));

2025-05-07_10-58-54.png

Thanks Experts!

hogi
Level XII

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

you applied the hover label script just to the first Framebox:

frame=(p2<<report)[FrameBox(1)];frame<<Set Graphlet(


when you want the same function in all (2) Frameboxes, use xpath to get a list of the Frameboxes and send the message to the list:

fbs = gb << xpath("//FrameBox");
fbs << 


maybe use a Modifier Key to make the creation of the subset less spontaneous : )
actions via mouseover ? - use a modifier Key 👉🔳 

Recommended Articles