cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
JMP is taking Discovery online, April 16 and 18. Register today and join us for interactive sessions featuring popular presentation topics, networking, and discussions with the experts.
Choose Language Hide Translation Bar
shasheminassab
Level IV

Make histogram and box plot in graph builder

In the distribution platform you can add a box plot to the histogram (attached pic 1).
Pic 1Pic 1
How can I make a similar plot in Graph Builder? The reason that I am asking is I want to overlay it with a categorical parameter.

 

I made those plots separately and attached them manually in Photoshop (see attached pic2).

Pic 2Pic 2

If such thing can be done much easier and faster in Graph Builder, which is usually done with a dummy variable, please let me know (preferably without JSL coding!!)

 

 

3 REPLIES 3
txnelson
Super User

Re: Make histogram and box plot in graph builder

I don't know of an interactive way to do what you want in one instance of Graph Builder, but below is the "Start" of a simple script that may get you what you want.

couple.PNG

names default to here(1);
dt=open("$SAMPLE_DATA/big class.jmp");

his = dt << Graph Builder(
	Size( 534, 456 ),
	Show Control Panel( 0 ),
	Variables( X( :height ), Overlay( :sex ) ),
	Elements( Points( X, Legend( 2 ) ), Histogram( X, Legend( 3 ) ) ),
	SendToReport(
		Dispatch( {}, "graph title", TextEditBox, {Set Text( "" )} ),
		Dispatch(
			{},
			"Graph Builder",
			FrameBox,
			{DispatchSeg( Hist Seg( 1 ), Bin Span( 24, 0 ) ),
			DispatchSeg( Hist Seg( 2 ), Bin Span( 24, 0 ) )}
		)
	)
);

box = dt << Graph Builder(
	Size( 495, 296 ),
	Show Control Panel( 0 ),
	Variables( X( :height ), Overlay( :sex ), Color( :sex ) ),
	Elements( Box Plot( X, Legend( 5 ) ) ),
	SendToReport(
		Dispatch(
			{},
			"Graph Builder",
			FrameBox,
			{DispatchSeg(
				Box Plot Seg( "Box Plot (F)" ),
				{Line Color( "Medium Dark Blue" ), Fill Color( "Medium Dark Blue" ),
				Fill( 1 )}
			), DispatchSeg(
				Box Plot Seg( "Box Plot (M)" ),
				{Line Color( "Medium Dark Red" ), Fill Color( "Medium Light Red" ),
				Fill( 1 )}
			)}
		)
	)
);

new window("Height", lub = lineupbox(n col(1)));
lub<<append(report(box)[FrameBox(1)]);
lub<<append(report(his)[Frame box(1)]);
lub<<append(report(his)[AxisBox(1)]);
Jim
gzmorgan0
Super User (Alumni)

Re: Make histogram and box plot in graph builder

@shasheminassab ,

 

Jim provided you with what you wanted.  Below is an alternative view.

 

I am not a fan of vertical histograms, but you can create the view below fairly easily. The script follows.  This is more of an FYI and to determine if the developers might know of a clever method to rotate the frame or create a layout for what you want directly with GraphBuilder.

 

image.png 

names default to here(1);
dt=open("$SAMPLE_DATA/big class.jmp");

//Gender is a numeric column
dt << New Column( "Gender",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Formula( If( :sex == "F", 1, 2 ) ),
		Value Labels( {1 = "F", 2 = "M"} ),
		Use Value Labels( 1 )
	);
//Counts is a constant column used a placed holder
dt << New Column( "Counts",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		<< set Each Value(1)
);

gb = dt <<Graph Builder(
	Size( 526, 454 ),
	Show Control Panel( 0 ),
	Variables(
		X( :Counts ),
		X( :Gender ),
		Y( :height ),
		Overlay( :sex ),
		Color( :sex )
	),
	Elements( Position( 1, 1 ), Histogram( X, Y, Legend( 41 ) ) ),
	Elements( Position( 2, 1 ), Box Plot( X, Y, Legend( 40 ) ) ),
	SendToReport(
		Dispatch(
			{},
			"Gender",
			ScaleBox,
			{Format( "Fixed Dec", 12, 0 ), Min( 0 ), Max( 2.5 ), Inc( 1 ),
			Minor Ticks( 0 )}
		),
		Dispatch(
			{},
			"Y title",
			TextEditBox,
			{Rotate Text( "Right" ), Set Font Size( 12 ), Set Font Style( "Bold" )}
		),
		Dispatch(
			{},
			"Graph Builder",
			FrameBox( 2 ),
			{DispatchSeg(
				Box Plot Seg( "Box Plot (F, 1)" ),
				{Line Width( 2 ), Fill Color( {66, 112, 221} ), Fill( 1 ),
				Transparency( 0.6 )}
			), DispatchSeg(
				Box Plot Seg( "Box Plot (M, 2)" ),
				{Line Width( 2 ), Fill Color( {212, 73, 88} ), Fill( 1 ),
				Transparency( 0.6 )}
			)}
		),
		Dispatch(
			{},
			"400",
			LegendBox,
			{Legend Position( {41, [0, 1], 40, [-1, -1, -1, -1, -3, -3]} ),
			Position( {0, 1, -1, -1, -1, -1, -3, -3} )}
		)
	)
);

 

 

shasheminassab
Level IV

Re: Make histogram and box plot in graph builder

Thanks very much!