From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Parker Subject: Re: org-babel and gnuplot Date: Wed, 8 Sep 2010 19:20:19 -0500 Message-ID: References: <4C870290.30701@ccbr.umn.edu> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1671442513==" Return-path: Received: from [140.186.70.92] (port=40595 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OtV82-0002II-RK for emacs-orgmode@gnu.org; Wed, 08 Sep 2010 20:36:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OtUsa-0006pG-Cq for emacs-orgmode@gnu.org; Wed, 08 Sep 2010 20:20:42 -0400 Received: from mail-vw0-f41.google.com ([209.85.212.41]:64809) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OtUsa-0006pA-3q for emacs-orgmode@gnu.org; Wed, 08 Sep 2010 20:20:40 -0400 Received: by vws16 with SMTP id 16so862016vws.0 for ; Wed, 08 Sep 2010 17:20:39 -0700 (PDT) In-Reply-To: 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: John Hendy Cc: emacs-orgmode@gnu.org --===============1671442513== Content-Type: multipart/alternative; boundary=e0cb4e8878118c3eb1048fc89915 --e0cb4e8878118c3eb1048fc89915 Content-Type: text/plain; charset=ISO-8859-1 John, Thanks for you're input, I'll give it a whirl. Nick Parker www.developernotes.com On Wed, Sep 8, 2010 at 2:04 PM, John Hendy wrote: > Nick, > > How about this?? Just fiddled around a little and wonder what you think. > There might be a better way, but essentially, I've done the following: > > - Left y-axis = distance > - Right y-axis = time > - I couldn't get the xtic(1) option to work, so I replaced things with what > I've found to work x:y:xticlabels(col#) > - Beefed up the points to make them a little easier to see > - Used your data to "calibrate" your speed > --- The left y-axis is from 9-21min > --- The right y-axis is from 1.5min - 3.5min > --- This means the axes are 'calibrated' to 10mph > > What does the "calibration" do? It means that at a quick glance you can see > your speed based on a target rate you set: > - if speed/distance are on top of each other, you're right at your target > - if speed (green) is higher than distance (red), you were faster than your > target > - if speed (green) is lower than distance (red), you were slower than your > target > > Resetting your target is as easy as changing (in the code below): > - Time: yrange [y1:y2] > - Distance: y2range [y3:y4] > > All you have to do is make sure that y3/y1 = y4/y2 = target speed > > Also, remove the references to L/R and Red/Green if you'd like from the > labels. I just tried to make the labels as easy as possible to follow so > that no matter where you looked for a reference you would be forced to see > what color/axis matched what value. > > I attached a sample graph. Sorry if I overstepped my bounds -- I realize > it's *your* workout tracker. Take what you like and ditch the rest. I > wanted to know how to do two different y axes anyway so it helped me learn. > Code is here: > > ------------------- gnuplot code ----------------------- > > #+tblname: sessions > | Date | ID | Time | Distance | > |-------------+----+-------+----------| > | 9/1/2010 | 1 | 14:00 | 2.4 | > | 9/2/2010 | 2 | 15:13 | 2.5 | > | 9/10/2010 | 3 | 13:45 | 2.3 | > | 9/11 | 4 | 12:20 | 2.0 | > | Spd > 10mph | 5 | 16:35 | 2.8 | > | Spd = 10mph | 6 | 10 | 1.666 | > | Spd < 10mph | 7 | 20 | 2.8 | > > #+begin_src gnuplot :var data=sessions :file org-running.png :exports both > reset > set title "Running Stats" > set size ratio square > > set xlabel "Date" > set xtics nomirror rotate by -45 > > set yrange [9:21] > set ylabel "Time (min) -- Red" > set ytics nomirror > > set y2range [1.5:3.5] > set y2label "Distance (mi) -- Green" > set y2tics 0,0.5,3.5 > > set style data points > plot data u 2:3:xticlabels(1) axis x1y1 lw 3 title 'Time (L axis)', \ > data u 2:4 axis x2y2 lw 3 title 'Distance (R axis)' > #+end_src > > ------------------- end gnuplot code --------------------- > > > Best regards, > John > > On Wed, Sep 8, 2010 at 11:52 AM, Nick Parker wrote: > >> John, >> >> I am reworking the gnuplot script, it is not done at this point, but this >> is what I currently have: >> >> #+begin_src gnuplot :var data=sessions :file org-running.png :exports both >> set title "Running Stats" >> set xtics nomirror rotate by -45 >> set key noenhanced >> set style data linespoints >> plot "$data" using 2:xtic(1) title columnheader(1), \ >> for [i=2:3] '' using i title columnheader(i) >> #+end_src >> >> Nick Parker >> www.developernotes.com >> >> >> On Wed, Sep 8, 2010 at 9:39 AM, John Hendy wrote: >> >>> Nick, >>> >>> >>> This got me curious to see the output. I tried to generate it on my >>> computer and get this in the *gnuplot* buffer after running the code: >>> >>> ----- >>> gnuplot> plot data using 1:2:3 notitle >>> ^ >>> warning: Skipping data file with no valid points >>> ^ >>> x range is invalid >>> ----- >>> >>> This is working for you, though? >>> >>> #+tblname: sessions >>> | Date | Time | Distance | >>> |------------+-------+----------| >>> | 09/02/2010 | 15:13 | 2.5 | >>> | 09/01/2010 | 14:00 | 2.4 | >>> >>> #+begin_src gnuplot :var data=sessions :file org-running.png :exports >>> both >>> set title "Running Stats" >>> set auto x >>> set style data histogram >>> set style fill solid border -1 >>> set boxwidth .9 >>> set xlabel "Date" >>> set ylabel "Time" >>> plot data using 1:2:3 notitle >>> #+end_src >>> >>> >>> John >>> >>> On Wed, Sep 8, 2010 at 8:10 AM, Nick Parker wrote: >>> >>>> Erik, >>>> >>>> That was the issue, the :file reference needed to be on the line above. >>>> Thanks. >>>> >>>> >>>> Nick Parker >>>> www.developernotes.com >>>> >>>> >>>> On Tue, Sep 7, 2010 at 10:27 PM, Erik Iverson wrote: >>>> >>>>> On 09/07/2010 10:12 PM, Nick Parker wrote: >>>>> >>>>>> Hi John, >>>>>> >>>>>> I would actually like to plot different lines per distance, each >>>>>> that correlate to a date and elapsed-time (x and y axis respectively). >>>>>> I get an error with the :file notation, though I read that in a >>>>>> sample >>>>>> babel gnuplot example for generating graphs of commit history on the >>>>>> org-mode git repository. I tried to reference the variable data >>>>>> without >>>>>> the quotes and $ sign without any success. I will continue to fiddle >>>>>> with it, I am new to gnuplot. >>>>>> >>>>> >>>>> AFAIK, you can't break source code header argument lines across >>>>> multiple lines. Is that how you actually have it in your >>>>> org file? >>>>> >>>>> >>>>> #+begin_src gnuplot :var data=sessions >>>>>> :file org-running.png :exports both >>>>>> set title "Running Stats" >>>>>> set auto x >>>>>> set style data histogram >>>>>> set style fill solid border -1 >>>>>> set boxwidth .9 >>>>>> set xlabel "Date" >>>>>> set ylabel "Time" >>>>>> plot "$data" using 1:2:3 notitle >>>>>> #+end_src >>>>>> >>>>>> Nick Parker >>>>>> www.developernotes.com >>>>>> >>>>>> >>>>>> _______________________________________________ >>>>>> 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 >>>>>> >>>>> >>>>> >>>> >>> >> > --e0cb4e8878118c3eb1048fc89915 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable John,

