Our World Statistics Day conversations have been a great reminder of how much statistics can inform our lives. Do you have an example of how statistics has made a difference in your life? Share your story with the Community!
Choose Language Hide Translation Bar
Highlighted
Level II

## Building Multiple Graphs from one Data Table

When I build a graph from a dt like this:

``````gb = Data_Table << Graph Builder(
Size( 534, 454 ),
Show Control Panel( 0 ),
Show Legend( 0 ),
Variables(
X( :Split ),
X( :Wafer, Position( 1 ) ),
Y( As Column( analysisTests[i] ) ),
Color( :Split )
),
Elements(
Points( X( 1 ), X( 2 ), Y, Legend( 21 ) ),
Box Plot( X( 1 ), X( 2 ), Y, Legend( 22 ) )
)
);``````

It works great.  However, if I put it all in a loop, hoping to generate a set of graphs (one for each of the column labels) each in their own window, it just updates the first graph instead:

``````for(i = 1, i <= N Items(analysisTests), i++,
gb = Data_Table << Graph Builder(
Size( 534, 454 ),
Show Control Panel( 0 ),
Show Legend( 0 ),
Variables(
X( :Split ),
X( :Wafer, Position( 1 ) ),
Y( As Column( analysisTests[i] ) ),
Color( :Split )
),
Elements(
Points( X( 1 ), X( 2 ), Y, Legend( 21 ) ),
Box Plot( X( 1 ), X( 2 ), Y, Legend( 22 ) )
)
);
);``````

How do I get it to show a set of graphs, each in it's own window?  It seems like because its asking for a graph based on a data table I would need multiple data tables each with it's own graph, but it seems like there should be an easier way.  I tried gb[i] hoping to get a separate graph for each loop, but that gives an error. -- Not subscriptable value in access or evaluation of 'Assign'

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User

## Re: Building Multiple Graphs from one Data Table

Not sure why that is - I would expect the default action to be that separate windows are created; as in this script:

``````dt = open("\$SAMPLE_DATA/Big Class.jmp");
cols = dt << get column names;
for (i=1,i<=nitems(cols),i++,
dt << Graph Builder(
Size( 353, 317 ),
Show Control Panel( 0 ),
Variables( X( :height ), Y( eval(cols[i]) ) )
);
)``````

-Dave
4 REPLIES 4
Highlighted
Level VI

## Re: Building Multiple Graphs from one Data Table

Hi,
One way to do this is 1) create a new window and a ListBox outside the loop, 2) Append each graph to the ListBox within the loop, and 3) Append the new window with the ListBox after the loop closes. I don't have the time to give you a complete script solution but you might be able to figure it out with the Scripting Help and Manual.
Best,
TS
Thierry R. Sornasse
Highlighted
Super User

## Re: Building Multiple Graphs from one Data Table

Not sure why that is - I would expect the default action to be that separate windows are created; as in this script:

``````dt = open("\$SAMPLE_DATA/Big Class.jmp");
cols = dt << get column names;
for (i=1,i<=nitems(cols),i++,
dt << Graph Builder(
Size( 353, 317 ),
Show Control Panel( 0 ),
Variables( X( :height ), Y( eval(cols[i]) ) )
);
)``````

-Dave
Highlighted
Super User

## Re: Building Multiple Graphs from one Data Table

If I misunderstood what you meant by "window" - and that what you really want are lots of graphs in a single window then you need to put the graph in a container (that prevents it being rendered immediately) and then append it to a pre-existing display box (hlb in this example)

``````dt = open("\$SAMPLE_DATA/Big Class.jmp");
cols = dt << get column names;
NewWindow("Demo",
hlb = HListBox()
);
for (i=1,i<=nitems(cols),i++,
content = VListBox(
dt << Graph Builder(
Size( 353, 317 ),
Show Control Panel( 0 ),
Variables( X( :height ), Y( eval(cols[i]) ) )
)
);
hlb << append(content)
);``````
-Dave
Highlighted
Level II

## Re: Building Multiple Graphs from one Data Table

Thanks David,

This is actually exactly what I was doing, but it was only showing the last one.  I ended up finding a bug in part of the "extra" script I didn't show and once that was fixed it started working correctly.  So you're answer showed me that I was doing it right and pointed me in the right direction to finding the real problem.  Thanks

Article Labels