Showing results for 
Search instead for 
Did you mean: 

Waveform graph inside loop



I want to insert a graph inside a while loop which will build gradually on each iteration. The X and Y axis ranges will be prespecified outside the loop and the expected curve will build while the code is running. Please have a look on the attached script. The output is pretty much the input squared and the curve on the graph at the end of the code execution should look like the one below





0 Kudos
Message 1 of 7
The easiest way would be to use a waveform "chart". You feed it one point at a time and it maintains a history.
If you want to clear the chart, write an empty array to the "history" property via property node.
To specify x and y axis limits, turn off autoscaling and set x.min, x.max, y.min, and y.max via property node once before the loop.
Message 2 of 7

@Gregory thank you for your suggestions. They seem to work however I can not figure out hot to set-up properly the X axis on the chart. For example my X values need to be x_min=0 and x_max=6 and stay like this for the entire code execution.





0 Kudos
Message 3 of 7
The default is dt=1. If you are plotting 7 points (0 to 6) this will fit perfectly. If not, you have to set the XScale.Multiplier to property to reflect your actual dt. You can set it as the reciprocal of your resolution control and it should get you pretty close. Set the multiplier first (top of the property node) or run twice for a proper update.
Message 4 of 7

Seems to work that way. The only minor issue is that the XScale.Increment property does not seem to respond to its input. The Y one does. Any ideas on how to fix that?




0 Kudos
Message 5 of 7

I don't know if you are looking for that, but if you want to see all the X markers from 0 to 6 you have to set property to 0. You can also set it in the right click menu of the chart. 

0 Kudos
Message 6 of 7

Hi MichailM,

The reason may be a race condition...Inorder to fix that ,please wire the error out from the property node to the while loop to ensure that all the properties are set before execution of while loop.




0 Kudos
Message 7 of 7