Thanks for you're input, I'll give it a wh= irl.

Nick Parker
www.developernotes.com


On Wed, Sep 8, 2010 at 2:04 PM, John Hen= dy <jw.hendy@gma= il.com> wrote:
Nick,

How about this?? Just fiddled around a little and = wonder what you think. There might be a better way, but essentially, I'= ve done the following:

- Left y-axis =3D distance<= /div>
- Right y-axis =3D time
- I couldn't get the xtic(1) opt= ion to work, so I replaced things with what I've found to work x:y:xtic= labels(col#)
- Beefed up the points to make them a little easier = to see
- Used your data to "calibrate" your speed
--- The= left y-axis is from 9-21min
--- The right y-axis is from 1.5min = - 3.5min
--- This means the axes are 'calibrated' to 10mp= h

What does the "calibration" do? It means that= at a quick glance you can see your speed based on a target rate you set:
- if speed/distance are on top of each other, you're right at = your target
- if speed (green) is higher than distance (red), you were faster than= your target
- if speed (green) is lower than distance (red), you= were slower than your target

Resetting your targe= t is as easy as changing (in the code below):
- Time: yrange [y1:y2]
- Distance: y2range [y3:y4]

All you have to do is make sure that y3/y1 =3D y4/y2 =3D ta= rget speed

Also, remove the references to L/R and = Red/Green if you'd like from the labels. I just tried to make the label= s as easy as possible to follow so that no matter where you looked for a re= ference you would be forced to see what color/axis matched what value.

I attached a sample graph. Sorry if I overstepped my bo= unds -- I realize it's your=A0workout tracker. Take what you lik= e and ditch the rest. I wanted to know how to do two different y axes anywa= y so it helped me learn. Code is here:

------------------- gnuplot code ----------------------= -

#+tblname: sessions
| Date = =A0 =A0 =A0 =A0| ID | =A0Time | Distance |
|-------------+----+--= -----+----------|
| 9/1/2010 =A0 =A0| =A01 | 14:00 | =A0 =A0 =A02.4 |
| 9/2/20= 10 =A0 =A0| =A02 | 15:13 | =A0 =A0 =A02.5 |
| 9/10/2010 =A0 | =A0= 3 | 13:45 | =A0 =A0 =A02.3 |
| 9/11 =A0 =A0 =A0 =A0| =A04 | 12:20= | =A0 =A0 =A02.0 |
| Spd > 10mph | =A05 | 16:35 | =A0 =A0 =A0= 2.8 |
| Spd =3D 10mph | =A06 | =A0 =A010 | =A0 =A01.666 |
| Spd &l= t; 10mph | =A07 | =A0 =A020 | =A0 =A0 =A02.8 |

#+begin_src gnuplot :var data=3Dsessions :file org-run= ning.png :exports both
=A0=A0reset
=A0=A0set title "Running Stats"
=A0=A0set size rat= io square
=A0=A0
=A0=A0set xlabel "Date"
=A0=A0set xtics nomirror rotate by -45
=A0=A0set yrange [9:21]
=A0=A0set ylabel "Time (min) -- Red"
=A0=A0set yti= cs nomirror

=A0=A0set y2range [1.5:3.5]
= =A0=A0set y2label "Distance (mi) -- Green"
=A0=A0set y2= tics 0,0.5,3.5

=A0=A0set style data points
=A0=A0plot data u= 2:3:xticlabels(1) axis x1y1 lw 3 title 'Time (L axis)', \
=A0=A0 =A0 =A0 data u 2:4 axis x2y2 lw 3 title 'Distance (R axis)'= ;
#+end_src

------------------- end gnuplot code --------= -------------


Best regards,
John

On Wed, Sep 8, 2010 at 11:52 AM, Nick Parker <nickp@developernotes= .com> wrote:
John,

I am reworking the = gnuplot script, it is not done at this point, but this is what I currently = have:

#+begin_src gnuplot :var data=3Dsessions :fil= e org-running.png :exports both
=A0=A0set title "Running Stats"
=A0=A0set xt= ics nomirror rotate by -45
=A0=A0set key noenhanced
=A0= =A0set style data linespoints
=A0=A0plot "$data" using = 2:xtic(1) title columnheader(1), \
=A0=A0for [i=3D2:3] '' using i title columnheader(i)
#+end_src

Nick Parker
www.developernotes.com


On Wed, Sep 8= , 2010 at 9:39 AM, John Hendy <jw.hendy@gmail.com> wrote:
Nick,


This got me curious to see the outp= ut. I tried to generate it on my computer and get this in the *gnuplot* buf= fer after running the code:

-----
gnuplot> plot data using 1:2:3 notitle
=A0=A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ^
=A0=A0 =A0 =A0 =A0 warn= ing: Skipping data file with no valid points
=A0=A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0^
=A0= =A0 =A0 =A0 =A0 x range is invalid
-----

This is working for you, though?
<= br>
#+tblname: sessions
| Date =A0 =A0 =A0 | = =A0Time | Distance |
|------------+-------+----------|
| 09/02/2010 | 15:13 | =A0 =A0 =A02.5 |
| 09/01/2010 | 14:00 | =A0 =A0 =A02.4 |

#+begin_src gnuplot :var data=3Dsessions :file org-running.png :expor= ts both
=A0=A0set title "Running Stats"
=A0= =A0set auto x
=A0=A0set style data histogram
=A0=A0set style fill solid border -1
=A0=A0set boxwidth .9
=A0=A0set xlabel "Date"
=A0=A0set ylabel "= ;Time"
=A0=A0plot data using 1:2:3 notitle
#+end_s= rc


John
On Wed, Sep 8, 2010 at 8:10 AM, Nick Parker <nickp@developernotes.com> wrote:
Erik,

That was the issue,= the :file reference needed to be on the line above. =A0Thanks.
On Tue, Sep 7= , 2010 at 10:27 PM, Erik Iverson <eriki@ccbr.umn.edu> wrote= :
On 09/07/2010 10:12 PM, Nick Parker wrote:
Hi John,

I would actually like to plot different lines per distance, each
that correlate to a date and elapsed-time (x and y axis respectively).
=A0I get an error with the :file notation, though I read that in a sample<= br> babel gnuplot example for generating graphs of commit history on the
org-mode git repository. =A0I tried to reference the variable data without<= br> the quotes and $ sign without any success. =A0I will continue to fiddle
with it, I am new to gnuplot.

AFAIK, you can't break source code header argument lines across
multiple lines. =A0Is that how you actually have it in your
org file?


=A0 =A0 =A0 =A0#+begin_src gnuplot :var data=3Dsessions
=A0 =A0 =A0 =A0 =A0 :file org-running.png :exports both
=A0 =A0 =A0 =A0 =A0 set title "Running Stats"
=A0 =A0 =A0 =A0 =A0 set auto x
=A0 =A0 =A0 =A0 =A0 set style data histogram
=A0 =A0 =A0 =A0 =A0 set style fill solid border -1
=A0 =A0 =A0 =A0 =A0 set boxwidth .9
=A0 =A0 =A0 =A0 =A0 set xlabel "Date"
=A0 =A0 =A0 =A0 =A0 set ylabel "Time"
=A0 =A0 =A0 =A0 =A0 plot "$data" using 1:2:3 notitle
=A0 =A0 =A0 =A0#+end_src

=A0 =A0 =A0 =A0Nick Parker
=A0 =A0 =A0 =A0www.developernotes.com <http://www.developernotes.com>


=A0 =A0 =A0 =A0_______________________________________________
=A0 =A0 =A0 =A0Emacs-orgmode mailing list
=A0 =A0 =A0 =A0Please use `Reply All' to send replies to the list.
=
=A0 =A0 =A0 =A0= Emacs-orgmode@gnu.org <mailto:Emacs-orgmode@gnu.org>






--e0cb4e8878118c3eb1048fc89915-- --===============1671442513== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ 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 --===============1671442513==--