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
 All Forums
 Origin Forum for Programming
 Forum for Origin C
 plot color indexing by column value

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

Screensize:
UserName:
Password:
Anti-Spam Code:
Format Mode:
Format: BoldItalicizedUnderlineStrikethrough Align LeftCenteredAlign Right Horizontal Rule Insert HyperlinkUpload FileInsert Image Insert CodeInsert QuoteInsert List
   
Message:

* HTML is OFF
* Forum Code is ON
Smilies
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Clown [:o)]
Black Eye [B)] Eight Ball [8] Frown [:(] Shy [8)]
Shocked [:0] Angry [:(!] Dead [xx(] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
rapt1 Posted - 03/17/2021 : 08:42:55 AM
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
3   L A T E S T    R E P L I E S    (Newest First)
rapt1 Posted - 03/19/2021 : 04:21:49 AM
Hi,

thank you! That looks good.
Best,
D


win10
OriginPro 2021 (64-bit)
9.8.0.200
cpyang Posted - 03/18/2021 : 8:44:58 PM
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
cpyang Posted - 03/17/2021 : 11:12:59 PM
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

The Origin Forum © 2020 Originlab Corporation Go To Top Of Page
Snitz Forums 2000