The directly-generated PDF from the third chunk ("tmp.pdf") is OK,
but the PDF generated from the second chunk ("unnamed-chunk-2.pdf") is
clipped -- so it's not just the passage through pdflatex that does
something to it ...
should I try messing with resize.width, resize.height ... ?
Ben Bolker
Regards,
Yihui
--
Yihui Xie <xiey...@gmail.com>
Phone: 515-294-2465 Web: http://yihui.name
Department of Statistics, Iowa State University
2215 Snedecor Hall, Ames, IA
Thanks for your quick response (and sorry for my slow one). I had
tried a variety of different out.width settings (\textwidth,
0.7\textwidth, etc.) and the longest legend label is still clipped.
Oddly enough, when viewing it with evince (a Gnome PDF viewer), if I
highlight the legend text the end of the label becomes visible; in
acrobat reader, I can highlight and see a bar that extends the full
width of the text, but the cut-off text is not visible.
Ben Bolker
Regards,
Yihui
--
Yihui Xie <xiey...@gmail.com>
Phone: 515-294-2465 Web: http://yihui.name
Department of Statistics, Iowa State University
2215 Snedecor Hall, Ames, IA
This is indeed weird, and I'm beginning to suspect some kind of
interaction *somewhere* along the toolchain: knitr -> ggplot -> R -> PDF
driver -> pdflatex ?
I can see your PDF just fine (in acrobat reader or evince), so I don't
think it's the viewer.
Here are my three variants:
Full PDF file -- clipped
http://www.math.mcmaster.ca/~bolker/misc/knitggclip.pdf
PDF figure only, as generated from within knitr (first chunk) -- clipped
http://www.math.mcmaster.ca/~bolker/misc/knitggclipfig.pdf
PDF figure, as explicitly saved via pdf() (second chunk) -- *not* clipped
http://www.math.mcmaster.ca/~bolker/misc/knitggclipfig2.pdf
This is under R-devel, knitr 0.2, ggplot 0.9.0, on Ubuntu 10.04 -- I
haven't tried other combinations yet. I tried dev=cairo_pdf, didn't
seem to change anything.
I guess that this suggests something about the specific procedure by
which knitr captures PDF output ...
???
Ben
Also I noticed you are using a development version of R, and this
might make a difference. I'm using 2.14.1.
Regards,
Yihui
--
Yihui Xie <xiey...@gmail.com>
Phone: 515-294-2465 Web: http://yihui.name
Department of Statistics, Iowa State University
2215 Snedecor Hall, Ames, IA
Running in a non-interactive session fixed the problem. Thanks. I
don't know whether this is worth putting on an "issue list" somewhere --
presumably it constitutes a bug *somewhere* in *someone's* code, but
it's not clear to me whose responsibility it is ...
thanks very much -- your solution to embedding functions is working great.
cheers
Ben Bolker
For some reason, pdf(file = NULL) is not stable in your devel version
of R. At least I know Prof Ripley made a change to it a few days ago
to fix the bug:
https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=14808 So I
recommend to either roll back to the stable version of 2.14.1, or
check out the latest source of R and rebuild it.
Regards,
Yihui
--
Yihui Xie <xiey...@gmail.com>
Phone: 515-294-2465 Web: http://yihui.name
Department of Statistics, Iowa State University
2215 Snedecor Hall, Ames, IA
Thanks very much. For now I will just use the workaround of building
non-interactively whenever I care about the details of the plots ... I
have been having a little trouble building the latest R-devel, probably
something boneheaded I'm doing, but I don't want to take the time to fix
it right now so I will wait and see if this gets resolved. (Unless it
would be very useful to you to have this followed up, in which case I'll
try to make some time to do so.)
cheers
Ben Bolker