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
 Ploting with longnames

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
Chris2 Posted - 09/20/2010 : 05:03:20 AM
Windows Vista
Origin 8.1

Hello,

is it possible to call special columns with their longnames?

in Laptalk I use the following code to plot this way:

plotxy iy:= [cool.dat]cool!((Time,lambda),(Time,lambda2)) ogl:=[Graph1]1! plot:=200;

in Origin C I tried this one (First example of code in Origin C):


DataRange dr;
dr.Add(wksDest2, Time, "X");
dr.Add(wksDest2, lambda, "Y");
dr.Add(wksDest2, lambda2, "Y");
GraphPage gp ("Graph1");
GraphLayer gl = gp.Layers(0);
gl.AddPlot(dr, IDM_PLOT_LINE);
legend_update(gl);
gp.SetShow();

Unfortunately it didn't work, so I tried another one (Second example of Code in Origin C):

for( int ii = 0; ii < wksDest2.GetNumCols() ; ii++ )
{
string strName;
wksDest2.Columns(ii).GetLongName();
strName = wksDest2.Columns(ii).GetLongName();

DataRange dr;
if(strName == "Time")
{
dr.Add(wksDest2, ii, "X");
}
if(strName == "lambda")
{
dr.Add(wksDest2, ii, "Y");
}
if(strName == "lambda2")
{
dr.Add(wksDest2, ii, "Y");
}
GraphPage gp ("Graph1");
GraphLayer gl = gp.Layers(0);
gl.AddPlot(dr, IDM_PLOT_LINE);
legend_update(gl);
gp.SetShow();
}

Now it works but Origin puts the legend to the center of the graph and doesn't give the second Y-Column a separate color. When I run the first example of code in Origin C with the number of the columns instead of their longnames it works properly (however this isn't possible in my case, I absolutely need the longnames).

Hope you can help me!


2   L A T E S T    R E P L I E S    (Newest First)
Chris2 Posted - 09/20/2010 : 06:27:41 AM
Thanks a lot! Works great!
Penn Posted - 09/20/2010 : 06:16:15 AM
Hi,

For the first example code:
There is no such prototype for DataRange::Add method like the way you used. You can take a look the existing three prototypes.

For the second example code:
You can try the following code first.

void test_DataRange()
{
	Worksheet wksDest2 = Project.ActiveLayer();
	DataRange dr;  // declare outside the for loop
	
	for( int ii = 0; ii < wksDest2.GetNumCols() ; ii++ )
	{
		string strName;
		wksDest2.Columns(ii).GetLongName();
		strName = wksDest2.Columns(ii).GetLongName();

		if(strName == "Time")
		{
			dr.Add(wksDest2, ii, "X");
		}
		if(strName == "lambda")
		{
			dr.Add(wksDest2, ii, "Y");
		}
		if(strName == "lambda2")
		{
			dr.Add(wksDest2, ii, "Y");
		}
	}
	
	// plot outside the for loop
	GraphPage gp ("Graph1");
	GraphLayer gl = gp.Layers(0);
	gl.AddPlot(dr, IDM_PLOT_LINE);
	legend_update(gl);
	gp.SetShow();
}

You can see that, I declare the DataRange and make the plot outside the for loop. The difference is that, the above code will make two plots as a grouped plot and will use the color increment, just as you highlight both columns and then make a graph, however, the code you used will make two plots in the graph layer separately, just as you highlight one column and plot it first, then add another plot to the graph layer.

Penn

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