emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* [babel] changing size of R graphics in pdf output
@ 2009-12-12 22:40 Graham Smith
  2009-12-13  1:45 ` Dan Davison
  0 siblings, 1 reply; 9+ messages in thread
From: Graham Smith @ 2009-12-12 22:40 UTC (permalink / raw)
  To: emacs-orgmode

I don't seem able to change the size of graphics in the PDF output.

#+begin_src R :file z.pdf :width 20 :height 20 :R-dev-args
bg="olivedrab", fg="hotpink"
     plot(matrix(rnorm(100), ncol=2), type="l")
#+end_src

Using this  example from an earlier post, regardless of how I change
the width and height settings the image in the PDF stays the same.

With this next example:

#+srcname:Boxplots Summary
#+begin_src R :session BirdData :file BoxplotSummary.pdf :exports both
 boxplot(Wingcrd,Tarsus,Head,Wt,names=c("Wingcrd","Tarsus","Head","Wt"))
#+end_src

If I add height and width arguments the image stays the same size
regardless of settings, but the labels for the boxplots become tiny.

Am I missing some code somewhere that allows the graphs to be modified.

Thanks,

Graham

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [babel] changing size of R graphics in pdf output
  2009-12-12 22:40 [babel] changing size of R graphics in pdf output Graham Smith
@ 2009-12-13  1:45 ` Dan Davison
  2009-12-13  7:37   ` Graham Smith
  0 siblings, 1 reply; 9+ messages in thread
From: Dan Davison @ 2009-12-13  1:45 UTC (permalink / raw)
  To: Graham Smith; +Cc: emacs-orgmode

Hi Graham,

Graham Smith <myotisone@gmail.com> writes:

> I don't seem able to change the size of graphics in the PDF output.
>
> #+begin_src R :file z.pdf :width 20 :height 20 :R-dev-args
> bg="olivedrab", fg="hotpink"
>      plot(matrix(rnorm(100), ncol=2), type="l")
> #+end_src
>
> Using this  example from an earlier post, regardless of how I change
> the width and height settings the image in the PDF stays the same.

Hmm, this example is working for me. What about the axis annotation --
does that change size relative to the plot?

>
> With this next example:
>
> #+srcname:Boxplots Summary
> #+begin_src R :session BirdData :file BoxplotSummary.pdf :exports both
>  boxplot(Wingcrd,Tarsus,Head,Wt,names=c("Wingcrd","Tarsus","Head","Wt"))
> #+end_src
>
> If I add height and width arguments the image stays the same size
> regardless of settings, but the labels for the boxplots become tiny.

That's what one would see if you increase the width and height arguments
to pdf(). I.e. the labels get smaller relative to the plot size (unless
you also scale the labels size by using cex.lab or whatever) Is it
possible that the pdf output *is* changing size, but that your pdf
viewer is rescaling the images to the same size on your screen?

Dan

>
> Am I missing some code somewhere that allows the graphs to be modified.
>
> Thanks,
>
> Graham
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [babel] changing size of R graphics in pdf output
  2009-12-13  1:45 ` Dan Davison
@ 2009-12-13  7:37   ` Graham Smith
  2009-12-13  8:23     ` Graham Smith
  0 siblings, 1 reply; 9+ messages in thread
From: Graham Smith @ 2009-12-13  7:37 UTC (permalink / raw)
  To: emacs-orgmode

Dan/Torsten

Thanks, It seems to be a orgemode/babel/Latex issue.

If I view the pdf from within Emacs by double clicking on the link,
the size changes as expected, but if I compile the whole document as a
pdf the plots appear as small.

The error in the log is

! LaTeX Error: Cannot determine size of graphic in z.pdf (no BoundingBox).

See the LaTeX manual or LaTeX Companion for explanation.
Type  H <return>  for immediate help.
 ...

l.283  \includegraphics[width=10em]{z.pdf}


The actual TEX file has

\includegraphics[width=10em]{BoxplotSummary.pdf}
\includegraphics[width=10em]{z.pdf}

So it seems to be ignoring the change in height and width commands for
z.pdf, and defaulting to 10em.

