Sign in to follow this  
NickB

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?

Share this post


Link to post
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
endclass

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
PlotData.append(newData)
channelX.ClearHistory()
channelY.ClearHistory()

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.

 

 

Share this post


Link to post
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

endclass

 

 

 

private newData = new(CData)

newData.xData = AIN2

newData.yData = AIN1

PlotData.append(newData)

AIN2.ClearHistory()

AIN1.ClearHistory()

 

 

component.Graph2D.AddTrace ("test1")

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

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

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this