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
- :
- Wait function within a for loop within graph box..

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

Mar 29, 2016 6:57 AM
(682 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

Solution

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

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

Mar 29, 2016 8:20 AM
(480 views)

- 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
(480 views)

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

Mar 29, 2016 8:31 AM
(480 views)

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
(480 views)

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
(480 views)

- 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
(480 views)

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
(480 views)