In general, Sweave is making great looking PDFs for me.

However, when I plot a histogram, it is not appearing in my PDF.

I have a bare bones Sweave document as follows. I can't seem to isolate what is missing!




p <- ggplot(diamonds, aes(x=carat))
p <- p + geom_histogram()

(PS : yes, I have the 'listings' package installed in my LaTex package! And yes, the plot is being printed to the terminal.)

Thanks in advance for any advice.

  • I provide small working examples with Sweave here for interested. – hhh Sep 30 '18 at 16:12

(Upgraded from a comment).

Try adding fig=TRUE in the chunk options. (You might need an explicit print() around the p in the last line of the chunk too ...) If you use knitr::knit instead of Sweave, you won't need either of those explicit specifications ...

  • This did the trick. The addition of the fig=TRUE into the chunk options worked perfectly. Thank you! – tumultous_rooster Sep 25 '13 at 23:23
  • @MattO'Brien apparently you are using the chunk options of knitr instead of Sweave – Yihui Xie Sep 26 '13 at 1:43
  • I cannot get any plots with Sweave with this example, only gibberish like here, ideas? – hhh Sep 30 '18 at 15:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.