emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] gnuplot question - "Specify an entire line to be inserted in the


From: Nick Dokos
Subject: Re: [O] gnuplot question - "Specify an entire line to be inserted in the Gnuplot script."
Date: Fri, 29 Jul 2011 19:41:54 -0400

Michael C Gilbert <address@hidden> 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
> 
> <snip>
> 
> 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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]