Graham

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [babel] changing size of R graphics in pdf output
  2009-12-13  7:37   ` Graham Smith
@ 2009-12-13  8:23     ` Graham Smith
  2009-12-13 13:12       ` Graham Smith
  0 siblings, 1 reply; 9+ messages in thread
From: Graham Smith @ 2009-12-13  8:23 UTC (permalink / raw)
  To: emacs-orgmode

IGNORE everything in my last email.

The only relevant bit is

> \includegraphics[width=10em]{BoxplotSummary.pdf}
> \includegraphics[width=10em]{z.pdf}
>
> So it seems to be ignoring the change in height and width commands for
> z.pdf, and defaulting to 10em.

If I then edit the [width=10em] bit in the tex file I can change the
size easily.

It just seems that babel isn't passing the changes made in the org
file onto the tex file.

Graham

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [babel] changing size of R graphics in pdf output
  2009-12-13  8:23     ` Graham Smith
@ 2009-12-13 13:12       ` Graham Smith
  2009-12-13 13:39         ` Graham Smith
  0 siblings, 1 reply; 9+ messages in thread
From: Graham Smith @ 2009-12-13 13:12 UTC (permalink / raw)
  To: emacs-orgmode

A little progress here

#+srcname:Boxplots Summary
#+begin_src R :session BirdData :file BoxplotSummary.pdf :exports both
 boxplot(Wingcrd,Tarsus,Head,Wt,names=c("Wingcrd","Tarsus","Head","Wt"))
#+end_src


#+resname: Boxplots

#+ATTR_LaTeX: width=10cm

[[file:BoxplotSummary.pdf]]

This gives me a plot 10cm wide, but in "addition" to the small plot.
Not sure I understand why I am getting two plots.

Graham

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [babel] changing size of R graphics in pdf output
  2009-12-13 13:12       ` Graham Smith
@ 2009-12-13 13:39         ` Graham Smith
  2009-12-13 14:23           ` Graham Smith
  0 siblings, 1 reply; 9+ messages in thread
From: Graham Smith @ 2009-12-13 13:39 UTC (permalink / raw)
  To: emacs-orgmode

This works

#+srcname:Boxplots Summary
#+begin_src R :session BirdData :file BoxplotSummary.pdf :exports none
 boxplot(Wingcrd,Tarsus,Head,Wt,names=c("Wingcrd","Tarsus","Head","Wt"))
#+end_src


#+resname: Boxplots
#+CAPTION:    Trial boxplots with babel
#+LABEL:      fig:trial boxplots
#+ATTR_LaTeX: width=10cm

[[file:BoxplotSummary.pdf]]


However, it needs :exports none

I actually want the code to still be present, but if I use  :exports
code   I get the both boxplots again :-(

I assume this is becasue the graphics are treated differently from
numerical code output.

Graham

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [babel] changing size of R graphics in pdf output
  2009-12-13 13:39         ` Graham Smith
@ 2009-12-13 14:23           ` Graham Smith
  2009-12-15 19:14             ` Dan Davison
  0 siblings, 1 reply; 9+ messages in thread
From: Graham Smith @ 2009-12-13 14:23 UTC (permalink / raw)
  To: emacs-orgmode

OK,  This was all to do with the ordering of the latex code

Below works, includes the R code, but only one plot of the expected size.


#+srcname:Boxplots Summary
#+begin_src R :session BirdData :file BoxplotSummary.pdf :exports both
 boxplot(Wingcrd,Tarsus,Head,Wt,names=c("Wingcrd","Tarsus","Head","Wt"))
#+end_src

#+CAPTION:    Trial boxplots with babel
#+LABEL:      fig:trial boxplots
#+ATTR_LaTeX: width=10cm
#+resname: Boxplots
[[file:BoxplotSummary.pdf]]

I await for someone to tell me how it "should" be done :-)

