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
 Origin Forum
 stack bars without good results
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

science2002

UK
Posts

Posted - 07/11/2006 :  07:22:13 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: WinXP

I am evaluation graph-stat products for University. One of the test under which I put also Origin is the following.
Classes:_______Lecturer1(hours):________Lecturer 2(hours):
macro_______________20______________________30
micro_______________40______________________50
literat._____________0______________________20

I need to show with stack bars that lecturer 1 (first stack bar) has 20+40 hours and the label of any piece of the bar should have the name of the classes. So the piece of the bar with height 20 should contain the text "macro".
I am not able to get the result. But I know that Origin is very powerful. Hope someone helps. Thanks
AQ

Hideo Fujii

USA
1582 Posts

Posted - 07/11/2006 :  11:54:49 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi AQ,

If you make the graph manually, you can make a stack
column plot (Plot:Special Bar/Column:Stack Column menu),
then you put text labels by the text tool.

If what you want is to make the graph automatically,
you will need a LabTalk script or OriginC program.
For example, the following script makes the sample graph
below:

///////////////////////////////////////////////
nr=wks.MaxRows;
nc=wks.nCols;
%K=%H;
For(jj=1;jj<=nc;jj++) wks.colsel(jj,1);
Worksheet -p 213;
For(ii=1;ii<=nr;ii++) {
hgt1=0; hgt2=0;
for(jj=2;jj<=nc;jj++) {
hgt1=(hgt2+%(%K,jj,ii)/2)*1.1;
hgt2=hgt2+%(%K,jj,ii);
Label -s -sa -j 1 -a ii hgt1 "\p130(\c18(%(%K,@C,jj)))";
}
}
Legend;
Layer.X.label.pt=30;
Label -s -sa -xb "\p130(%(%K,@C,1))";
%A=%K!wks.col1.label$;
Label -s -sa -yl "\p130(%A)";
doc -uw; clr;
///////////////////////////////////////////////



Go to Top of Page

science2002

UK
Posts

Posted - 07/11/2006 :  12:21:43 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
That's it, Fujii!
Thank you so much. I knew it was possibile but from what you showed me I need a bit (a lot) of learning.

The problem could not be solved (efficiently) with a manual text tool, because probably the data are not only the one I gave in the example, but are much more.
Where can one learn (or have a taste of) the programming language of Origin? Guide? Tutorials?
Thank you so much again. You have done a wonderful job. High points to Origin, though up to know it does not appear to be for novices.
AQ
Go to Top of Page

larry_lan

China
Posts

Posted - 07/11/2006 :  10:12:28 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi AQ:

There are help files on Origin programming folder \Help subfolder. And you can alse see the prgramming, tutorial helps from the 'Help' menu.

If you want to plot several graph with the same font and format setting, you can save the graph setting as theme (right click graph --> save format as theme), and then apply the theme to other plot (Format --> Theme gallery). Or save it as template. More information please see the "The Graph:Templates and Themes" section of Origin Help file.

If want to make the graph by programming, you can learn the Origin LabTalk script first from LabTalk.chm file (in the help folder) and then reference to Hideo's scripts.

Larry
OriginLab GZ Office
Go to Top of Page

science2002

UK
Posts

Posted - 07/12/2006 :  06:12:09 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
I could run also the Script. It works beautifully, with one little drawback: the label "liter" that is not present in the first column is there, though almost invisible because it is in white color. Is it possible to have the labels that are only needed for each column? [BTW the same drawback is also in Excel, and that was the reason I did not use Excel graphs.]
Go to Top of Page

Mike Buess

USA
3037 Posts

Posted - 07/12/2006 :  09:27:51 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Hi AQ,

Add the brown line to Hideo's script to suppress labels whose corresponding cell values are zero.

nr=wks.MaxRows;
nc=wks.nCols;
%K=%H;
For(jj=1;jj<=nc;jj++) wks.colsel(jj,1);
Worksheet -p 213;
For(ii=1;ii<=nr;ii++) {
hgt1=0; hgt2=0;
for(jj=2;jj<=nc;jj++) {
if( %(%K,jj,ii)==0 ) continue;
hgt1=(hgt2+%(%K,jj,ii)/2)*1.1;
hgt2=hgt2+%(%K,jj,ii);
Label -s -sa -j 1 -a ii hgt1 "\p130(\c18(%(%K, @C, jj)))";
}
}
Legend;
Layer.X.label.pt=30;
Label -s -sa -xb "\p130(%(%K, @C, 1))";
%A=%K!wks.col1.label$;
Label -s -sa -yl "\p130(%A)";
doc -uw; clr;

Mike Buess
Origin WebRing Member
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