cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
lala
Level VIII

How to use different labels for the same bar chart?

Positive and negative values like this use different cotton swabs

Thanks!

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
r = N Row( dt );ca = "weight";ar = dt << GetAsMatrix( ca );
For( i = 1, i <= r, i++,	ar[i, 1] = -ar[i, 1]);dt[0, ca] = ar;
c1 = Quantile( 0.8, dt[0, "height"] );c2 = Quantile( 0.2, dt[0, "weight"] );
ca = "A";New Column( ca );Column( ca ) << Formula( If( height > c1, height ) );dt << run formulas;Column( ca ) << deleteFormula;
ca = "B";New Column( ca );Column( ca ) << Formula( If( weight < c2, weight ) );dt << run formulas;Column( ca ) << deleteFormula;
Column( "A" ) << set labelled( 1 );
Column( "B" ) << set labelled( 1 );
Column( "name" ) << set labelled( 0 );
p1 = dt << Graph Builder(
	Size( 885, 607 ),
	Variables( X( Transform Column( "Row", Formula( Row() ) ) ), Y( :height ), Y( :weight, Position( 1 ) ) ),
	Elements( Bar( X, Y( 1 ), Y( 2 ), Legend( 5 ), Bar Style( "Stacked" ), Label( "Label by Row" ) ) ),
	SendToReport(
		Dispatch(
			{},
			"400",
			ScaleBox,
			{Legend Model(
				5,
				Properties( 0, {Transparency( 0.5 )}, Item ID( "height", 1 ) ),
				Properties( 1, {Transparency( 0.5 )}, Item ID( "weight", 1 ) )
			)}
		)
	)
);

2024-10-19_21-46-00.png

1 ACCEPTED SOLUTION

Accepted Solutions
jthi
Super User

Re: How to use different labels for the same bar chart?

You could for example add extra bar charts for A and B columns and set labels for those (disable columns from variables accordingly and set transparency of second bar charts to 0)

jthi_1-1729347436917.png

I think you can also use Points instead of bars in JMP18 if you want to

-Jarmo

View solution in original post

5 REPLIES 5
jthi
Super User

Re: How to use different labels for the same bar chart?

You could for example add extra bar charts for A and B columns and set labels for those (disable columns from variables accordingly and set transparency of second bar charts to 0)

jthi_1-1729347436917.png

I think you can also use Points instead of bars in JMP18 if you want to

-Jarmo
lala
Level VIII

Re: How to use different labels for the same bar chart?

I changed the label form, and I do not know how to set the label in this case.
I bother the expert to instruct again.

Thanks Experts!

dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
r = N Row( dt );ca = "weight";ar = dt << GetAsMatrix( ca );
For( i = 1, i <= r, i++,	ar[i, 1] = -ar[i, 1]);dt[0, ca] = ar;
c1 = Quantile( 0.8, dt[0, "height"] );c2 = Quantile( 0.2, dt[0, "weight"] );
ca = "A";New Column( ca, Character,"Nominal");Column( ca ) << Formula( If( height > c1, "A"||char(row()) ) );dt << run formulas;Column( ca ) << deleteFormula;
ca = "B";New Column( ca,Character,"Nominal" );Column( ca ) << Formula( If( weight < c2, "B"||char(row()) ) );dt << run formulas;Column( ca ) << deleteFormula;
Column( "A" ) << set labelled( 1 );Column( "B" ) << set labelled( 1 );Column( "name" ) << set labelled( 0 );
p1 = dt << Graph Builder(
	Size( 885, 607 ),
	Variables( X( Transform Column( "Row", Formula( Row() ) ) ), Y( :height ), Y( :weight, Position( 1 ) ) ),
	Elements( Bar( X, Y( 1 ), Y( 2 ), Legend( 5 ), Bar Style( "Stacked" ), Label( "Label by Row" ) ) ),
	SendToReport(
		Dispatch(
			{},
			"400",
			ScaleBox,
			{Legend Model(
				5,
				Properties( 0, {Transparency( 0.5 )}, Item ID( "height", 1 ) ),
				Properties( 1, {Transparency( 0.5 )}, Item ID( "weight", 1 ) )
			)}
		)
	)
);

2024-10-25_10-15-57.png

jthi
Super User

Re: How to use different labels for the same bar chart?

Did you try with the same method I did provide earlier? You just have to add new columns with the "heights" where you want to show the labels and and use those to create the bar charts with label enabled

jthi_1-1729828768541.png

 

-Jarmo
lala
Level VIII

Re: How to use different labels for the same bar chart?

Yes, the original "A" column is positive and the "B" column is negative.So they can be shown above and below.

 

Now "A" and "B" are text.You cannot have the "A" column label displayed above and the "B" column label displayed below.This is the key.

 

Thanks!

jthi
Super User

Re: How to use different labels for the same bar chart?

Did you try the method in my earlier post and try creating extra columns?

You just have to add new columns with the "heights" where you want to show the labels and and use those to create the bar charts with label enabled

-Jarmo