Closes the current plotting device and shows the result in...

View source: R/miscfuns.R

fit.offR Documentation

Closes the current plotting device and shows the result in the viewer


This function is deprecated: Please use the functions export_graph_start() and export_graph_end() instead.



To be used in combination with pdf_fit or png_fit when exporting images. It performs exactly the same thing as but additionaly shows the resulting graph in the viewer pane provided you're using RStudio.

To view the results of PDF exports, the function pdf_convert from package pdftools is used to convert the PDF files into images – so you need to have installed pdftools to make it work.

In PDFs, only the first page will be viewed.


This function does not return anything in R. It closes the connection between the R graphics engine and a file that has been defined via one of the functions: pdf_fitpng_fit


Laurent Berge

See Also

The tool to set the page size and the exporting defaults: setFplot_page. Exporting functions pdf_fit, png_fit, jpeg_fit.

The functions export_graph_start() and export_graph_end() provide similar features.


# Exportation example
# The functions pdf_fit, png_fit, etc, guarantee the right
#  point size of the texts present in the graph.
# But you must give the exact size the graph will take in your final document.
# => first use the function setFplot_page, default is:
# setFplot_page(page = "us", margins = "normal")
# By default the graph takes 100% of the text width


tmpFile = file.path(tempdir(), "DISTR -- institutions.png")

plot_distr(~institution, us_pub_econ)

# What's the consequence of increasing the point size of the text?
png_fit(tmpFile, pt = 15)
plot_distr(~institution, us_pub_econ)

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