Home > Back-end >  Removing the space between a plot generated by R and the caption in an Rtex file
Removing the space between a plot generated by R and the caption in an Rtex file

Time:02-11

I am trying to edit an Rtex file and I'm creating plots. I have a plot below, which does compile. However, there is an empty white space below the caption. I can't figure out how to remove it. I have tried to search for solutions but to no avail:

  • Picture showing the code output

    CodePudding user response:

    Your image does have quite a lot of white space around it. You can move the caption further up with this quick hack:

    \documentclass[a4paper,11pt]{article}
    
    %Packages
    \usepackage[justification=centering]{caption}
    \usepackage{blindtext}
    \begin{document}
    \title{F-distribution}
    \maketitle
    \section{Diagram showing the $F$-distribution for a selected pair of values of the degree of freedom}
    \blindtext
    \begin{figure}[h!]
    <<echo=FALSE, cache=TRUE, fig.width=5, fig.height=5>>=
    curve(df(x, df1=20, df2=20))
    @
    \vskip-1cm
    \caption{Hi}
    \end{figure}
    \blindtext
    \blindtext
    \end{document}
    

    enter image description here

  • Related