cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Choose Language Hide Translation Bar
0 Kudos

Add bar style to histogram within graph builder.

Add options to change how bars are displayed on histograms within graph builder, including stacked, side by side, nested, etc.

 

Users would find it more intuitive to build this chart by starting with a histogram rather than needing to use a bar chart with a count statistic:

Binned.png

 

but the closest you get are overlaid bars:

Histogram.png

 

Code:

View more...
Names default to here(1);

dt = Open( "$Sample_Data/iris.jmp" );

dt << New Column("Sepal length Binned", Numeric, "Continuous", Format("Fixed Dec", 12, 1), Formula(Floor(:Sepal length / 0.2) * 0.2));
dt << New Column("Is Target", Character, "Nominal", Set Property("Value Colors", {"Is Target" = 59, "The Rest" = 32}), Formula(If(:Species == "setosa", "Is Target", "The Rest")));

//Desired Chart
dt << Graph Builder(
	Size( 500, 300 ),
	Show Control Panel( 0 ),
	Variables(
		X( :Sepal length ),
		Y( :Sepal length ),
		Overlay( :Is Target ),
		Color( :Is Target )
	),
	Elements(
		Bar( X, Y, Legend( 11 ), Bar Style( "Stacked" ), Summary Statistic( "N" ) )
	),
	SendToReport(
		Dispatch(
			{},
			"Sepal length",
			ScaleBox,
			{Min( 4.1659880239521 ), Max( 8.0340119760479 ), Inc( 0.2 ),
			Minor Ticks( 0 )}
		)
	)
);

//Histogram option - no way to stack bars, leads to confusion when 'Is Target' 
//and 'The rest' have similar counts
dt << Graph Builder(
	Size( 500, 300 ),
	Show Control Panel( 0 ),
	Variables(
		X( :Sepal length ),
		Y( :Sepal length ),
		Overlay( :Is Target ),
		Color( :Is Target )
	),
	Elements( Histogram( X, Y, Legend( 12 ) ) ),
	SendToReport(
		Dispatch(
			{},
			"Sepal length",
			ScaleBox,
			{Min( 4.1659880239521 ), Max( 8.0340119760479 ), Inc( 0.2 ),
			Minor Ticks( 0 )}
		)
	)
);
1 Comment
Ryan_Gilmore
Community Manager
Status changed to: Archived
We are archiving this request. If this is still important please comment with additional details and we will reopen. Thank you!