cameronbracken / pgfSweave

Quality graphics and speedy compilation with Sweave
http://r-forge.r-project.org/projects/pgfsweave/
29 stars 6 forks source link

eps figures are VERY large #2

Closed cameronbracken closed 13 years ago

cameronbracken commented 13 years ago

setting tex.driver=latex will correctly create an eps figure but in the document it will be very large. Too large for anyone to want.

yihui commented 13 years ago

One feature I believe that Sweave should have from the very beginning is to have a way to specify the width/height of the graphics device (such as pdf() or postscript()) and the size of the figure in LaTeX respectively. Unfortunately Sweave invented the LaTeX command \setkeys{Gin}{} instead. This is a solution, but not neat in my eyes. One thing I like the tikz device is I can use [nogin] with Sweave, and the width/height options will lead to the real size of the figure, which will not bring any confusion.

I am not sure if the issue comes from the width/height specification, but personally I would prefer different options to control the size of the graphics device and the size of LaTeX figures independently in the chunk options. Perhaps dev.width and dev.height?

cameronbracken commented 13 years ago

I completely agree. Using Gin (and actually having Sweave.sty exist at all) was a mistake in my opinion. nogin is the way to go for pgfSweave.

I see two problems with new options:

  1. They are new options and I am always reluctant to add more
  2. Because externalization is used, there is only an \input{} command to include the graphic and no way to set the dimensions.
yihui commented 13 years ago
  1. I hate too many options as well, but (to me) this problem is important and should not be difficult to implement; I see little hope in persuading Duncan or Frietz adding this feature. I'm OK without them, though. I rarely use other devices other than tikz.
  2. You are right, but I mean the other devices such as pdf() (I also wish one day there could be a png() device -- we talked with them for a couple of times but it seems impossible to have the support from the official R; sorry, this is off-topic).
cameronbracken commented 13 years ago

Here is one way to solve this using the new tikz externalization library:

https://github.com/cameronbracken/pgfSweave/blob/844d9a9d6c95b966a1bdaf3f2e732ad99058d9b2/inst/example/pgfSweave-latex-example.Rnw

can also be used to generate bitmap graphics. This will be the suggested way in the next version of pgfSweave.