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
 Setting line colormap
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

couturier

France
291 Posts

Posted - 02/23/2024 :  08:07:14 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): 2024
Operating System:10

Very basic question but couldn't find any solution
I have a line plot which I want to colormap according to another column (or vector)
I can setup my colormap with dp.SetColormap or dataplot_set_colormap() but how do I link the colormamp to the column ?
couldn't find the right option in dp.SetModifier()

minimax

351 Posts

Posted - 02/26/2024 :  04:01:02 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Antoine,

You will need to use ApplyFormat() instead, like following:


void DataPlot_SetColorByCol_ex()
{
	//wks with 3 columns
	int nXCol = 0, nYCol = 1, nCCol = 2;
	Worksheet wks = Project.ActiveLayer();
	DataRange dr;	
	dr.Add(wks, nXCol, "X");
	dr.Add(wks, nYCol, "Y");
	
	//make a line plot
	GraphPage gp;
	gp.Create("Origin");
	GraphLayer gl = gp.Layers();	
	gl.AddPlot(dr, IDM_PLOT_LINE);
        DataPlot dp = gl.DataPlots(0); 
	if( !dp )
		return;
	
	//set line color by theme
	OQCOLOR oqColor;
	okutil_get_ocolor_by_col(&oqColor, nCCol, nYCol, COLTYPE_COLOR_COLORMAP);
	Tree trFormat;
	trFormat.Root.Line.Color.nVal = oqColor;
	int iRet = dp.UpdateThemeIDs(trFormat.Root, "Error", "Unknown tag");
	bool bRet = dp.ApplyFormat(trFormat, true, true);     
	
	gl.Rescale();
}


We will check how to improve the document, so it will be easier to find out okutil_get_ocolor_by_col().
Go to Top of Page

couturier

France
291 Posts

Posted - 02/27/2024 :  12:03:59 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
thanks a lot
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