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 color indexing by column value
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

rapt1

6 Posts

Posted - 03/17/2021 :  08:42:55 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Hi folks,

I have a question about setting the color of a data plot with respect to the values in another column like done here:
https://www.originlab.com/doc/Origin-Help/PlotColor-DatasetControl
manual: 9.3.2 Using a Dataset to Control Plot Color
Is there a (origin c) function to use/ specify or is the only way via the format tree? If yes which entries need to be set/how?

Thank you :)
D


win10
OriginPro 2021 (64-bit)
9.8.0.200

Edited by - rapt1 on 03/17/2021 08:46:19 AM

cpyang

USA
1406 Posts

Posted - 03/17/2021 :  11:12:59 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Yes, I will post OC code shortly, but first, let me post Python code to show how to use column next to Y as the color map.

import originpro as op
wks = op.find_sheet()#assume active XYY data
graph = op.new_graph(template='scatter')
layer = graph[0]
plot = layer.add_plot(wks, coly=1, colx=0)
layer.rescale()
plot.color = op.color_col(1)# the +1 column


CP
Go to Top of Page

cpyang

USA
1406 Posts

Posted - 03/18/2021 :  8:44:58 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Here is the OC code I promised, basically the LT color function added ability in Origin2021 to form the OCOLOR value needed to specify offset and type:

void plot_color_from_col()
{
	Worksheet wks = Project.ActiveLayer();  // get worksheet with group.dat data	
	// plot simple scatter plot
	DataRange dr;
	dr.Add(wks, 0, "X");
	dr.Add(wks, 1, "Y");
	
	GraphPage gp;
	gp.Create("scatter");  // create scatter graph	
	GraphLayer gl = gp.Layers(0);
	int nPlot = gl.AddPlot(dr, IDM_PLOT_SCATTER);  // add plot to layer
	gl.Rescale();

	DataPlot dp = gl.DataPlots(nPlot);
	dp.SetSymbol(12);   // set symbol shape: empty circle
	//LT color function color(offset, type), type: n=index, r=RGB, m=colormap
	double vv;LT_evaluate("color(1,n)",&vv);
	int oColor = (int)vv;
	dp.SetColor(oColor);
}



CP
Go to Top of Page

rapt1

6 Posts

Posted - 03/19/2021 :  04:21:49 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi,

thank you! That looks good.
Best,
D


win10
OriginPro 2021 (64-bit)
9.8.0.200

Edited by - rapt1 on 03/29/2021 3:21:19 PM
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