Plots Resolution
In this article, you’ll learn to save plots in R programming. You’ll learn to save plots as bitmap and vector images.
- Plot Graph in High Resolution in Matplotlib Save Figure in High Resolution in Matplotlib To save a graph in high resolution in Matplotlib, we control various parameters of savefig function. Similarly, we can plot graphs in high resolution by setting a high value of dpi parameter in figure function.
- Adjust SciView's Plots resolution/dpi Follow. Amin Sadeghi Created June 03, 2020 02:50. The default resolution of plots in SciView is sub-optimal and blurry.
Plot Resolution Definition
Complete the output from the Plot dialog box Note: The higher the fidelity, the more computer memory is used, so the longer it takes to plot. High fidelity is not necessary for all plots, and a setting between 300 and 600 dpi is generally sufficient for most plots. Was this information helpful? By default, the graphs are 480x480 pixels in size, at a resolution of 72 dpi (6.66x6.66 inches). Increasing the resolution will increase the size (in pixels) of the text and graph elements. This occurs because the size of these elements is relative to the physical dimension of the graph (e.g., 4x4 inches), not the pixel dimension of the graph.
All the graphs (bar plot, pie chart, histogram, etc.) we plot in R programming are displayed on the screen by default.
We can save these plots as a file on disk with the help of built-in functions.
It is important to know that plots can be saved as bitmap image (raster) which are fixed size or as vector image which are easily resizable.
How to save plot as a bitmap image?
Most of the image we come across like jpeg or png are bitmap image. They have a fixed resolution and are pixelated when zoomed enough.
Functions that help us save plots in this format are jpeg()
, png()
, bmp()
and tiff()
.
We will use the temperature column of built-in dataset airquality
for the remainder of this section as example.
Save as Jpeg image
To save a plot as jpeg image we would perform the following steps.
Please note that we need to call the function dev.off()
after all the plotting, to save the file and return control to the screen.
This will save a jpeg image in the current directory. The resolution of the image by default will be 480x480
pixel.
Save as png image
We can specify the resolution we want with arguments width
and height
.
We can also specify the full path of the file we want to save if we don’t want to save it in the current directory.
The following code saves a png file with resolution 600x350
.
Save as bmp image
Similarly, we can specify the size of our image in inch, cm or mm with the argument units
and specify ppi with res
.
The following code saves a bmp file of size 6x4
inch and 100
ppi.
Save as tiff image
Finally, if we want to save in the tiff format, we would only change the first line to tiff(filename = 'saving_plot3')
How to save plot as a vector image?
We can save our plots as vector image in pdf or postscript formats.
The beauty of vector image is that it is easily resizable. Zooming on the image will not compromise its quality.
Save as pdf file
To save a plot as pdf we do the following.
Save as postscript file
Similarly, to save the plot as a postscript file, we change the first line to postscript(file='saving_plot4.ps')
.
Plot Resolution Map
- PREVIOUS
R Multiple Plots - NEXT
R Plot Color