Set Area Margins of ggplot2 Plot in R
In this article, we will discuss how to set area margins of the ggplot2 plot in the R programming language.
To do this call the theme() function and use the plot.margin argument of this function with the required data to this argument as per the requirement of the user.
theme() function is a powerful way to customize the non-data components of your plots: i.e. titles, labels, fonts, background, gridlines, and legends.
- plot.margin: -margin around the entire plot (unit with the sizes of the top, right, bottom, and left margins)
Let us look at few implementations to be familiar with the concept
Example 1a: Initial plot
Example 1b: final plot
Example 2a: Initial plot
Example 2b: final plot