Plots cut off at end of page

My R markdown document contains solely plots and tables. Pages that contain both tables and plots dont display correctly; the plots overlap the margin at the bottom of the page and are cut off (example: I experimented with float parameters and there was no effect. I tried specifying a new page before the images but also no effect. I've had a lot of trouble finding information about this issue, any help is appreciated.

EDIT: I think this issue comes from the use of the file longtable.sty, which has a known issue with causing images to float. Theres a patched version of longtable.sty that I used, which didn't seem to make a difference. Then I switched from using kable to xtable. With xtable, all the images are fully plotted on the page, although they still overlap with the page number.

You mean that you included a \newpage immediately before the code chunk that displays the plot (with echo=F) .
Can you show us that piece of the Rmd input?

Sure, it looks like this:

xtable(Anova(fit.temp.time, type = 3), type = "latex", booktabs = T, 
             caption.placement = "top", align = 'cccc', 
             caption = "Temporal Data - Time in Synch")


bxp.peer <- ggboxplot(
  dat1, x = "Timepoint", y = "",
  color = "group", xlab = "Time",
  ylab = "PEER Score" 
  ) + theme(legend.position="right") + scale_color_discrete()

except there are multiple tables in the first chunk, multiple plots in the second.

I would like to see the chunks that you used.
What you showed looks to be one chunk.

I think it should be one code chunk, one text chunk and again one code chunk. Is that what you used?

1 Like

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.