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
 LabTalk Forum
 Axis label tick - show only round numbers

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
alkamid Posted - 04/18/2010 : 07:06:27 AM
Origin Ver. and Service Release: OriginPro 8 SR3
Operating System: Ubuntu 9.04

Hello,

How to set axis ticks to only show round numbers, i.e. 0.5, 1.0, 1.5? I've created the top axis label with these commands:
layer.x.showaxes=3;
layer.x.showlabels=3;
layer.x2.label.formula$ = "1/x";

But it's showing numbers like 4.13, 1.77 whereas the bottom label shows "0.1, 0.2, 0.3" etc. In other words, on the top label I don't want equal distance between ticks but instead I'd like to see round numbers.
22   L A T E S T    R E P L I E S    (Newest First)
larry_lan Posted - 10/29/2010 : 12:57:11 AM
Hi:

Sorry for the delay.

It's a problem in Origin's side. Sorry about that. You can fix it by adding a pause after creating new axis. For example:

// Prepare data
int graph = 1;
string booknewn;
newbook result:=booknewn$;
wks.ncols = 4;
loop(i,1,2)
{
	wcol(i)=normal(100);
}
wcol(3)[1] = -2.1; wcol(4)[1] = 10;
wcol(3)[2] = 0.2; wcol(4)[2] = 100;
wcol(3)[3] = 1.8; wcol(4)[3] = 1000;
plotxy col(2);
// Your script
layer -s 1;
layer -n X2;

// Note Here
sec -p 1;
// End pause

layer$(graph+1).link=1;
range rg1 = [%(booknewn$)]sheet1!col(C);
layer$(graph+1).x2.ticksbydata$ = rg1;
laycopyscale igl:=1 dest:=$(graph+1) axis:=1;
layer$(graph+1).x2.label.formula$ = "1.239/x";
range rg2 = [%(booknewn$)]sheet1!col(D);
layer$(graph+1).x2.label.dataset$ = rg2;
layer$(graph+1).x2.label.type = 8;

Thanks
Larry
alkamid Posted - 10/19/2010 : 2:04:47 PM
Your code works weel so it's my problem here. Let's have a look at my code:
layer -s 1;
layer -n X2;
layer$(graph+1).link=1;
range rg1 = [%(booknewn$)]sheet1!col(C);
layer$(graph+1).x2.ticksbydata$ = rg1;
laycopyscale igl:=1 dest:=$(graph+1) axis:=1;
layer$(graph+1).x2.label.formula$ = "1.239/x";
range rg2 = [%(booknewn$)]sheet1!col(D);
layer$(graph+1).x2.label.dataset$ = rg2;
layer$(graph+1).x2.label.type = 8;


The variables are correct but maybe you can see a mistake? It's strange that the part with the first "range" command works:
range rg1 = [%(booknewn$)]sheet1!col(C);
layer$(graph+1).x2.ticksbydata$ = rg1;

While another doesn't.
larry_lan Posted - 10/19/2010 : 12:17:08 PM
Hi:

Could you please try the following script

newbook;
string strbkn$ = %H;
win -o strbkn$ {
wks.ncols = 4;
col(1) = {1, 2, 3};
col(2) = {1, 2, 3};
col(3) = {1.5, 2.5};
col(4) = {100, 1000};
plotxy iy:=col(2);
range r3 = [strbkn$]sheet1!col(3);
range r4 = [strbkn$]sheet1!col(4);
layer.x.ticksbydata$ = r3;
layer.x.label.dataset$ = r4;
layer.x.label.type = 8;
}


If you see two ticks in the graph, which was ticks in position 1.5 and 2.5, and labeled by 100, 1000. Then it means those command/properties works. And you should check/debug your project and script carefully, such as, were you working on an inactive worksheet, did you type the correct book/sheet name, etc ...

P.S, The latest version of Origin 8 is SR6. You can update it form "Help -> Check for Update".

Larry
alkamid Posted - 10/19/2010 : 11:46:23 AM
I think this time I'm doing exactly what you tell me to do but still - no luck. Maybe it's my Origin's version fault?
larry_lan Posted - 10/19/2010 : 11:05:53 AM
Range notation like [Book1]dat!G cannot assign to a labtalk property directly. Change the last two rows of script into

range rg = [book1]dat!col(G);
layer2.x2.label.dataset$ = rg;
layer2.x2.label.type = 8;


Larry
alkamid Posted - 10/19/2010 : 06:00:38 AM
Does it work for you? I switched the commands but it still doesn't work.
larry_lan Posted - 10/19/2010 : 05:56:32 AM
quote:
Originally posted by alkamid

Thank you. I invented this:
layer2.x2.ticksbydata$ = Book1_f;
laycopyscale igl:=1 dest:=2 axis:=1;
layer2.x2.label.formula$ = "1.239/x";
layer2.x2.label.type=8;
layer2.x2.label.dataset$=[Book1]dat!G;


But it doesn't change "type" to "tick-indexed dataset" and then it doesn't change the dataset.



Switch the last two script ...

Larry
alkamid Posted - 10/19/2010 : 04:41:16 AM
Thank you. I invented this:
layer2.x2.ticksbydata$ = Book1_f;
laycopyscale igl:=1 dest:=2 axis:=1;
layer2.x2.label.formula$ = "1.239/x";
layer2.x2.label.type=8;
layer2.x2.label.dataset$=[Book1]dat!G;


