Hi Mark, I use time series a little differently but I believe the suggestion to 
me would work for you as well. Put the time data in terms of epoch seconds. 
Then they can be treated as a numerical structure for which PDL was designed - 
i.e. performing any matrix operations. I don't know of an easy way to go 
between a date-time model and the epoch seconds for display. 
 
Thanks, Cliff.

-----Original Message-----
From: Mark Grimes [mailto:[email protected]] 
Sent: April 26, 2013 9:07 AM
To: [email protected]
Subject: [Perldl] Graphing Date Series

Hi all,

I am somewhat new to PDL, but I love Perl and am looking to use Perl/PDL for 
some statistical/machine learning based financial analysis. I've seen lot's of 
code in Python and R for these purposes, but not much yet for Perl/PDL. I hope 
to correct that!

Anyway, one stumbling block has been graphing date/time series. There are a 
bunch of good graphing options for PDL, but I have not been able to figure out 
how put dates on the x-axis for any of them. So far I have been gravitating 
towards PLplot, but I like Prima and am certainly not committed to anything yet.

I did see some documentation refering to "pltimefmt", but I really don't know 
where to start with that.

Just to be complete, here is a snippet of code. Ideally, $x would be a list of 
dates:

sub plot_returns {
    my ( $values, $mkt_values ) = @_;

    my $pl = PDL::Graphics::PLplot->new( DEV => "xwin", );
    my $x = sequence( nelem($values) );

    my $returns     = $values / $values->(0) - 1;
    my $mkt_returns = $mkt_values / $mkt_values->(0) - 1;
    $pl->xyplot(
        $x, $returns,
        TITLE    => 'Portfolio Return',
        XBOX     => 'anst',
        COLOR    => 'BLUE',
        CHARSIZE => 0.75,
        YLAB     => 'Returns',
        BOX      => [ $x->minmax, cat( $returns, $mkt_returns )->minmax ],
    );
    $pl->xyplot( $x, $mkt_returns, COLOR => 'BLACK', );
    $pl->close;
}

Thanks,
Mark

_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl

_______________________________________________
Perldl mailing list
[email protected]
http://mailman.jach.hawaii.edu/mailman/listinfo/perldl

Reply via email to