From: John Hendy <email@example.com>
To: Eric Abrahamsen <firstname.lastname@example.org>
Subject: Re: plotting tables
Date: Sun, 24 Mar 2013 12:33:22 -0500 [thread overview]
Message-ID: <CA+M2ft-uUg+7k69M2Mb0C5K_z+FsvnJyi7ctTuPsLxivuAjEhQ@mail.gmail.com> (raw)
On Sun, Mar 24, 2013 at 1:44 AM, Eric Abrahamsen
> I'm trying to get my head around plotting data from org tables, for use
> in LaTeX exports. I've been looking at these two pages:
> As far as I can tell, there are two general approaches. One is an org
> table with some #+PLOT declarations, and when I call `org-plot/gnuplot'
> on it, gnuplot processes the table and shows it to me. Presumably I can
> make it save to a file instead, I haven't investigated that yet.
> The other approach seems to be using a named table, and then a gnuplot
> source block that accepts the table data as a variable. In this case
> you're writing an actual gnuplot script, rather than feeding gnuplot
> options into a #+PLOT line.
> My questions:
> 1. Are these really mutually incompatible approaches, as they appear to
What do you mean by incompatible? I think if you used them both, you'd
just get two plots. It looks like #+plot just allows one to put some
gnuplot commands in the header above a table and get a plot out. Using
the org-babel approach lets you write straight gnuplot code and call a
data table from elsewhere.
I wrote ob-doc-gnuplot, long ago that I didn't really remember why.
It looks like I was running into limitations with the #+plot syntax
and switched to using #+begin_src gnuplot because of that.
If you had a #+plot header and #+begin_src gnuplot with the same code,
both calling the table, if you had the correct :exports and :results
options in the block, you'd probably get to graphs.
> 2. What's my best option if I want the following scenario: I start with
> an org file containing an org table, call `org-latex-export-to-pdf' on
> that file, get a coffee, and come back to find a nice pdf containing
> just the plotted graph (no table). Can someone show me just the barest
Nice PDF of the plot and nothing else whatsoever, or nice PDF
containing other stuff from your org file and just not the header? If
you just want a standalone pdf, you can just use the file option
(assuming gnuplot will write to a pdf) in your code block:
#+begin_src gnuplot :file plot.pdf :exports results :results output
Something like that?
Otherwise, you could just hide the table in a headline with the :noexport: tag:
* Heading 1
Contains stuff you want in a resultant pdf file.
#+begin_src gnuplot :var data=foo
** Data table :noexport:
| data table here |
That would keep the table hidden in a non-exported headline.
> 3. I've been learning the tikz LaTeX package and am very impressed. Has
> anyone used tikz/pgfplots with org?
Yes! Though as with Dieter, I've also migrated to R now. Gnuplot
worked fairly well for simple plotting, but at the end of the day,
most plotting (for me, at least) falls into some sort of workflow:
- get some data
- re-arrange, combine, pre-process some data
- get that data accessible to some program (e.g. gnuplot, R)
- plot results
- interpret results
- present plots in context of some project/endeavor
Sure you can just start feeding gnuplot from a file instead of having
big tables in Org-mode tables (which I find gets extremely cumbersome
for more than maybe 20 or so rows and 10 cols), but for most things
you actually need to *do* other things with that data.
If you're just learning... I'd recommend just switching to learning to
plot with R. Ditch other R stuff if it's intimidating at the moment --
just manipulate your data in Excel or LibreOffice, and teach yourself
the equivalent of plotting in gnuplot with R. Instead of =plot data
using 1:3=, it might be =plot(data[, 1], data[, 3])= in R.
The benefit is that as you learn, you can "grow into R," whereas if
you attempt some level of gnuplot mastery, you'll still be stuck
needing a bunch of other tools for all but the more simply plotting
For matching fonts/styles in your LaTeX output, there's the handy
=tikzDevice= R library: ETA: gasp! It's been removed from CRAN. You
can still get it, though:
Here's the documentation:
You can add frequently used options in ~/.Rprofile (just create it if
it doesn't exist). Of particular interest is setting the
tikzLatexPackages variable. The following would set your document to
use the =mathpazo= font family instead of the default. You could
replace with whatever you wanted (I use lmodern a lot).
options( tikzLatexPackages = c(
getOption( "tikzLatexPackages" ),
From there, you'd do something like so:
[any general R code]
tikz(file = "file.tex", width = n, height = n, standAlone = T)
[commands that generate the plot in R]
Now you'll have a .tex file of your plot and can just compile it.
Better yet, just add this after =dev.off()= above:
That would compile the resultant file. I tend to get the output in
some other format to make sure things look good and then do the output
to .tex -> pdf as the final step.
As a bonus to this process, if there's ever any re-arrangement or more
complex annotation to be done, you can add it to the .tex file before
compiling. This is fairly manually intensive, but for some things when
you just couldn't specify it based on the data to have it
automatically plotted, you'd end up doing the same amount of work in R
to add text here and there anyway. By looking at the tikz code, you
can generally figure out the min/max coordinates of the plot and add
whatever additional graphics or text you want. You also get fine-tuned
color/shape changing abilities.
Hope that helps!
> In return, I promise to add a very hand-holdy explanation to worg,
> provided that there isn't already one there that I missed.
next prev parent reply other threads:[~2013-03-24 17:33 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-24 6:44 plotting tables Eric Abrahamsen
2013-03-24 10:42 ` Dieter Wilhelm
2013-03-24 17:33 ` John Hendy [this message]
2013-03-26 3:09 ` Eric Abrahamsen
2013-03-26 15:19 ` John Hendy
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
List information: https://www.orgmode.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).