- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Graph builder element loop function
How can i use loop function for multiple position definition?
If separate like below it work:
Eval(
Substitute(
Expr(
gb = cdt << Graph Builder(
Size( 600, 800 ),
Show Control Panel( 0 ),
vvv,
Elements(Position( 1, 1 ),
Points( X, Y( 1 ), Y( 2 ), Y( 3 ), Legend( 3 ) ),
Smoother( X, Y( 1 ), Y( 2 ), Y( 3 ), Legend( 4 ) )
),
Elements(
Position( 2, 1 ),
Box Plot( X, Y, Outliers( 0 ) ),
Points( X, Y ),
Bar( X, Y, Bar Style( "Float" ), Label( "Label by Value" ) ),
Legend( 6 )
),
Elements(
Position( 2, 2 ),
Box Plot( X, Y, Outliers( 0 ) ),
Points( X, Y ),
Bar( X, Y, Bar Style( "Float" ), Label( "Label by Value" ) ),
Legend( 7 )
),
Elements(
Position( 2, 3 ),
Box Plot( X, Y, Outliers( 0 ) ),
Points( X, Y ),
Bar( X, Y, Bar Style( "Float" ), Label( "Label by Value" ) ),
Legend( 8 )
)
)
),
Expr( vvv ),
Name Expr( var expr )
)
);
But if using loop like this it's only have bar, what's missing in this code?
Eval(
Substitute(
Expr(
gb = cdt << Graph Builder(
Size( 600, 800 ),
Show Control Panel( 0 ),
vvv,
Elements(Position( 1, 1 ),
Points( X, Y( 1 ), Y( 2 ), Y( 3 ), Legend( 3 ) ),
Smoother( X, Y( 1 ), Y( 2 ), Y( 3 ), Legend( 4 ) )
),
For( j = 1, j <= n_mydatecol, j++,
Elements(
Position( 2, j ),
Box Plot( X, Y, Outliers( 0 ) ),
Points( X, Y ),
Bar( X, Y, Bar Style( "Float" ), Label( "Label by Value" ) ),
Legend(eval( 5 + j ))
),
),
)
),
Expr( vvv ),
Name Expr( var expr )
)
);
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Graph builder element loop function
I'm not sure what you are plotting, but it might (or might not) work. Here I'm using Add Element to add bar chart to X axis 2 and Y axis 1 and 2
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
gb = dt << Graph Builder(
Size(528, 454),
Show Control Panel(0),
Variables(X(:height), X(:sex), Y(:name), Y(:weight)),
Elements(Position(1, 1), Points(X, Y, Legend(20))),
Elements(
Position(1, 2),
Points(X, Y, Legend(5)),
Smoother(X, Y, Legend(6)),
Line Of Fit(X, Y, Legend(8))
),
Elements(Position(2, 1), Points(X, Y, Legend(19))),
Elements(Position(2, 2), Points(X, Y, Legend(18)))
);
gb << Add Element(2, 1, {Type("Bar"), X, Y, Bar Style("Float"), Label("Label by Value")});
gb << Add Element(2, 2, {Type("Bar"), X, Y, Bar Style("Float"), Label("Label by Value")});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Graph builder element loop function
You could build the elements expressions separately and then evaluate it inside graph builder expression. Or in some cases it might be easier if you use << Add Element
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)));
Wait(0.5);
gb << Add Element(1, 1, {Type("Line Of Fit"), X, Y, Degree("Quadratic")});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Graph builder element loop function
my chart want to be like this, do I need to define the position?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Graph builder element loop function
Add element does allow you setting X and Y position. Did you try if it would work for your use case?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Graph builder element loop function
Hello Jarmo,
Try to use the code below, but still only show box plot, how can i show the bar and label.
Eval(
Substitute(
Expr(
gb = cdt << Graph Builder(
Size( 1200, 800 ),
Show Control Panel( 0 ),
vvv,
Elements(
Position( 1, 1 ),
Points( X, Y( 1 ), Y( 2 ), Y( 3 ), Legend( 3 ) ),
Smoother( X, Y( 1 ), Y( 2 ), Y( 3 ), Legend( 4 ) )
)
);
// Loop to add repetitive elements
For( i = 2, i <= 10, i++,
gb << Add Elements(
Position( 2, i ),
Box Plot( X, Y( 1 ), Y( 2 ), Y( 3 ), Legend( 2 * i + 1 ) ),
Bar( X, Y, Legend( 2 * i + 2 ), Bar Style( "Float" ), Label( "Label by Value" ), Label Format( "Fixed Dec", 5, 2 ) )
);
);
),
Expr( vvv ),
Name Expr( var expr )
)
);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Graph builder element loop function
I will have to create example data (or find appropriate one) and re-create the graph so it will take some time
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Graph builder element loop function
I can see all the images have changed to something totally different they were earlier... I'm not sure how well the scripts provided to correspond to those new images. Which columns would have to be added dynamically and where?
Graph builder script for this
looks something like this
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
gb = dt << Graph Builder(
Size(528, 454),
Show Control Panel(0),
Variables(X(:height), X(:sex), Y(:weight)),
Elements(
Position(1, 1),
Points(X, Y, Legend(5)),
Smoother(X, Y, Legend(6)),
Line Of Fit(X, Y, Legend(8))
),
Elements(
Position(2, 1),
Points(X, Y, Legend(18)),
Bar(X, Y, Legend(19), Bar Style("Float"), Label("Label by Value"))
)
);
If you have a plot like this and you wish to add float bar chart to it to the right side with points
You can use add element
gb << Add Element(2, 1, {Type("Bar"), X, Y, Bar Style("Float"), Label("Label by Value")});
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
gb = dt << Graph Builder(
Size(528, 454),
Show Control Panel(0),
Variables(X(:height), X(:sex), Y(:weight)),
Elements(
Position(1, 1),
Points(X, Y, Legend(5)),
Smoother(X, Y, Legend(6)),
Line Of Fit(X, Y, Legend(8))
),
Elements(
Position(2, 1),
Points(X, Y, Legend(18))
)
);
gb << Add Element(2, 1, {Type("Bar"), X, Y, Bar Style("Float"), Label("Label by Value")});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Graph builder element loop function
Hi Jarmo,
Thanks for the helping, it can work went the y axis only have one, but what I want is if their have multiple y axis, can i still using loop function to have the element with box plot and bar? I had tried like the first one, but it only showed box plot without bars.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Graph builder element loop function
I'm not sure what you are plotting, but it might (or might not) work. Here I'm using Add Element to add bar chart to X axis 2 and Y axis 1 and 2
Names Default To Here(1);
dt = Open("$SAMPLE_DATA/Big Class.jmp");
gb = dt << Graph Builder(
Size(528, 454),
Show Control Panel(0),
Variables(X(:height), X(:sex), Y(:name), Y(:weight)),
Elements(Position(1, 1), Points(X, Y, Legend(20))),
Elements(
Position(1, 2),
Points(X, Y, Legend(5)),
Smoother(X, Y, Legend(6)),
Line Of Fit(X, Y, Legend(8))
),
Elements(Position(2, 1), Points(X, Y, Legend(19))),
Elements(Position(2, 2), Points(X, Y, Legend(18)))
);
gb << Add Element(2, 1, {Type("Bar"), X, Y, Bar Style("Float"), Label("Label by Value")});
gb << Add Element(2, 2, {Type("Bar"), X, Y, Bar Style("Float"), Label("Label by Value")});
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Graph builder element loop function
It works, and I try like this.
Thanks a lot
Eval(
Substitute(
Expr(
gb = cdt << Graph Builder(
Size( 600, 800 ),
Show Control Panel( 0 ),
vvv,
Elements(Position( 1, 1 ),
Points( X, Y( 1 ), Y( 2 ), Y( 3 ), Legend( 3 ) ),
Smoother( X, Y( 1 ), Y( 2 ), Y( 3 ), Legend( 4 ) )
),
);
For( i = 1 , i <= n_mymetric , i++,
gb << Add Element(2, i, {Type("Bar"), X, Y, Bar Style("Float"), Label("Label by Value")});
),
),
Expr( vvv ),
Name Expr( var expr )
)
);