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
 plot fraction of timetable
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic Lock Topic Edit Topic Delete Topic New Topic Reply to Topic

Mane07

USA
Posts

Posted - 10/29/2005 :  07:58:44 AM  Show Profile  Edit Topic  Reply with Quote  View user's IP address  Delete Topic
Origin Version (7.5 pro):
Operating System: XP

Hello
Being a newbie to OriginLap Im wondering if someone could give me an advice.

I have a data pair Price(y) against Time (x) and a second pair StartTime (x) and EndTime(x).
What Im trying to do is the following:
I like to plot fractions of the Price vs. Time table, divined by StartTime and EndTime on top of each other.
Any advise how I can do that and where I can find useful information regarding this task?

Thanks

To make things easier to understand...

My Data

What I like to achieve:

Mike Buess

USA
3037 Posts

Posted - 10/29/2005 :  3:01:38 PM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Looks to me like your graphs plot price change since Start Time versus number of days since Start Time. If that's the case then the following procedure might work...

1. Select Tools > Options > Miscellaneous tab and enter the following for one of the Custom Date Formats...

dd'.'MM'.'yyyy

2. Delete the first row in your price worksheet. (I transferred that row to the corresponding column labels in Data22 below. Prices in Data22 are random numbers between 1 and 2.)

3. Double-click on each of the time columns (A, D and E in Data22) and set Format to Date and Display to the custom format you created.

4. Copy the following labtalk script, paste it to your script window and execute by selecting all lines of script and pressing Enter. Alternatively, you can run the script from the Custom Routine button as described here...
http://www.originlab.com/www/support/resultstech.aspx?ID=769&language=English

The script copies the prices in each time range to separate Y columns in a new worksheet (Data25 below), subtracts the first price in each column from all values in that column and creates an X column for days elapsed. (I have ignored the weekend gaps which therefore count as zero days.) Finally, all Y columns are plotted as in Graph4 at the bottom. If the graph legend is too large you can delete it by replacing the last line of the script with label -r legend; If you want the fractional, rather than absolute, price changes insert the command %(%H,wks.ncols)/=xx; after %(%H,wks.ncols)-=xx; in the loop.

# Script starts here
%W=%H; // save name of starting wks
get col(4) -e nn; // how many date ranges?
win -t D; // create new wks
del col(2); // delete Y column
loop (ii,1,nn)
{
xx1=%W!cell(ii,4); // Start time
xx2=%W!cell(ii,5); // End time
ii1=xindex(xx1,%(%W,2)); // Start index
ii2=xindex(xx2,%(%W,2)); // End index
ii3=ii2-ii1+1; // days in range
%A=$(xx1,D0);
%A=%[%A,#2,/].%[%A,#1,/].%[%A,#3,/];
%B=$(xx2,D0);
%B=%[%B,#2,/].%[%B,#1,/].%[%B,#3,/];
%Z=%A - %B; // this will be column label
wks.addCol(); // add Y column
wks.col$(wks.ncols).label$=%Z; // label it
copy -b ii1 %(%W,2) %(%H,wks.ncols) -b 1 -e ii3; // copy prices
xx=%H!cell(1,wks.ncols);
%(%H,wks.ncols)-=xx; // subtract initial price
};
wks.labels(); // show labels
wks.col1.label$=Days; // X axis label
col(1)=data(1,wks.maxrows); // X axis values
wo -s 0 0 0 0; // select entire wks
wo -p 200; // plot in new graph
lay -a; // rescale
layer.x.atzero=1; // create line at Y=0
xb.text$=Days; // X axis title
yl.text$=Price Change; // Y axis title
legend; // create legend

Starting worksheet:


Sorted worksheet:


Graph of sorted worksheet:


Mike Buess
Origin WebRing Member

Edited by - Mike Buess on 10/29/2005 3:41:42 PM

Edited by - Mike Buess on 10/29/2005 4:26:38 PM
Go to Top of Page

Mane07

USA
Posts

Posted - 10/31/2005 :  06:58:01 AM  Show Profile  Edit Reply  Reply with Quote  View user's IP address  Delete Reply
Thanks a lot

It's probably going to take me a while to understand all this in detail

Greetings mane
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