Search code examples
rnotebook

How to change image height in RNotebook


I want to increase the height of an image that is generated by RNotebook. When I use fig.height chunk option, it merely decreases font sizes and marker sizes, but picture remains the same. For example:

original plot (plot(iris)

and here is result with fig.height=3:

plot(iris) with fig.height=3 specified

How would I actually change height of the output?


Solution

  • According to R Markdown: The Definitive Guide, by default,

    Plots emitted from a chunk are rendered to match the width of the editor at the time the chunk was executed. The height of the plot is determined by the golden ratio.

    Specifying fig.size would not change aspect ratio: you actually change the whole size of the picture (width and height are changed proportionally), but when RNotebook shows it to you it rescales it automatically to fit editor window. So you don't see a difference other than change of size of fonts, etc.

    To actually produce taller image, you have to specify fig.asp, like fig.asp=1.2.

    plot(iris) with fig.asp=1.2 and fig.width=3