(none) imager-devel
/ help / lists / applications / search /
 

Re: Tick label with Imager::Plot

From: Etienne Goyer (
06637@xyz.molar.is)
Date: Tue 07 Jan 2003 - 15:06:13 GMT

  • Next message: Arnar Mar Hrafnkelsson: "Vacation + relocation"

    I found the answer to my question. I am posting it here in the hope it
    could be useful for somebody else.

    %opts{"Xformat"} in Imager::Plot::Axis as a reference to function that
    is executed on each tick label before being rendered. To access it thru
    your Imager::Plot object (thanks, Data::Dumper) :

        $graph->{'AXIS'}{'Xformat'} = sub {
            my @ticks = localtime(shift);
            return sprintf("%02d:%02d:%02d %d/%d/%02d",
                $ticks[2], $ticks[1], $ticks[0], $ticks[3], $ticks[4] + 1,
                $ticks[5] > 99 ? substr($ticks[5], 2, 2) : $ticks[5]);
        };

    where $graph is your Imager::Plot object.
      
    On Mon, Jan 06, 2003 at 02:23:23PM -0500, Etienne Goyer wrote:
    > Hi,
    >
    > I am using Imager::Plot to plot some data. I would like to change the
    > tick label on the X axis. The doc hint to it but I can't find details
    > or example.
    >
    > Here is my problem : I have some data for which the X value is a Unix
    > timestamp. Obviously, "1041534900" is not telling much to the user.
    > Saying "Jan 2 2003 14:05:00" would be much more appropriate. So what I
    > wuld like is a way to tell my Imager::Plot object that "1041534900"
    > should be labelled as "Jan 2 2003 14:05:00" instead.
    >
    > As usual, an example is worth a thousand man page ! :)
    >
    > Thanks for your help. So far, I must say that Imager::Plot is the best
    > module I found on CPAN for plotting. At least, it's the one producing
    > the nicest graph, so I look forward to solving this issue.
    >
    > --
    > Etienne Goyer Linux Québec Technologies Inc.
    > http://www.LinuxQuebec.com 06637@xyz.molar.is
    > PGP Pub Key: http://www.LinuxQuebec.com/pubkeys/eg.key
    > Fingerprint: F569 0394 098A FC70 B572 5D20 3129 3D86 8FD5 C853
    >
    >

    -- 
    Etienne Goyer                    Linux Québec Technologies Inc.
    http://www.LinuxQuebec.com       06637@xyz.molar.is
    PGP Pub Key: http://www.LinuxQuebec.com/pubkeys/eg.key 
    Fingerprint: F569 0394 098A FC70 B572  5D20 3129 3D86 8FD5 C853 
    



  •