Written by Erez Wenger - June 2011
In this post we explain, in images and code-lines, how to easily plot multiple traces.
If you are using a stripchart (see our previous stripchart post here) you might want to show two or more traces at once. This can be very useful as you can avoid using many stripcharts, save space, and do it in an elegant way.
Changing the number of traces on the UIR
- Go to the UIR and edit the stripchart control.
- Click the Traces button.
- Change the number of traces to the desired amount.
- Select style and color for each trace.
- Define an array as large as the amount of traces you want.
- On each time step calculate the value of each trace.
- Use the PlotStripChart command to draw the traces.
double y; //Array for 2 traces
y=sin(Pi()*t); //first trace calculation
y=2.0*sin(Pi()*t+0.5); //second trace calculation
PlotStripChart (panelHandle, PANEL_STRIPCHART, y, 2, 0, 0, VAL_DOUBLE); //plotting the traces