From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nick Dokos Subject: Re: gnuplot question - "Specify an entire line to be inserted in the Gnuplot script." Date: Fri, 29 Jul 2011 19:41:54 -0400 Message-ID: <7421.1311982914@alphaville.americas.hpqcorp.net> References: <105B4AC5-3799-4715-8F1E-5D3F6A1F4450@gilbert.org> <87tya4j242.fsf@gmail.com> <7C3F7CA1-A957-4D18-9EEB-B2E6DA157B42@gilbert.org> Reply-To: nicholas.dokos@hp.com Return-path: Received: from eggs.gnu.org ([140.186.70.92]:46487) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qmwgp-0000LJ-7q for emacs-orgmode@gnu.org; Fri, 29 Jul 2011 19:42:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qmwgn-0002iS-Vi for emacs-orgmode@gnu.org; Fri, 29 Jul 2011 19:41:59 -0400 Received: from g1t0029.austin.hp.com ([15.216.28.36]:18700) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qmwgn-0002iM-QB for emacs-orgmode@gnu.org; Fri, 29 Jul 2011 19:41:57 -0400 In-Reply-To: Message from Michael C Gilbert of "Fri, 29 Jul 2011 15:48:00 PDT." <7C3F7CA1-A957-4D18-9EEB-B2E6DA157B42@gilbert.org> 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: Michael C Gilbert Cc: nicholas.dokos@hp.com, emacs-orgmode Mailinglist Michael C Gilbert wrote: > > On Jul 29, 2011, at 12:52 PM, Eric Schulte wrote: > > > I would recommending using a gnuplot code block rather than a plot line, > > and passing your data to the code block using a variable. Code blocks > > give you much more direct access to gnuplot, which I find generally > > makes gnuplot learning/debugging much easier. > > > > see http://orgmode.org/manual/Working-With-Source-Code.html > > > > Thank you, Eric. You're generous with your time and you're absolutely > correct. This is the direction I will go. There's no doubt that this > seems the right way to go for anything sophisticated. And like most > solutions, it will then end up my standard approach. However, it also > means I will put this off for a little while until I'm ready to do it > right. Maybe just a few days, but... > > That means that, in the mean time, if you or anyone has an example of > how to configure this using the line: formatting, it would still be > useful to me and I would still be grateful. I just have something > small I need to produce tonight or tomorrow, for doing some simple > blood pressure tracking. I have everything working except a couple of > reference lines running across the plot. I'm figuring since it's in > the documentation, there must be something somewhere that shows the > syntax, yes? > The syntax is not the problem - here is an example that adds a couple of lines to the script, so the graph line comes out gold (as you can see, I just cribbed from Eric and modified the PLOT line :-) --8<---------------cut here---------------start------------->8--- * Date series plot >From Eric Schulte M-x org-plot/gnuplot somewhere above or in the table. #+PLOT: title:"Weight" ind:1 deps:(2) type:2d with:linespoints set:"xdata time" set:"yrange [90:]" line:"set style line 1 lw 2 lc rgb 'gold'" line:"set style increment user" | Date | 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 | --8<---------------cut here---------------end--------------->8--- The point is that the line: options just get added willy-nilly into the script that org-plot/gnuplot prepares, which it then passes to gnuplot for plotting. But it adds them before the final plot command and there's the rub. Maybe there is another way to do it, but what I thought of when I read you wanted "reference lines" were a couple of horizontal lines. That is easily done with gnuplot: just plot constant functions. For example replot f(x)=92.5, f(x) will plot a horizontal straight line with y-coordinate 92.5, through the middle of the previous graph, and the "replot" says add it to the previous graph. The rub is that it has to come *after* the plot command for the table and I know of no way to force that to happen through org-plot. OTOH, with babel, it's easy as \pi: --8<---------------cut here---------------start------------->8--- * Using org-babel for more control >From Eric Schulte #+TBLNAME: my-table | Date | 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=my-table set xdata time set timefmt '%Y-%m-%d' set yrange [90:] plot data using 1:2 with linespoints title 'Kg' replot f(x)=92.5, f(x) #+end_src --8<---------------cut here---------------end--------------->8--- Nick