cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • New to JMP? Join us Sept. 23-24 for the Early User Edition of Discovery Summit, tailor-made for new users. Register now for free!
  • Use World Cup data to build models, explore spatial relationships, and create informative visualizations in JMP. Register. July 17, 2 pm US Eastern Time.
  • Your voice matters! Tell us how you prefer to receive JMP updates, so we can tailor our communication to your needs. Take short survey.

Discussions

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

I need help to make this loop work

Hello everybody.

Names Default To Here( 1 );
dt = Current Data Table();
For ( i = 1951, i <= 2021, i++, 


	gb = dt << Bivariate(
		Y( :PRCPC ),
		X( :Mes ),
		Fit Each Value( {Line Color( {208, 64, 86} )} ),
		Fit Line( {Line Color( {45, 177, 53} )} ),
		Fit Spline( 20.13724, {Line Color( {64, 110, 211} )} ),
		Where( :Any == [i]),
		SendToReport(
			Dispatch( {}, "Bivar Plot", FrameBox, {Frame Size( 486, 411 )} ),
			Dispatch( {}, "Linear Fit", "Summary of Fit",OutlineBox, {Close( 1 )} )
		),

	);
	gb << Save Picture( "/Users/mgc/Desktop/" || :Any == [i] || ".png", PNG );
	
),

. Thank you in advance

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: I need help to make this loop work

In your Where() clause, you need to remove the {} around the "i" variable.

In the Save Picture, you need to convert the value of "i" to a character before it can be concatenated to the string.

Names Default To Here( 1 );
dt = Current Data Table();
For ( i = 1951, i <= 2021, i++, 


	gb = dt << Bivariate(
		Y( :PRCPC ),
		X( :Mes ),
		Fit Each Value( {Line Color( {208, 64, 86} )} ),
		Fit Line( {Line Color( {45, 177, 53} )} ),
		Fit Spline( 20.13724, {Line Color( {64, 110, 211} )} ),
		Where( :Any == i),
		SendToReport(
			Dispatch( {}, "Bivar Plot", FrameBox, {Frame Size( 486, 411 )} ),
			Dispatch( {}, "Linear Fit", "Summary of Fit",OutlineBox, {Close( 1 )} )
		),

	);
	gb << Save Picture( "/Users/mgc/Desktop/" || char(i) || ".png", PNG );
	
);
Jim

View solution in original post

1 REPLY 1
txnelson
Super User

Re: I need help to make this loop work

In your Where() clause, you need to remove the {} around the "i" variable.

In the Save Picture, you need to convert the value of "i" to a character before it can be concatenated to the string.

Names Default To Here( 1 );
dt = Current Data Table();
For ( i = 1951, i <= 2021, i++, 


	gb = dt << Bivariate(
		Y( :PRCPC ),
		X( :Mes ),
		Fit Each Value( {Line Color( {208, 64, 86} )} ),
		Fit Line( {Line Color( {45, 177, 53} )} ),
		Fit Spline( 20.13724, {Line Color( {64, 110, 211} )} ),
		Where( :Any == i),
		SendToReport(
			Dispatch( {}, "Bivar Plot", FrameBox, {Frame Size( 486, 411 )} ),
			Dispatch( {}, "Linear Fit", "Summary of Fit",OutlineBox, {Close( 1 )} )
		),

	);
	gb << Save Picture( "/Users/mgc/Desktop/" || char(i) || ".png", PNG );
	
);
Jim

Recommended Articles