But it doesn't change "type" to "tick-indexed dataset" and then it doesn't change the dataset.
larry_lan Posted - 10/19/2010 : 03:55:15 AM
quote:
Originally posted by alkamid
- Make the scale on Layer2 the same as Layer1?


Please look for the layer.axis properties in our LabTalk help document.

quote:
- Change "type" to "Tick-indexed dataset"
- Set "Dataset" to "[Book1]dat!G"


Please look for the layer.axis.label properties in our LabTalk help document.
alkamid Posted - 10/19/2010 : 03:43:41 AM
They weren't! I feel we are approaching the end :-)

Now I have some questions regarding LabTalk commands. How to:
- Make the scale on Layer2 the same as Layer1?
- Change "type" to "Tick-indexed dataset"
- Set "Dataset" to "[Book1]dat!G"

I want to write a script which does it automatically so it would be perfect if there were commands.
larry_lan Posted - 10/19/2010 : 03:34:49 AM
Please verify if the X range for bottom and top X axis are the same (From, To).
alkamid Posted - 10/19/2010 : 03:17:50 AM
Ok, thank you. Now I'm going to try to the same with another layer and top X axis. With the same Workbook I create a new layer: (Linked) Top X.

Then I type:
layer2.x2.ticksbydata$ = Book1_f;


This is what I get:


What's wrong?
larry_lan Posted - 10/19/2010 : 02:53:41 AM
OK, sorry about that.

You need to ascending sort column F.

Thanks
Larry
alkamid Posted - 10/18/2010 : 06:11:24 AM
Larry, this is Polish locale (we use comma as decimal separator). Data range in A column is: 1.112547175551 to 0.210275239608.
larry_lan Posted - 10/18/2010 : 06:06:54 AM
The data in your column A range from 11010776175 to 1112547175551, while data in column F range from 0.413 to 0.826.

Please read my example carefully that layer.x.ticksbydata$ controls the POSITION of the ticks.

I guess you may need layer.y.ticksbydata$ = xxx.

Larry
alkamid Posted - 10/18/2010 : 05:42:26 AM
Thank you for your reply Larry.

Here's the book I'm working on: http://paste.pocoo.org/show/276895/
My X is col(A), my Y is col(E)

Now, when I type:
layer.x.ticksbydata$ = Bx_f;


...I get an empty X axis which is not exactly what I need:


Which part I'm not understanding? Should I place the tick data differently?
larry_lan Posted - 10/13/2010 : 6:56:34 PM
Well, if you add another column as the label value you want to show, you can use the Ticks indexed dataset option from Axis setting, Tick Labels tab, Type drop down.

The follow example shows how these option works:

1. The source data:



And Original plot is:



2. If I set layer.x.ticksbydata$ = book1_c, ticks will be shown on the position specified on column c (P.S: Maybe also need to set the Decimal Places on Tick Labels tab):



3. Then, if I set layer.x.label.formula$ = "1/x", it changed into:



Note that the ticks positions still placed on the value specified in column C.

4. Finally, If I go to the Tick Labels tab, and use values in column D as tick labels:



It became:



As you can see, the ticks still placed on the position in column 3, but shows values in column D.

Hope this will clarify the Origin ticks settings.

Thanks
Larry
OriginLab
alkamid Posted - 10/13/2010 : 2:05:53 PM
quote:
Originally posted by larry_lan
The property, layer.Axis.ticksbydata$ controls the POSITION of the ticks. Please check the data range and value in [Booky1]Sheet1!col(3).



Thank you for your reply. Does it mean that I have to place the values I want to be shown in the same row as corresponding X values? I placed it one by one in the first 10 rows.
larry_lan Posted - 10/13/2010 : 05:04:23 AM
Hi:

The property, layer.Axis.ticksbydata$ controls the POSITION of the ticks. Please check the data range and value in [Booky1]Sheet1!col(3).

However, layer.x2.label.formula$ doesn't change the position of the ticks, but change the LABEL of the ticks. In other word, it controls what to DISPLAY on the original ticks.

Hope this helps.

Larry
OriginLab Technical Services
alkamid Posted - 10/13/2010 : 01:40:31 AM
Anyone please? It's crucial to my script.
alkamid Posted - 10/09/2010 : 1:40:28 PM
Thank you for your reply.

I think I did everything according to the site you pointed me to:
- I created a new layer with an axis
- I created two additional columns (each 10 rows long) with tick data
- I used this command:
range xticks = [Booky1]Sheet1!col(3); 
layer4.x2.ticksbydata$=xticks;

- I changed the axis settings

Here's what I get:


This is not what I want (I want, of course, the ticks to be placed along the whole axis).

What am I doing wrongly?
easwar Posted - 04/18/2010 : 5:20:58 PM
Hi,

For rounded numbers this method of 2nd axis in same layer does not work...as the labels shown on 2nd axis are exactly at same position as the primary axis, so depending on formula the numbers may not show well.

See the 2nd method in this page for an alternate way, this involves a 2nd layer and datasets to specify desired label locations:
http://www.originlab.com/www/support/resultstech.aspx?ID=1116&language=English&Version=8

Easwar
OriginLab

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