plotting data against a time axis

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Gerrit Holl

    plotting data against a time axis

    Hi,

    I have a dictionairy containing DateTime objects as keys and integers as
    values. What would be the easiest way to create a simple plot of these,
    with a number axis versus a time axis? What library is the most
    suitable for this? 'plot' on parnassus yields 18 hits, but since I have
    zero experience, I don't know where to start. What makes it difficult
    is that I have a time axis instead of a simple integer x-axis. Gnuplot
    doesn't seem to be able to do this, or does it?

    I could, of course, write the data as a .csv, import it in OpenOffice
    and create a chart with OpenOffice, but I don't really see how to get
    OOffice to use the first column with iso dates as time axis, and I
    want to be able to do this automatically.

    yours,
    Gerrit Holl.

    --
    208. If he was a freed man, he shall pay one-third of a mina.
    -- 1780 BC, Hammurabi, Code of Law
    --
    Asperger Syndroom - een persoonlijke benadering:

    Kom in verzet tegen dit kabinet:
    De website van de Socialistische Partij (SP) in Nederland: Informatie, nieuws, agenda en publicaties.


  • Dennis Lee Bieber

    #2
    Re: plotting data against a time axis

    Gerrit Holl fed this fish to the penguins on Saturday 15 November 2003
    14:19 pm:
    [color=blue]
    > I have a dictionairy containing DateTime objects as keys and integers
    > as values. What would be the easiest way to create a simple plot of
    > these, with a number axis versus a time axis? What library is the most
    > suitable for this? 'plot' on parnassus yields 18 hits, but since I
    > have zero experience, I don't know where to start. What makes it
    > difficult is that I have a time axis instead of a simple integer
    > x-axis. Gnuplot doesn't seem to be able to do this, or does it?
    >[/color]

    Maybe I need to check the specs of the DateTime module, but most
    systems that work in dates usually store them internally in a linear
    format. Ignoring the /time/ aspect, a date could be stored in pseudo
    human readable format as an 8-digit integer -- yyyymmdd -- which sorts
    linearly, regardless of how it is formatted for display.

    IOW, time /is/ a integer (or, if using whole dates, a floating point
    with time of day as a fraction) counted from some epoch.

    At worst, take the earliest (time wise) date in your data as an epoch,
    and rebuild your dictionary using the delta from the epoch as the new
    key/index.

    --[color=blue]
    > =============== =============== =============== =============== == <
    > wlfraed@ix.netc om.com | Wulfraed Dennis Lee Bieber KD6MOG <
    > wulfraed@dm.net | Bestiaria Support Staff <
    > =============== =============== =============== =============== == <
    > Bestiaria Home Page: http://www.beastie.dm.net/ <
    > Home Page: http://www.dm.net/~wulfraed/ <[/color]

    Comment

    • Alexander Schmolck

      #3
      Re: plotting data against a time axis

      Gerrit Holl <gerrit@nl.linu x.org> writes:
      [color=blue]
      > Hi,
      >
      > I have a dictionairy containing DateTime objects as keys and integers as
      > values. What would be the easiest way to create a simple plot of these,
      > with a number axis versus a time axis? What library is the most
      > suitable for this? 'plot' on parnassus yields 18 hits, but since I have
      > zero experience, I don't know where to start. What makes it difficult
      > is that I have a time axis instead of a simple integer x-axis. Gnuplot
      > doesn't seem to be able to do this, or does it?[/color]
      [color=blue]
      > gnuplot[/color]

      G N U P L O T
      Version 3.8j patchlevel 0
      last modified Wed Nov 27 20:49:08 GMT 2002

      Terminal type set to 'x11'
      gnuplot> help time
      Ambiguous request 'time'; possible matches:
      time/date
      time_specifiers
      timefmt
      timestamp

      Not what you want?

      'as

      Comment

      • Paul McGuire

        #4
        Re: plotting data against a time axis

        "Dennis Lee Bieber" <wlfraed@ix.net com.com> wrote in message
        news:a6ui81-705.ln1@beastie .ix.netcom.com. ..[color=blue]
        > Maybe I need to check the specs of the DateTime module, but most
        > systems that work in dates usually store them internally in a linear
        > format. Ignoring the /time/ aspect, a date could be stored in pseudo
        > human readable format as an 8-digit integer -- yyyymmdd -- which sorts
        > linearly, regardless of how it is formatted for display.[/color]

        Ooops, not really. This trick will correctly *order* dates for sorting, but
        they wont ascend linearly. I think that you'll find big non-linear gaps
        between the last days of a month and the first day of the next:
        20031029
        20031030 (delta is 1)
        20031031 (delta is 1)
        20031101 (delta is 70)
        ....
        20031230
        20031231 (delta is 1)
        20040101 (delta is 8870!)

        [color=blue]
        > At worst, take the earliest (time wise) date in your data as an[/color]
        epoch,[color=blue]
        > and rebuild your dictionary using the delta from the epoch as the new
        > key/index.[/color]
        For the OP to get a nice scatter-plot, with linear time as the x-axis
        variable, this is what he/she will have to do. Simplest is to contrive an
        epoch with a starting day number (01/01/2000?), plus the time represented as
        a fraction of a whole day, (so that noon on day 17 will be represented as
        17.5, 6pm as 17.75, etc.)


        Comment

        • Dennis Lee Bieber

          #5
          Re: plotting data against a time axis

          Paul McGuire fed this fish to the penguins on Saturday 15 November 2003
          18:58 pm:

          [color=blue]
          > Ooops, not really. This trick will correctly *order* dates for
          > sorting, but[/color]

          Okay, okay... I did say "readable", whereas ddmmyyyy is all over the
          map <G>
          [color=blue]
          > For the OP to get a nice scatter-plot, with linear time as the x-axis
          > variable, this is what he/she will have to do. Simplest is to
          > contrive an epoch with a starting day number (01/01/2000?), plus the
          > time represented as a fraction of a whole day, (so that noon on day 17
          > will be represented as 17.5, 6pm as 17.75, etc.)
          >[/color]
          Or go to the astronomical format used for Julian date -- where noon is
          x.0 and midnight is x.5 (avoids having a 'day' change occur in the
          middle of observations -- unless, of course, you are observing sunspots
          <G>).

          My main interest was that I'd expect almost any time/date module to
          have /some/ sort of linear basis available for plotting purposes.

          --[color=blue]
          > =============== =============== =============== =============== == <
          > wlfraed@ix.netc om.com | Wulfraed Dennis Lee Bieber KD6MOG <
          > wulfraed@dm.net | Bestiaria Support Staff <
          > =============== =============== =============== =============== == <
          > Bestiaria Home Page: http://www.beastie.dm.net/ <
          > Home Page: http://www.dm.net/~wulfraed/ <[/color]

          Comment

          • Gerrit Holl

            #6
            Re: plotting data against a time axis

            Alexander Schmolck wrote:[color=blue]
            > Gerrit Holl <gerrit@nl.linu x.org> writes:[color=green]
            > > zero experience, I don't know where to start. What makes it difficult
            > > is that I have a time axis instead of a simple integer x-axis. Gnuplot
            > > doesn't seem to be able to do this, or does it?[/color]
            >[color=green]
            > > gnuplot[/color]
            >
            > G N U P L O T
            > Version 3.8j patchlevel 0
            > last modified Wed Nov 27 20:49:08 GMT 2002
            >
            > Terminal type set to 'x11'
            > gnuplot> help time
            > Ambiguous request 'time'; possible matches:
            > time/date
            > time_specifiers
            > timefmt
            > timestamp
            >
            > Not what you want?[/color]

            Hm, maybe it is, actually :). It seems my estimate was incorrect; to be
            fair, I assumed Gnuplot was used solely for plotting functions, not data.
            Maybe it is wise to invest some time in learning Gnuplot, I may be happy
            with it later as well.

            Thank you all (John, Alexander, Dennis, Paul) for the responses!

            Gerrit.

            --
            275. If any one hire a ferryboat, he shall pay three gerahs in money
            per day.
            -- 1780 BC, Hammurabi, Code of Law
            --
            Asperger Syndroom - een persoonlijke benadering:

            Kom in verzet tegen dit kabinet:
            De website van de Socialistische Partij (SP) in Nederland: Informatie, nieuws, agenda en publicaties.


            Comment

            • Alexander Schmolck

              #7
              Re: plotting data against a time axis

              Gerrit Holl <gerrit@nl.linu x.org> writes:
              [color=blue]
              > Alexander Schmolck wrote:[color=green]
              > > Gerrit Holl <gerrit@nl.linu x.org> writes:[color=darkred]
              > > > zero experience, I don't know where to start. What makes it difficult
              > > > is that I have a time axis instead of a simple integer x-axis. Gnuplot
              > > > doesn't seem to be able to do this, or does it?[/color]
              > >[color=darkred]
              > > > gnuplot[/color]
              > >
              > > G N U P L O T
              > > Version 3.8j patchlevel 0
              > > last modified Wed Nov 27 20:49:08 GMT 2002
              > >
              > > Terminal type set to 'x11'
              > > gnuplot> help time
              > > Ambiguous request 'time'; possible matches:
              > > time/date
              > > time_specifiers
              > > timefmt
              > > timestamp
              > >
              > > Not what you want?[/color]
              >
              > Hm, maybe it is, actually :). It seems my estimate was incorrect; to be
              > fair, I assumed Gnuplot was used solely for plotting functions, not data.
              > Maybe it is wise to invest some time in learning Gnuplot, I may be happy
              > with it later as well.[/color]

              I think it is well worthwhile.

              I used to regard gnuplot as a waste of time (because of its poor output
              quality and a number of bizzarre warts), and because I have matlab available
              for plotting (also from within python), which has very comprehensive
              functionality.

              However I came to appreciate that gnuplot is actually quite useful for quick
              and dirty plots, in particular from somewhat messy input files, because
              gnuplot helpfully just ignores stuff it can't regard as datapoints. Also its
              text based interface, although not perfect, is also far more effective than
              most GUI crap, once you got a slight hang of it and saving the plot results in
              a file of gnuplot commands which is easy to modify and/or to reuse. Finally
              gnuplot has the advantage of being quite ubiquitous and will presumably stay
              around for another couple of years.

              As a quick example, this will generate a 3D point plot from a text file (that
              amongst other things) contains point coordinates in 3 columns (2,3,4).

              gnuplot> splot 'locs.xyz' using 2:3:4 with points

              Than's to unique prefixes, you'd actually just have to type something like:

              gnuplot> sp 'locs.xyz' us 2:3:4 w p

              A final word of advice: I'd strongly recommend you track down version 3.8j (or
              latter, if already available) -- it has extremely useful enhancements such as
              zooming with mouse and decent 3d plots.

              'as

              Comment

              Working...