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

Showing results for

- JMP User Community
- :
- Discussions
- :
- Discussions
- :
- Wait function within a for loop within graph box..

- 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
- Subscribe to RSS Feed
- Get Direct Link
- Email to a Friend
- Report Inappropriate Content

Mar 29, 2016 6:57 AM
(3805 views)

Hi all,

I wanted to create a graph box that plots a point every, say, 0.5 seconds. The idea is that I can watch the evolution of my data through time for example.

Here is a simple script that doesn't work but it is how I imagined it working. Can somebody point to how you might achieve this?

x = **[****1** **2** **3** **4** **5]**;

y = -x;

New Window**(**"Data evolution",

graph box**(**

** **

for**(**i, i < **6**, i++,

Marker**(**x**[**i**]**, y**[**i**])**;

wait**(0.5)**;

**)**,

**)**,

**)**;

1 ACCEPTED SOLUTION

Accepted Solutions

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

Mar 29, 2016 8:05 AM
(6225 views)
| Posted in reply to message from sam_cartwright1 03/29/2016 09:57 AM

There are several ways to do this. Here's one example:

x = **[****1** **2** **3** **4** **5****]**;

y = -x;

//Start values (as matrices)

xi = x**[****1** :: **1****]**;

yi = y**[****1** :: **1****]**;

nw = New Window**(**"Data evolution", gb = Graph Box**(**X Scale**(****0**, **6****)**, Y Scale**(**-**6**, **0****)**, Marker**(**xi, yi**)))**;

For**(**i = **2**, i < **6**, i++,

Wait**(****0.5****)**;

xi = x**[****1** :: i**]**;

yi = y**[****1** :: i**]**;

gb << **reshow**;

**)**;

8 REPLIES

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

Mar 29, 2016 8:05 AM
(6226 views)
| Posted in reply to message from sam_cartwright1 03/29/2016 09:57 AM

There are several ways to do this. Here's one example:

x = **[****1** **2** **3** **4** **5****]**;

y = -x;

//Start values (as matrices)

xi = x**[****1** :: **1****]**;

yi = y**[****1** :: **1****]**;

nw = New Window**(**"Data evolution", gb = Graph Box**(**X Scale**(****0**, **6****)**, Y Scale**(**-**6**, **0****)**, Marker**(**xi, yi**)))**;

For**(**i = **2**, i < **6**, i++,

Wait**(****0.5****)**;

xi = x**[****1** :: i**]**;

yi = y**[****1** :: i**]**;

gb << **reshow**;

**)**;

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

Brilliant! Exactly what I wanted to achieve

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

Mar 29, 2016 8:21 AM
(3603 views)
| Posted in reply to message from sam_cartwright1 03/29/2016 09:57 AM

And (to prove the point) here's an alternative to the one provided by Marcus above:

x = **[****1** **2** **3** **4** **5****]**;

y = x;

New Window**(** "Data evolution",

gb = Graph Box**(**X Scale**(** **0**, **6** **)**, Y Scale**(** **0**, **6** **)**, **)**

**)**;

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

gb << **Set Graphics Script** **(**Marker**(**x**[****1**::i**]**, y**[****1**::i**]))**;

Wait**(** **0.5** **)**;

**)**;

I note that there were a couple of syntax errors in your sample code, so please be aware of 'Help > Scripting Index' and the examples therein.

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

Hi Ian,

I try to use the scripting index as much as possible but the matrix syntax is still a bit of a struggle for me at the moment.

For example I find that that

Marker(x, y) works

Marker(x[1::3], y[1::3]) works

Marker(x[1], y[1]) does not work

If you don't mind, what would be the correct syntax for a single point?

kind regards, Sam

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

Mar 29, 2016 8:42 AM
(3603 views)
| Posted in reply to message from sam_cartwright1 03/29/2016 11:31 AM

Don't worry - You will soon get it! If you want a single point, try Marker**({**x**[****1****]**, y**[****1****]}). **

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

Mar 29, 2016 8:52 AM
(3603 views)
| Posted in reply to message from sam_cartwright1 03/29/2016 11:31 AM

Marker( ) requires matrix or list arguments. x[1] returns a number by default, whereas x[1::2] returns a matrix. The odd syntax x[1::1] is a way to force the index to return a matrix for a single-number subscript.

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

Mar 29, 2016 10:15 AM
(3603 views)
| Posted in reply to message from sam_cartwright1 03/29/2016 09:57 AM

You could also use the Bubble Plot to get your data to animate.

The Data Filter also has an animation feature.

-Jeff

-Jeff

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

Mar 30, 2016 2:01 AM
(3603 views)
| Posted in reply to message from sam_cartwright1 03/29/2016 09:57 AM

Ah ok, this makes sense now. Thanks for the responses.