Tuesday, February 19, 2013

Origin C-Code for Plot the graph

#include <Origin.h>
void plotgraph(){
     int i;

 // Delcare worksheet object and datasets from 1st two columns of the worksheet
 Worksheet wks("Data1");
 Dataset dsX(wks, 0);
 Dataset dsY(wks, 1);
 dsY.SetSize(251);
  for(i=0;i<251;i++)
 {
 
  dsY[i]=dsY[i]*10000;
 }

 // Set up name of custom template to be used for creating a graph
 string strGraphTemplateName = LabTalk.System.Path.Program$
   + "Samples\\Programming\\Automation\\I-V curve original.OTP";
 // Create a graph using custom template
 GraphPage grphData;
 int nOptionG = CREATE_VISIBLE_SAME;
 bool bRetG = grphData.Create(strGraphTemplateName, nOptionG);

 // Declare active layer in current graph page
 GraphLayer grphLayer = grphData.Layers();

  // Declare a curve object using x,y columns of worksheet
 Curve crvData(wks, 0, 1);

  // Plot data curve to active layer
 int nPlot = grphLayer.AddPlot(crvData, IDM_PLOT_LINE);
 if(grphLayer)                                  // If valid graph layer...
  {
   Scale sc1(grphLayer.X);                     // Get X scale object from graph layer
   sc1.From = -1.0;                     // Assign scale from value
   sc1.To = 1.0;                       // assign scale to value
   Scale sc2(grphLayer.Y);                     // Get X scale object from graph layer
   sc2.From = -20.0;                     // Assign scale from value
   sc2.To = 20.0;                       // assign scale to value
  }

}

No comments:

Post a Comment