Go to TogaWare.com Home Page. Data Science Desktop Survival Guide
by Graham Williams
Duck Duck Go



CLICK HERE TO VISIT THE UPDATED SURVIVAL GUIDE

Adjusting Aspect

Raw

\includegraphics[width=\textwidth]{figures/onepager/knitr:example_figure_width-1}

We can fine tune the size of the figure to suit the document and presentation. In this example we have asked R to widen the figure from 7 inches to 14 inches using fig.width=. The code chunk is:

<<myfigure, echo=FALSE, fig.width=14>>=
... R code ...
@

Underneath, knitr is using a PDF device on which the plot is generated, and then saved to file for inclusion in the final document. The PDF device grDevices::pdf(), by default, will generate a 7 inch by 7 inch plot (see ?pdf for details). This is the plot dimensions as we see on the previous page. By setting fig.width= (and fig.height=) we can change the dimensions. In our example here we have doubled the width, resulting in a more pleasing plot.

Notice that as a consequence of the figure being larger the fonts have remained the same size, resulting them appearing smaller now when we include the figure in the same area on the printed page.


Support further development by purchasing the PDF version of the book.
Other online resources include the GNU/Linux Desktop Survival Guide.
Books available on Amazon include Data Mining with Rattle and Essentials of Data Science.
Popular open source software includes rattle and wajig.
Hosted by Togaware, a pioneer of free and open source software since 1984.
Copyright © 2000-2020 Togaware Pty Ltd. . Creative Commons ShareAlike V4.