BookmarkSubscribeRSS Feed
Akane

Occasional Contributor

Joined:

Nov 7, 2018

how to fix graph size when add multiple graphs in single window?

Hello,

I use For loop to create graph size (800,800) and add to the same window. When test the script only for one graph, size is correct. When added multiple graphs in single window, it will adjust y automatically and it is too narrow to review the data. 

Could you please advise how to fix graph size when add to the single window?

Thank you.

 

nw= New Window("Report");

For(j = 1, j <= nitems(mylist) , j++,
prod_list = mylist[j];
Gr1 = expr (Data Table(" Rej Rate "||prod_list) << Graph Builder(
	Size( 800,800 ),
.
.
);
nw << Append (Hlistbox(Gr1)); 
); // end for mylist loop

@msharp  I created new post as your comment. Thank you.

2 ACCEPTED SOLUTIONS

Accepted Solutions
msharp

Super User

Joined:

Jul 28, 2015

Solution

Re: how to fix graph size when add multiple graphs in single window?

Akane, try appending it to a list box, not the window directly.  That should fix your issue.

 

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

nw = New Window("Dashboard", hlb = hlistbox()); //vlistbox if you want it vertical

for(i=1, i<10, i++,
	g = expr(dt << Graph Builder(
		Size( 800, 800 ),
		Show Control Panel( 0 ),
		Variables( X( :name ), Y( :age ) ),
		Elements( Points( X, Y, Legend( 5 ) ) )
	));
	hlb << Append(g);
);

Also, instead of calling Data Table's by name, its a better practice to store the data table reference in a variable and call that.

So....

//Bad Practice
mylist = {"name1", "name2"};
For(j = 1, j <= nitems(mylist) , j++,
prod_list = mylist[j];
Gr1 = expr (Data Table(" Rej Rate "||prod_list) << Graph Builder(
	Size( 800,800 ),
	
//Good Practice
mylist = {dt1, dt2};
For(j = 1, j <= nitems(mylist) , j++,
dt = mylist[j];
Gr1 = expr (dt << Graph Builder(
	Size( 800,800 ),

 

Highlighted
danschikore

Staff

Joined:

Sep 21, 2012

Solution

Re: how to fix graph size when add multiple graphs in single window?

Another solution would be to add:

 

Fit To Window("off")

as part of your Graph Builder() command.  By default Graph Builder automatically decides whether to stretch with the window or maintain a constant size.  I think the solution that @msharp provided changes the auto-stretching behavior.  I'm actually not sure why that changes things - this may be a bug that you are working around.

3 REPLIES
msharp

Super User

Joined:

Jul 28, 2015

Solution

Re: how to fix graph size when add multiple graphs in single window?

Akane, try appending it to a list box, not the window directly.  That should fix your issue.

 

Names Default To Here( 1 );
dt = Open( "$SAMPLE_DATA/Big Class.jmp" );

nw = New Window("Dashboard", hlb = hlistbox()); //vlistbox if you want it vertical

for(i=1, i<10, i++,
	g = expr(dt << Graph Builder(
		Size( 800, 800 ),
		Show Control Panel( 0 ),
		Variables( X( :name ), Y( :age ) ),
		Elements( Points( X, Y, Legend( 5 ) ) )
	));
	hlb << Append(g);
);

Also, instead of calling Data Table's by name, its a better practice to store the data table reference in a variable and call that.

So....

//Bad Practice
mylist = {"name1", "name2"};
For(j = 1, j <= nitems(mylist) , j++,
prod_list = mylist[j];
Gr1 = expr (Data Table(" Rej Rate "||prod_list) << Graph Builder(
	Size( 800,800 ),
	
//Good Practice
mylist = {dt1, dt2};
For(j = 1, j <= nitems(mylist) , j++,
dt = mylist[j];
Gr1 = expr (dt << Graph Builder(
	Size( 800,800 ),

 

Highlighted
danschikore

Staff

Joined:

Sep 21, 2012

Solution

Re: how to fix graph size when add multiple graphs in single window?

Another solution would be to add:

 

Fit To Window("off")

as part of your Graph Builder() command.  By default Graph Builder automatically decides whether to stretch with the window or maintain a constant size.  I think the solution that @msharp provided changes the auto-stretching behavior.  I'm actually not sure why that changes things - this may be a bug that you are working around.

Akane

Occasional Contributor

Joined:

Nov 7, 2018

Re: how to fix graph size when add multiple graphs in single window?

Thank you. It works both method.