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
 Creating a Colormap Scatter Plot
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Seb136

6 Posts

Posted - 09/18/2018 :  07:48:43 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Ver. and Service Release (Select Help-->About Origin): 2017 b9.4.0.220
Operating System:Win10

Hi all,

I have a problem creating a scatter plot with a colormap.



Worksheet wks = Project.ActiveLayer();

DataRange dr;
	
//Creating XYY Range
dr.Add("X", wks, 0, 2, -1, 2);
dr.Add("Y", wks, 0, 4, -1, 4);
dr.Add("Y", wks, 0, 6, -1, 6);
	
GraphPage gp;
gp.Create("Origin");
GraphLayer gl = gp.Layers();
	
gl.AddPlot(dr, IDM_PLOT_INDEX_COLOR); //ID: 247 for Color mapped


This code is my attempt to create a graph that has column 3 as X, column 5 as Y and column 7 as the reference for the color scale.
Instead it just creates a graphpage with columns 5 and 7 as a group and no plot type is selected (so it's just a blank page with axes).

The LabTalk commands I used in this code work as I want them to, execpt that it creates a line plot so I have to use the update_plot_type X-Function.

Worksheet wks = Project.ActiveLayer();
	
wks.Columns(2).SetType(OKDATAOBJ_DESIGNATION_X);
	
LT_execute("wks.ColSel(3,1)");
LT_execute("wks.ColSel(5,1)");
LT_execute("wks.ColSel(7,1)");
LT_execute("Worksheet -p 247");

//use x-function to change plot type to scatter
GraphLayer gl = Project.ActiveLayer();
DataPlot dp = gl.DataPlots(0);
update_plot_type(dp, IDM_PLOT_SCATTER);


Can someone tell me why my OC-code doesn't work as it's supposed to but instead creates a grouped plot?

Thanks a lot
Seb

yuki_wu

896 Posts

Posted - 09/19/2018 :  01:34:22 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Seb,

It seems that IDM_PLOT_INDEX_COLOR only works in LabTalk, but you could try method DataPlot::SetModifier
https://www.originlab.com/doc/OriginC/ref/DataPlot-SetModifier
void test_plot_scatter_3()
{
	Worksheet wks = Project.ActiveLayer();
	DataRange dr;	
	//Creating XYY Range
	dr.Add(wks, 0, "X");
	dr.Add(wks, 1, "Y");
	GraphPage gp;
	gp.Create("Origin");
	GraphLayer gl = gp.Layers();	
	gl.AddPlot(dr, IDM_PLOT_SCATTER);
    DataPlot dp = gl.DataPlots(0); 
	if( !dp )
		return;
	Column col(wks, 2);
	dp.SetModifier(COLDESIG_COLOR, col);
	gl.Rescale();
}

Hope it helps.

Regards,
Yuki

OriginLab
Go to Top of Page

Seb136

6 Posts

Posted - 09/19/2018 :  03:26:26 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi Yuki,

thank you very much it works perfectly fine!
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