setFplot_page: Sets the target page size for figure exporting

View source: R/miscfuns.R

setFplot_pageR Documentation

Sets the target page size for figure exporting


Tha package fplot offers some functions (e.g. pdf_fit or png_fit) to export figures, with a guarantee to obtain the desired point size for the plotting text. The function setFplot_page sets the target page size (once and for all). This is important for the accuracy of the export, although the default values should be working well most of the time.


  page = "us",
  margins = "normal",
  units = "tw",
  pt = 10,
  w2h = 1.75,
  reset = FALSE




What is the page size of the document? Can be equal to "us" (for US letter, the default) or "a4". Can also be a numeric vector of length 2 giving the width and the height of the page in inches. Or can be a character string of the type: "8.5in,11in" where the width and height are separated with a comma, note that only centimeters (cm), inches (in) and pixels (px) are accepted as units–further: you can use the unit only once.


The bottom/left/top/right margins of the page. This is used to obtain the dimension of the body of the text. Can be equal to "normal" (default, which corresponds to 2cm/2.5cm/2cm/2.5cm), or to "thin" (1.5/1/1/1cm). Can be a numeric vector of length 1: then all margins are the same given size in inches.

Can also be a numeric vector of length 2 or 4: 2 means first bottom/top margins, then left/right margins; 4 is bottom/left/top/right margins, in inches. Last, it can be a character vector of the type "2,2.5,2,2.5cm" with the margins separated by a comma or a slash, and at least one unit appearing: either cm, in or px.


The default units when using the functions pdf_fit, png_fit, etc. Defaults to "tw" (text width) which is a fraction of the size of the text. Alternatives can be "pw" (page width), and "in", "cm", "px".


The size of the text, in pt, once the figure is inserted in your final document. The default is 10. This means that all text appearing in the plot with cex = 1 will appear with 10pt-sized fonts in your document.


Numeric scalar. Used to determine the height of the figure based on the width. By default it is equal to 1.75 which means that the graph will be 1.75 larger than tall. Note that when argument sideways = TRUE, the default for the height becomes ⁠90%⁠.


Logical, default is FALSE. Whether arguments should be reset to default before applying modifications.


This function sets the option "fplot_export_opts" after parsing the arguments. This option is then automatically accessed by the functions used to export graphs export_graph_start().


The function setFplot_page() does not return anything. It sets an R option containing the page parameters.

The function getFplot_page() returns the named list of page parameters which has been set in setFplot_page().

See Also

Exporting functions: pdf_fit, png_fit. The function closing the connection and showing the obtained graph in the viewer:


# How to set the page size

# All examples below provide the same page size
setFplot_page(page = "us")
setFplot_page(page = "8.5in, 11in")
setFplot_page(page = "8.5/11in")
setFplot_page(page = c(8.5, 11))

# All examples below provide the same margins
setFplot_page(margins = "normal")
setFplot_page(margins = "2cm, 2.5cm, 2cm, 2.5cm")
setFplot_page(margins = "2/2.5/2/2.5cm")
setFplot_page(margins = c(2, 2.5) / 2.54) # cm to in
setFplot_page(margins = c(2, 2.5, 2, 2.5) / 2.54)

fplot documentation built on Aug. 24, 2023, 5:09 p.m.