From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: Plotting (with gnuplot) using dates timestamps Date: Mon, 26 Mar 2012 10:37:12 -0400 Message-ID: <27136.1332772632@alphaville> References: <1332770878.2404.3.camel@ascraeus> Reply-To: nicholas.dokos@hp.com Return-path: Received: from eggs.gnu.org ([208.118.235.92]:56458) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SCB2w-0004ps-Ut for emacs-orgmode@gnu.org; Mon, 26 Mar 2012 10:37:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SCB2v-0003iR-5B for emacs-orgmode@gnu.org; Mon, 26 Mar 2012 10:37:22 -0400 Received: from g4t0016.houston.hp.com ([15.201.24.19]:8418) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SCB2s-0003hE-Cj for emacs-orgmode@gnu.org; Mon, 26 Mar 2012 10:37:21 -0400 Received: from g4t0009.houston.hp.com (g4t0009.houston.hp.com [16.234.32.26]) by g4t0016.houston.hp.com (Postfix) with ESMTP id 18745141EF for ; Mon, 26 Mar 2012 14:37:16 +0000 (UTC) In-Reply-To: Message from Steven Buczkowski of "Mon, 26 Mar 2012 10:07:58 EDT." <1332770878.2404.3.camel@ascraeus> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: emacs-orgmode Mode Cc: nicholas.dokos@hp.com Steven Buczkowski wrote: > On Mon, 2012-03-26 at 15:37 +0200, Alan Schmitt wrote: > > Hello, > > > > I'm trying to plot the following table, but the dates part is all wrong. Is there a way to tell gnuplot what the date format is? > > > > #+tblname: data-table > > | Date | HP | HC | > > |------------------+--------+--------| > > | [2011-08-20 Sat] | 006815 | 008399 | > > | [2011-08-29 Mon] | 006840 | 008438 | > > | [2011-09-11 Sun] | 006946 | 008552 | > > | [2011-12-11 Sun] | 007805 | 009603 | > > | [2012-03-04 Sun] | 008800 | 010826 | > > | [2012-03-11 Sun] | 008876 | 010930 | > > | [2012-03-25 Sun] | 009015 | 011121 | > > > > In straight gnuplot, I would do something like the following: > > gnuplot> set xdata time > gnuplot> set timefmt '[%Y-%m-%d %a]' > The "set xdata time" line is indeed what makes the difference: without it, gnuplot doesn't know that this is a time series. But there are some additional details: when babel prepares the data, the data file that will be fed to gnuplot ends up like this (not sure this is documented though): ,---- | 2011-08-20-00:00:00 6815 8399 | 2011-08-29-00:00:00 6840 8438 | 2011-09-11-00:00:00 6946 8552 | 2011-12-11-00:00:00 7805 9603 | 2012-03-04-00:00:00 8800 10826 | 2012-03-11-00:00:00 8876 10930 | 2012-03-25-00:00:00 9015 11121 `---- so the script should look something like this: --8<---------------cut here---------------start------------->8--- reset set xdata time set timefmt "%Y-%m-%d-%H:%M:%S" set format x "%Y-%m-%d" set xrange ["2011-08-01":"2012-04-01"] set title "Consumption" set size ratio square set xlabel "Date" set yrange [6800:9100] set ylabel "HP" set ytics nomirror set y2range [8000:12000] set y2label "HC" set y2tics nomirror set style data points plot data using 1:2 axis x1y1 title 'HP', \ data using 1:3 axis x1y2 title 'HC' --8<---------------cut here---------------end--------------->8--- BTW, going into gnuplot and saying "help time/date" helps :-) I have trouble navigating the gnuplot help system, but I think it is complete. Nick