cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
The Discovery Summit 2025 Call for Content is open! Submit an abstract today to present at our premier analytics conference.
Choose Language Hide Translation Bar
Jemster
Level III

Adding mean line by script

I can build a graph and add a horizontal mean line. When I try to extract the script it doesn't reproduce any line.

I have attached the script below

Graph Builder(
	Size( 1964, 1192 ),
	Variables( X( Column ), Y( Column ), Group X( Column_a ) ),
	Elements( Bar( X, Y, Legend( 11 ) ), Line( Y, Legend( 12 ) ) ),
	Local Data Filter(
		Add Filter( columns( Column_a ), Where( Column >= 0 & Column_a <= 3.2 ) )
	),
	SendToReport(
		Dispatch( {"Line"}, "", OutlineBox, {Close( 0 )} ),
		Dispatch(
			{},
			"400",
			ScaleBox,
			{Legend Model(
				11,
				Properties( 0, {Fill Color( 0 )}, Item ID( "Column", 1 ) )
			)}
		)
	)
);
1 ACCEPTED SOLUTION

Accepted Solutions
Jemster
Level III

Re: Adding mean line by script

I overlayed the two graphs onto one plot by adding the script for the line graph I wanted into the elements section of the script

View solution in original post

5 REPLIES 5
ErraticAttack
Level VI

Re: Adding mean line by script

You'll need to provide more information -- How are you adding the line?  Can you provide a script that uses an example data table so that we can test?

Jordan
txnelson
Super User

Re: Adding mean line by script

Here is an example of adding a Line to an existing Graph Builder plot

txnelson_0-1658370235569.png

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );
gb = Graph Builder(
	Variables( X( :height ), Y( :weight ) ),
	Elements( Points( X, Y ), Smoother( X, Y ) )
);
gbb = Report( gb )[Graph Builder Box( 1 )];
gbb << Add Element( 1, 1, {Type( "Line" ), X, Y} );

The documentation for the messages that can be sent to Graph Builder are found in the Scripting Index.

Jim
Jemster
Level III

Re: Adding mean line by script

Thank you, this works to add a line but I was wondering how I can change it so that the line is a horizontal line displaying the mean Y variable

txnelson
Super User

Re: Adding mean line by script

Go to the Scripting Index and search on

add ref line

Jim
Jemster
Level III

Re: Adding mean line by script

I overlayed the two graphs onto one plot by adding the script for the line graph I wanted into the elements section of the script