From mboxrd@z Thu Jan 1 00:00:00 1970 From: Dan Davison Subject: Re: Plotting date on xaxis Date: Tue, 23 Feb 2010 12:15:44 -0500 Message-ID: <87vddnzxdr.fsf@stats.ox.ac.uk> References: <417457b51002221031k48e2470aof86f6b6e71ea454b@mail.gmail.com> <87zl30c6zn.fsf@gmail.com> <417457b51002230827w555d345dg98fbbea5c0091a36@mail.gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Return-path: Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NjyMT-0004nY-P7 for emacs-orgmode@gnu.org; Tue, 23 Feb 2010 12:15:53 -0500 Received: from [140.186.70.92] (port=43943 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NjyMS-0004me-KN for emacs-orgmode@gnu.org; Tue, 23 Feb 2010 12:15:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1NjyMR-0000JU-Fu for emacs-orgmode@gnu.org; Tue, 23 Feb 2010 12:15:52 -0500 Received: from markov.stats.ox.ac.uk ([163.1.210.1]:54413) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1NjyMR-0000JI-8g for emacs-orgmode@gnu.org; Tue, 23 Feb 2010 12:15:51 -0500 In-Reply-To: <417457b51002230827w555d345dg98fbbea5c0091a36@mail.gmail.com> (Johan Ekh's message of "Tue, 23 Feb 2010 17:27:13 +0100") List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org To: Johan Ekh Cc: emacs-orgmode@gnu.org Johan Ekh writes: > Thanks guys, > the babel version worked perfect so I didn't try the other one thanks! > Would it be possible to use python and matplotlib with babel instead of > gnuplot? > If so, could you just indicate how such a src code block would look like? Hi Johan, I've never used matplotlib, but here's a start. Firstly, one thing I notice is that org-babel-python currently doesn't like the column names on the table (I'll add it to our TODO list). So if we make a table like this, without the header: #+results: my-table-nohdr | 2010-02-21 | 95.0 | | 2010-02-22 | 93.0 | | 2010-02-23 | 92.0 | | 2010-02-24 | 91.5 | | 2010-02-25 | 91.0 | | 2010-02-26 | 92.0 | Then pass the data into python and have a look at what we've got: #+begin_src python :var data=3Dmy-table-nohdr :results output print str(data) #+end_src #+results: : [['2010-02-21', 95.0], ['2010-02-22', 93.0], ['2010-02-23', 92.0], ['2010= -02-24', 91.5], ['2010-02-25', 91.0], ['2010-02-26', 92.0]] So if you know how to use matplotlib to create your plot using that list of lists, then you should be set. To get output to file you will need to use something like :file pyplot.png, *and* arrange that your code writes the graphical output to pyplot.png. A link to pyplot.png will be inserted in the org buffer. Given my ignorance of gnuplot and matplotlib, I would use R. Unlike python, but like gnuplot, the graphical output is automatically sent to the specified file, without having to explicitly tell R to so so: #+begin_src R :var d=3Dmy-table :file R-plot.png plot(as.Date(d$Date), d$Kg, ylab=3D"Kg", type=3D"b") #+end_src #+results: [[file:R-plot.png]] Dan > > Babel seems super cool! > > /Johan > > On Tue, Feb 23, 2010 at 3:47 PM, Eric Schulte wr= ote: > > Hi Johan, > > You could try plotting your table using standard org-mode date formats > which org-plot will understand without any need to specify a timefmt > string. > > #+PLOT: title:"Weight" ind:1 deps:(2) type:2d with:linespo set:"xdata= time" > set:"yrange [90:]" > | Date =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 | =C2=A0 Kg | > |------------------+------| > | <2010-02-21 Sun> | 95.0 | > | <2010-02-22 Mon> | 93.0 | > | <2010-02-23 Tue> | 92.0 | > | <2010-02-24 Wed> | 91.5 | > | <2010-02-25 Thu> | 91.0 | > | <2010-02-26 Fri> | 92.0 | > > Alternatively if you want more control over your plots and more direct > access to gnuplot you can use org-babel to pass your table directly to > gnuplot as follows. > > #+results: my-table > | =C2=A0 =C2=A0 =C2=A0 Date | =C2=A0 Kg | > |------------+------| > | 2010-02-21 | 95.0 | > | 2010-02-22 | 93.0 | > | 2010-02-23 | 92.0 | > | 2010-02-24 | 91.5 | > | 2010-02-25 | 91.0 | > | 2010-02-26 | 92.0 | > > #+begin_src gnuplot :var data=3Dmy-table > =C2=A0set xdata time > =C2=A0set timefmt '%Y-%m-%d' > =C2=A0set yrange [90:] > =C2=A0plot data using 1:2 with linespoints title 'Kg' > #+end_src > > Best -- Eric > > Johan Ekh writes: > > > Hi all, > > I try to plot a table looking like this > > > > =C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 Date= =C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0 Kg | > > =C2=A0=C2=A0=C2=A0=C2=A0 |-----------------+--------| > > =C2=A0=C2=A0=C2=A0=C2=A0 | 2010-02-21 | 95.0 | > > =C2=A0=C2=A0=C2=A0=C2=A0 | 2010-02-22 | 93.0 | > > =C2=A0=C2=A0=C2=A0=C2=A0 | 2010-02-23 | 92.0 | > > =C2=A0=C2=A0=C2=A0=C2=A0 | 2010-02-24 | 91.5 | > > =C2=A0=C2=A0=C2=A0=C2=A0 | 2010-02-25 | 91.0 | > > =C2=A0=C2=A0=C2=A0=C2=A0 | 2010-02-29 | 92.0 | > > =C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2= =A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 | =C2=A0 = =C2=A0=C2=A0=C2=A0=C2=A0 | > > > > with the dates on the xaxis using > > > > #+PLOT: title:"Weight" ind:1 deps:(2) type:2d with:linespo set:"xda= ta > time" timefmt:%Y-%m-%d > > set:"yrange [90:]" > > > > but no plot is generated. If I remove , the plot = is > generated but without > > interpreting the dates as dates. > > > > Can anyone see what I do wrong? > > > > Thanks in advance, > > > > Johan > > > > _______________________________________________ > > Emacs-orgmode mailing list > > Please use `Reply All' to send replies to the list. > > Emacs-orgmode@gnu.org > > http://lists.gnu.org/mailman/listinfo/emacs-orgmode > > > _______________________________________________ > Emacs-orgmode mailing list > Please use `Reply All' to send replies to the list. > Emacs-orgmode@gnu.org > http://lists.gnu.org/mailman/listinfo/emacs-orgmode