The Origin Forum
File Exchange
Try Origin for Free
The Origin Forum
Home | Profile | Register | Active Topics | Members | Search | FAQ | Send File to Tech support
Username:
Password:
Save Password
Forgot your Password? | Admin Options

 All Forums
 Origin Forum for Programming
 Forum for Origin C
 Editing a single Datapoint on a curve
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

SteveS2

USA
Posts

Posted - 08/09/2006 :  8:41:06 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin 7.5 SR5
Windows 2000 SP4

Is there a way in Origin C to modify a single data point on a curve.
I want to loop through the all the points within a curve and change the symbol of a single point.


For example, I want to place a square symbol on every 10th point and the remove the symbols on the rest of the points.



Deanna

China
Posts

Posted - 08/10/2006 :  01:41:33 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Yes, it is possible to do that. We can add an extra column to the worksheet and uses it to control the shape of the data points.

It is just like using the Plot Detail dialog to have Origin use a column as the shape indexing. If indexing is zero, the symbol will not show; if indexing value is 1, the symbol will be a square; for 2, the shape will be circle...


In Origin C, we can add a column for shape indexing to the worksheet, fill it with proper numbers, change the format of the graph page so as to set the column for shape indexing of the scatter plot.
For example, the following program can "place a square symbol on every 10th point and the remove the symbols on the rest of the points" as you have requested.


void test5018()
{
//Get the active graph layer
GraphLayer gl=Project.ActiveLayer();
if (!gl) return;

//Get dataset name for the first dataplot
DataPlot dp=gl.DataPlots(0);
string strName = dp.GetDatasetName();

//Find the name of worksheet and the index of the column
int iPos=strName.Find('_');
Worksheet wks(strName.Left(iPos));
string strColName = strName.Right(strName.GetLength()-iPos-1);
int iIndexCol1=wks.Columns(strColName).GetIndex();

//Add a new column
string strColNameCreated;
wks.AddCol("shape", strColNameCreated);
Column colCreated = wks.Columns(strColNameCreated);
int iIndexCol2=colCreated.GetIndex();


//Set values
colCreated.SetFormula("rmod(i,10)==0?1:0");
colCreated.ExecuteFormula();


//Get format of the graph page
GraphPage pg = gl.GetPage();
Tree tr;
tr = pg.GetFormat(FOB_PLOT, FPB_STYLE_SYMBOL_SHAPE);

//Get the tree node for symbol shape
TreeNode tn;
tn=tree_get_node_by_attributes(tr, "NodeID", "143");
if (!tn.IsValid()) return;

//Set properties
tn.nVal=iIndexCol2-iIndexCol1+100;

//Apply the changed format
pg.ApplyFormat(tr);

}


You can change the formula as you need in the line:
colCreated.SetFormula("rmod(i,10)==0?1:0");

Deanna
OriginLab GZ Office

Edited by - Deanna on 08/10/2006 01:42:34 AM
Go to Top of Page
  Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000