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
 Plot skip points and change y question
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

kwis2

Poland
6 Posts

Posted - 11/18/2012 :  6:46:39 PM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hi
I have a lot of plots, and I would like to format every plot depends on dataset.
With colour and points it is easy by tree, but I have problem with data, where I would like to skip points, like in the drop lines in plot properties menu. I am no able to find the way how to set this property.

Best regards
Kamil

kwis2

Poland
6 Posts

Posted - 11/18/2012 :  7:06:54 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Sorry for reply on my own post, I wasn't able to edit my post :(

Another part of question It is how could I change "Y" on plots. I mean I would like to change ploted data for instance from column 3 to 4 of worksheet by one click. I have tried XYRange but I have failed.

Best regards
Kamil
Go to Top of Page

Penn

China
644 Posts

Posted - 11/19/2012 :  12:48:59 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Kamil,

1. About skipping points, you can use the LabTalk command set %C -skip n. For example:

string strCMD;
int nSkipPoints = 4;  // skip points is 4
strCMD.Format("set %s -skip %d;", dp.GetDatasetName(), nSkipPoints);  // dp is the data plot object
gl.LT_execute(strCMD);  // execute the LabTalk command, gl is the graph layer of the data plot

2. To change Y, please refer to the following sample code.

// Arguments:
// const string strNewData: the name of the new data
// int nPlotIndex = -1: the index of the plot in the layer to be changed data
void test_changeplotdata(const string strNewData, int nPlotIndex = -1)
{
	GraphLayer glActive = Project.ActiveLayer();  // get the active graph layer
	if(!glActive)
	{
		out_str("Error, please the active window is graph.");
		return;
	}

	DataPlot dp = glActive.DataPlots(nPlotIndex);  // get the data plot by index
	if(!dp)
	{
		out_str("Error, not found data plot by index.");
		return;
	}
	if( nPlotIndex < 0 ) // -1 means active plot index, need to convert to real index
		nPlotIndex = dp.GetIndex();

	Tree trContents;
	glActive.GetLayerContents( trContents, GETLC_DATAPLOTS );	// get layer contents tree
	TreeNode trLayer = trContents.GetNode( "Layer" + glActive.GetIndex() ); // layer tree node, the index offset is 0 here
	if( !trLayer )
	{
		out_str("Error");
		return;
	}
		
	string strName = "DataPlot" + (string)( nPlotIndex + 1 ); // the index offset is 1 here
	TreeNode trDataPlot = trLayer.GetNode(strName);	  // data plot tree node
	if( trDataPlot )
	{
		TreeNode trDepData = trDataPlot.PlotDesigs.DPC1;
		if( trDepData && trDepData.Name )
		{   	
			trDepData.Name.strVal = strNewData;  // replace with the new data name
			DWORD dwAddPlotsCtrl = ADDPLOTSFROMTREE_EDIT|ADDPLOTSFROMTREE_IMPLICIT_STYLEHOLDERS;
			int nNewPlotNum = glActive.AddPlots( trContents.FirstNode, dwAddPlotsCtrl );
		}
	}
}


Penn

Edited by - Penn on 11/19/2012 12:49:25 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