emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: John Hendy <jw.hendy@gmail.com>
To: Matt Price <moptop99@gmail.com>
Cc: Org Mode <emacs-orgmode@gnu.org>
Subject: Re: rmarkdown-like production of multiple plots in org
Date: Tue, 31 Mar 2020 15:12:21 -0500	[thread overview]
Message-ID: <CA+M2ft-SZZoMe8tHSJ1YU0k6=THvtTLsS4FHnpHqs9AmQ0idjA@mail.gmail.com> (raw)
In-Reply-To: <CAN_Dec9LkVhCVX35oTE6UuZdGfs1=3azUDOY96wGH3R02v-yZg@mail.gmail.com>

On Tue, Mar 31, 2020 at 2:22 PM Matt Price <moptop99@gmail.com> wrote:
> I'm completely new to R.
> I've started working with a project that creates plots using the ggplot package -- so by default it creates grid objects, rather than writing to files.
> In rmarkdown/rstudio, I can write something like this in a SOMEFILE.Rmd :
> ```
> install_github('eeholmes/CoV19')
> library(CoV19)
> getdata();
> plot4(world, 'Ontario Canada')
> plot2(world, 'Italy')
> plot4(states, "WA")
> ```

Interesting. I hadn't really thought that approach through. For
exploratory analysis, this sounds awesome and I don't think I've ever
tried multiple plots in a single chunk in RStudio. Only after seeing
Thomas' reply just now did I realize this isn't just plot(), though...
where are those functions from? There might be hidden conveniences
that don't apply to pure ggplot() calls... dunno.

I will add that as soon as you want to start tailoring sizes or how
these appear in the resultant file, I think you'd have to split these
into separate chunks in order to set the options, no?

> I sort of love how the rmarkdown package will just create all 3 of those plots, save them to auto-named files, and render to HTML.  In RStudio, running just that block will also create all three blocks and display them in the editor.
> By contrast, creating a series of many plots in org is fairly tedious.  I have to name the plot individually & put each function call in its own src block. Is there any way to mimic the behaviour of rmarkdown instead? I odn't understand babel or R enough to really even see how something like that could be implemented, but I'd appreciate some pointers.  Thank you!

Perhaps an alternative is running all your plots in one block, but
using ggsave() (or similar) to save out the files directly (vs. using
:output/:file to do it). Then you could have file links in the org
file instead of the typical 1:1 match-up of a single block to a single
result. I did this once during an effort to optimize a neural network.
I had a big loop iterating through parameters, and would
programmatically save out one residual plot per combination, e.g.
model_var1-value_var2-value_etc.png, I also generated an org-mode
section and exported headers for each combination, embedding the
corresponding [[./plots/foo.png]] image link within that heading.
Exporting to pdf let me page through all my residual plots handily to
compare them.

Anyway, maybe something helpful in there?


  reply	other threads:[~2020-03-31 20:12 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-31 19:23 rmarkdown-like production of multiple plots in org Matt Price
2020-03-31 20:12 ` John Hendy [this message]
2020-04-02 17:39 ` Berry, Charles via General discussions about Org-mode.
2020-04-02 17:52   ` Matt Price
2020-03-31 20:02 Thomas S. Dye

Reply instructions:

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 \
    --in-reply-to='CA+M2ft-SZZoMe8tHSJ1YU0k6=THvtTLsS4FHnpHqs9AmQ0idjA@mail.gmail.com' \
    --to=jw.hendy@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=moptop99@gmail.com \


* 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).