Graham

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [babel] changing size of R graphics in pdf output
  2009-12-13 14:23           ` Graham Smith
@ 2009-12-15 19:14             ` Dan Davison
  2009-12-15 19:51               ` Graham Smith
  0 siblings, 1 reply; 9+ messages in thread
From: Dan Davison @ 2009-12-15 19:14 UTC (permalink / raw)
  To: Graham Smith; +Cc: emacs-orgmode

Hi Graham,

I think your solution is sensible, and thanks for bringing up these
issues. Perhaps, as you suggest, we should be automatically setting
these attributes in the latex output; we'll get back to you on that.

Regarding the number of copies of the figure in the output, it should
work as follows:

Let's assume you have :exports both or :exports results.

Before running the export, do you have a link to the image *already* in
your org buffer?

If no, then you should just get one copy of the image.

If yes, then, if the link is positioned in such a way that it will get
replaced by the output (no intervening lines between end of source block
and results) then you should get one copy.

But if there are intervening lines between the source block and the
results, then you will get the original image, and a new one created by
the exporter which did not replace the original.

Thus I would do something like this, in which the pdf output is the same
regardless of whether the #+results line and link are in the buffer
before export, and which results in only one copy of the fig in either case.

------------------------------------------------------------------------
#+options toc:nil
#+title: R latex graphics

Text before figure.
#+CAPTION:    Trial boxplots with babel
#+LABEL:      fig:trial boxplots
#+ATTR_LaTeX: width=5cm
#+srcname:Boxplots Summary
#+begin_src R :session BirdData :file BoxplotSummary.pdf :exports both
  Wingcrd <- rnorm(100, 20) ; Tarsus <- rnorm(100, 5) ;
  Head <- rnorm(100, 3) ; Wt <- rnorm(100, 40)
  boxplot(Wingcrd,Tarsus,Head,Wt,names=c("Wingcrd","Tarsus","Head","Wt"))
#+end_src

#+results: Boxplots
[[file:BoxplotSummary.pdf]]

Text after figure.
------------------------------------------------------------------------

Dan


Graham Smith <myotisone@gmail.com> writes:

> OK,  This was all to do with the ordering of the latex code
>
> Below works, includes the R code, but only one plot of the expected size.
>
>
> #+srcname:Boxplots Summary
> #+begin_src R :session BirdData :file BoxplotSummary.pdf :exports both
>  boxplot(Wingcrd,Tarsus,Head,Wt,names=c("Wingcrd","Tarsus","Head","Wt"))
> #+end_src
>
> #+CAPTION:    Trial boxplots with babel
> #+LABEL:      fig:trial boxplots
> #+ATTR_LaTeX: width=10cm
> #+resname: Boxplots
> [[file:BoxplotSummary.pdf]]
>
> I await for someone to tell me how it "should" be done :-)
>
> Graham
>
>
> _______________________________________________
> Emacs-orgmode mailing list
> Please use `Reply All' to send replies to the list.
> Emacs-orgmode@gnu.org
> http://lists.gnu.org/mailman/listinfo/emacs-orgmode

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [babel] changing size of R graphics in pdf output
  2009-12-15 19:14             ` Dan Davison
@ 2009-12-15 19:51               ` Graham Smith
  0 siblings, 0 replies; 9+ messages in thread
From: Graham Smith @ 2009-12-15 19:51 UTC (permalink / raw)
  To: emacs-orgmode

Dan,

> Before running the export, do you have a link to the image *already* in
> your org buffer?
>
> If no, then you should just get one copy of the image.
>
> If yes, then, if the link is positioned in such a way that it will get
> replaced by the output (no intervening lines between end of source block
> and results) then you should get one copy.

I would almost certainly already  have the link as I have been making
minor changes and recompiling , what seems like hundreds of times
trying to sort out how to fix it

> ------------------------------------------------------------------------
> #+options toc:nil
> #+title: R latex graphics
>
> Text before figure.
> #+CAPTION:    Trial boxplots with babel
> #+LABEL:      fig:trial boxplots
> #+ATTR_LaTeX: width=5cm
> #+srcname:Boxplots Summary
> #+begin_src R :session BirdData :file BoxplotSummary.pdf :exports both
>  Wingcrd <- rnorm(100, 20) ; Tarsus <- rnorm(100, 5) ;
>  Head <- rnorm(100, 3) ; Wt <- rnorm(100, 40)
>  boxplot(Wingcrd,Tarsus,Head,Wt,names=c("Wingcrd","Tarsus","Head","Wt"))
> #+end_src
>
> #+results: Boxplots
> [[file:BoxplotSummary.pdf]]
>
> Text after figure.
> ------------------------------------------------------------------------

Thanks for this. It has to be said I am really excited about this
babel and R combination. I often do a few pages of R explanation on a
specific topic for students where I need to combine text and R output,
and this is a brilliant solution for this.

Graham

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2009-12-15 19:51 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-12-12 22:40 [babel] changing size of R graphics in pdf output Graham Smith
2009-12-13  1:45 ` Dan Davison
2009-12-13  7:37   ` Graham Smith
2009-12-13  8:23     ` Graham Smith
2009-12-13 13:12       ` Graham Smith
2009-12-13 13:39         ` Graham Smith
2009-12-13 14:23           ` Graham Smith
2009-12-15 19:14             ` Dan Davison
2009-12-15 19:51               ` Graham Smith

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

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