Hi, Naresh, I haven't really explored cairo myself, so I hope users with more experience will chip in / correct me. I've tested that the below works, but I can't really visually distinguish the results with cairo from the ones without.
Naresh Gurbuxani <naresh_gurbux...@hotmail.com> writes: > For cairo, I used this header and same code as below. > > #+begin_src R :exports results :results output :type cairo > > Running code block gives this output. > #+RESULTS: > : null device > : 1 > > Now I can insert a link using [[file:figures/cairoplot.png]] > > Is it possible to input file name as header and have the code output > graphics file link? Just try it with `:results file graphics' plus `:file' and a file name, and minus the explicit device commands. Here's a version of your full example; attaching a PNG of the result: #+begin_src R :exports results :results file graphics :file test-R-naresh.png :type cairo set.seed(123) mydf <- data.frame(x1 = rnorm(5, mean = 0, sd = 1), y1 = rnorm(5, mean = 0, sd = 1), x2 = rnorm(5, mean = 4, sd = 2), y2 = rnorm(5, mean = 4, sd = 2)) with(mydf, plot(x1, y1, xlim = c(-2, 8), ylim = c(-2, 8), pch = 20, cex = 2, col = rgb(0.9, 0, 0, alpha = 0.7), xlab = "", ylab = "")) with(mydf, points(x2, y2, pch = 20, cex = 2, col = rgb(0, 0.9, 0, alpha = 0.7))) with(mydf, arrows(x1, y1, x2, y2, length = 0.2, angle = 20, code = 2, col = rgb(0.7, 0.7, 0.7))) #+end_src
> Also, what are valid inputs for :antialias ? Looking at ob-R.el, org-babel simply passes through to the graphics device. So that's an R question. R help for cairo refers to help for `X11', where the antialias options are ‘c("default", "none", "gray", "subpixel")’. In my test, `:antialias none' gives visibly different results (whether or not using cairo). Yours, Christian > >> On Apr 16, 2025, at 8:45 AM, Christian Moe <m...@christianmoe.com> wrote: >> >> Try this: >> >> :type cairo >> >> See: https://orgmode.org/worg/org-contrib/babel/languages/ob-doc-R.html >> >> Yours, >> Christian >> >> Naresh Gurbuxani <naresh_gurbux...@hotmail.com> writes: >> >>> How can I set up a code block which uses R code to output a cairo >>> graphics file? In below example, code block for simple R graph uses >>> header argument to input filename. Is it possible to create a similar >>> set up when cairo is used?