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

symcel

Sweden
Posts

Posted - 02/19/2007 :  05:41:30 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (Select Help-->About Origin): 7.5
Operating System: XP

I'd like to create 48 error bars with names A1, B1, ... F8

Now I have a worksheet with columns A1 ... F8 and I have written a C function that calculates the mean value of all rows for each column. I have also calculated the standard error for each column.

So could you give me some hints what I should do to create 48 column showing the mean value and the standard error I already have calculated?

Thanks!

symcel

Sweden
Posts

Posted - 02/19/2007 :  08:05:19 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I now have a workspace with three columns
No 1 contains the column names (A1...F8)
No 2 the mean values
No 3 the standard error

Just need to igure out how to create the column bars now...
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 02/19/2007 :  08:18:27 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
If you're asking how to set the third column as yEr use this...

Worksheet wks = Project.ActiveLayer(); // active wks
wks.Columns(2).SetType(OKDATAOBJ_DESIGNATION_ERROR);

Mike Buess
Origin WebRing Member
Go to Top of Page

symcel

Sweden
Posts

Posted - 02/19/2007 :  08:59:57 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hmm, my table looks something like this now:

A1 2,86009 2,54687
B1 -1,9127 0,85824
C1 3,35497 2,88728
D1 6,14112 4,76
.
.
.
F8 5,3623 2.525

What I want to do now is to create a graph with 48 columns. I can do this from Origin like this:
1. Select column 1 whith my mean values
2. Plot->Column (which creates the columns A1 to F8)
3. Graph->Add Error bars (which should use the standard error in column 3 in my workspace)

But I haven't been able to figure out how to do this in Origin C. Have tried this code:

GraphPage gp = Project.GraphPages("Graph1");
if(gp)
{
GraphLayer lay = gp.Layers(1);

if (lay)
{
Curve cc(*pErrWsp, 0, 1);
Column colErrBar(*pErrWsp, 2);
int nPlotIndex = lay.AddErrBar(cc, colErrBar);
lay.Rescale();

out_int("nPlotIndex = ", nPlotIndex);
}
}

In the debugger I can see that the cc object doesn't seem to like strings (A1 to F8) in the first column. But even if I try to use the numbers 1 to 48 in stead it doesn't seem to create the columns, just error bars.
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 02/19/2007 :  10:28:27 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Try this...

Worksheet wks("Data2");
if( !wks ) return;
GraphPage gp("Graph1");
if( !gp ) return;
GraphLayer gl = gp.Layers(0); // layer 1!!
Curve cc(wks,0,1);
gl.AddPlot(cc); // plot Y
Column cerr(wks,2);
gl.AddErrBar(cc,cerr); // add error bars
gl.Rescale();

Mike Buess
Origin WebRing Member
Go to Top of Page

symcel

Sweden
Posts

Posted - 02/19/2007 :  10:45:49 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks Mike,

AddPlot solved my problems (I actually wanted to use the second layer).

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