Filtering Graph Data


Recommended Posts

I am using XY plot to trend 2 channels, I am needing to run a set condition and generate the plot.  I have this functioning well.  The next step would be to hold this data on the plot, make adjustments to my conditions and generate the next plot on the same graph without showing the collected data while changing conditions.  Additionally I would like to change trend color as well for each curve.  Is this possible?  

To further enhance the display, is there a way to add annotations on the fly or select from a drop down menu the prescribed operating conditions?

Link to comment
Share on other sites

You'd have to make a copy of the data.  So if your X/Y was plotting channelX vs channelY, you could do something like:

global chanXData = channelX
global chanYData = channelY

then plot chanXData vs chanYData.  Then do channelX.clearHistory() and channelY.clearHistory() before each run to start anew.  

The best way to handle this in script, if you expect to do this several times, is to actually use an object:

class CData
   local XData
   local YData

Then instead of what I did above, create a global variable called "PlotData".  Then for each run:

private newData = new(CData)
newData.xdata = channelX
newData.ydata = channelY

Now you can plot:

PlotData[0].xdata vs plotData[0].ydata

and change the 0 to other numbers as you accumulate more data sets.    This allows you to dynamically add/remove data sets.  Just add some script to add new traces on the fly too.



Link to comment
Share on other sites

Can you help with the syntax to add traces with the data from plotData variable?

I am not understanding how to get this.

Here is my sequence 



class CData

   local xData

   local yData





private newData = new(CData)

newData.xData = AIN2

newData.yData = AIN1






component.Graph2D.AddTrace ("test1")

component.Graph2D.test1.strYExpression = ????

component.Graph2D.test1.strXExpression = ????

Link to comment
Share on other sites

PlotData will become an array of CData objects over time, so you'll have to create multiple traces.  But to start, if you only have the code above, it would be:

component.Graph2D.test1.strYExpression = "plotData[0].ydata"

component.Graph2D.test1.strXExpression = "plotData[0].xdata"

Once you have more data sets, you'll have to create more traces, then index into plotData to access the different data sets.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.