Turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

- JMP User Community
- :
- Discussions
- :
- Re: sheetbox in a for loop ?

Topic Options

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Apr 12, 2012 7:42 AM
(5861 views)

I have been trying to create a display using sheet boxes and its not going well.

I am using a for loop to create a display and using "hsheetbooxname << append" commands . .

but not getting it right. In this simple example below. . can someone

show me how to convert this to type where you open an empty sheet box. .

then append in the different objects ? The << Hold command has me stumped.

dt = Open("$ENGLISH_SAMPLE_DATA/Big Class.jmp");

dt << minimize window();

NewWindow("Example",

VSheetBox(

<<Hold(Bivariate(Y(:weight), X(:height), FitLine())),

<<Hold(Distribution(Continuous Distribution(Column(:height),Horizontal Layout(1),Outlier Box Plot(0)))),

<<Hold(Tree Map(Categories(:age))),

<<Hold(Bubble Plot(X(:height),Y(:weight),Sizes(:age),Coloring(:sex),Circle Size(6.226),All Labels(0))),

HSheetBox(

SheetPart("", ExcerptBox(1, {PictureBox(1)})),

SheetPart("", ExcerptBox(2, {PictureBox(1)}))

),

HSheetBox(

SheetPart("", ExcerptBox(3, {PictureBox(1)})),

SheetPart("", ExcerptBox(4, {PictureBox(1)}))

)

)

);

1 ACCEPTED SOLUTION

Accepted Solutions

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Almost there. It seems like Hold() works with the expression rather than the platform object.

Try redefining your g's like this:

g1 = expr**(** Bivariate**(**Y**(**:weight**)**, X**(**:height**)**, FitLine**()))**;

g2 = expr**(** Distribution**(**Column**(**:height**)**,Horizontal Layout**(****1****)**,Outlier Box Plot**(****0****)))**;

g3 = expr**(** Tree Map**(**Categories**(**:age**)))**;

g4 = expr**(** Bubble Plot**(**X**(**:height**)**,Y**(**:weight**)**,Sizes**(**:age**)**,Coloring**(**:sex**)**,Circle Size**(****6.226****)**,All Labels**(****0****)))**;

8 REPLIES 8

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: sheetbox in a for loop ?

Here is more of the format I am looking for. . this one does not work.

I need to apply the logic to a much larger sheetbox project I am working on.

dt = Open("$ENGLISH_SAMPLE_DATA/Big Class.jmp");

dt << minimize window();

w = NewWindow("New Example", vsb = Vsheetbox());

g1 = dt << Bivariate(Y(:weight), X(:height), FitLine());

g2 = dt << Distribution(Column(:height),Horizontal Layout(1),Outlier Box Plot(0));

g3 = dt << Tree Map(Categories(:age));

g4 = dt << Bubble Plot(X(:height),Y(:weight),Sizes(:age),Coloring(:sex),Circle Size(6.226),All Labels(0));

vsb <<Hold(g1);

vsb <<Hold(g2);

vsb <<Hold(g3);

vsb <<Hold(g4);

sp1 = SheetPart("platform1", ExcerptBox(1, {PictureBox(1)}));

sp2 = SheetPart("platform2", ExcerptBox(2, {PictureBox(1)}));

hsb1 = HSheetBox();

hsb1 << append(sp1);

hsb1 << append(sp2);

vsb << append(hsb1);

sp3 = SheetPart("platform3", ExcerptBox(3, {PictureBox(1)}));

sp4 = SheetPart("platform4", ExcerptBox(4, {PictureBox(1)}));

hsb2 = HSheetBox();

hsb2 << append(sp3);

hsb2 << append(sp4);

vsb << append(hsb2);

w << Bring Window to Front;

w << refresh;

Highlighted

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Almost there. It seems like Hold() works with the expression rather than the platform object.

Try redefining your g's like this:

g1 = expr**(** Bivariate**(**Y**(**:weight**)**, X**(**:height**)**, FitLine**()))**;

g2 = expr**(** Distribution**(**Column**(**:height**)**,Horizontal Layout**(****1****)**,Outlier Box Plot**(****0****)))**;

g3 = expr**(** Tree Map**(**Categories**(**:age**)))**;

g4 = expr**(** Bubble Plot**(**X**(**:height**)**,Y**(**:weight**)**,Sizes**(**:age**)**,Coloring**(**:sex**)**,Circle Size**(****6.226****)**,All Labels**(****0****)))**;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: sheetbox in a for loop ?

Thanks MS.. that worked perfectly and saved me more frustration with that hurdle.

My bigger project actually has some Substitution expressions using a list of columns. .will see if I can apply this learning to that.

Will let you know how it comes out. I may be calling again.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: sheetbox in a for loop ?

I tried to build a sheet box with a for loop and came up with this code. It's adapted to collect graphs from a report with an arbitrary (>1) number of by-groups, i.e several similar graphs for different subgroups within the same window. But the principle should be possible to adapt to any collection of objects. Btw, try changing Picture Box(1) to Table Box(1) or Listbox(1).

// Script to collect graphs from a report with by-groups

dt = Open**(** "$ENGLISH_SAMPLE_DATA/Big Class.jmp" **)**;

by_column = Column**(** "age" **)**;

objexpr = Expr**(** Bivariate**(** Y**(** :weight **)**, X**(** :height **)**, FitLine**()**, by**(** by_column **)** **)** **)**;

//some math to define the layout

Summarize**(** g = by**(** by_column **)** **)**;

nobj = N Items**(** g **)**;

rows = Floor**(** Sqrt**(** nobj **)** **)**;

cols = Ceiling**(** nobj / rows **)**;

//Set up the panels

vsb = V Sheet Box**(** <<hold**(** objexpr **)** **)**;

HSheetBoxes = **{}**;

For**(** i = **1**, i <= rows, i++,

Insert Into**(** HSheetBoxes, H Sheet Box**()** **)**;

vsb << append**(** HSheetBoxes**[**i**]** **)**;

**)**;

// Populate with elements from reports

For**(** i = **1**, i <= rows * cols, i++,

If**(** i <= nobj,

HSheetBoxes**[**Ceiling**(** i / cols **)]** << append**(**

Sheet Part**(** by_column << get name || " = " || g**[**i**]**, Excerpt Box**(** i, **{**picture Box**(** **1** **)}** **)** **)**

**)**,

HSheetBoxes**[**Ceiling**(** i / cols **)]** << append**(** Spacer Box**()** **)**

**)**

**)**;

//Make window

New Window**(** headname**(**objexpr**)**, vsb **)**;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: sheetbox in a for loop ?

Wow. Your for loop example is great and close to what I am trying to do. Yours is much more elegant than mine. Humbling. I will have to study yours

carefully. My brain is still scripting basic expressions and evaluating basic expressions. . I need to get this concept to click to get to the next level.

Thank you.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: sheetbox in a for loop ?

Thanks! The conditional spacer box thing is just cometic. It adds empty boxes to the end if the number of graphs does not fit the layout matrix. It works without this feature but any trailing graphs are then automatically resized to fill the sheetbox which may look ugly.

For me, learning JSL has been a lot of trial and error. Many hours spent to find elaborate workarounds for (poorly documented) things that "should" work but don't. Later I often find a much simpler way, e.g. on this forum. Good luck!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: sheetbox in a for loop ?

MS,

in your sheetbox example above, can you save this as a journal ?

I get a jmp exception when I do.

Brad

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Re: sheetbox in a for loop ?