Remove Panel Border Lines in facet plots
To remove the Panel Border Lines, we use panel.border argument of theme() function. we use element.blank() function as parameter for panel.border argument to remove the border.
Syntax: plot + theme( panel.border = element_blank() )
Example:
Here, we have used the diamonds dataset to create a faceted bar plot and removed panel borders by using panel.border aselement_blank() in theme() function.
R
# load library tidyverse library (tidyverse) # set theme_bw() theme_set ( theme_bw (18)) # Basic facet plot divided according to category clarity # diamonds data frame is used in plot which # is provided natively by R Language # ggplot() function is used to plot the chart ggplot (diamonds, aes (x= "price" )) + # geom_bar function is used to create bar plot geom_bar ()+ # facet_wrap() function divides the plot in # facets according to category of clarity facet_wrap (~clarity)+ # theme function with panel.border is # used to remove border of facet panels theme ( panel.border = element_blank () ) |
Output:
How To Customize Border in facet plot in ggplot2 in R
In this article, we will discuss how to customize the border in the facet plot in ggplot2 in R Programming language.
Facet plots, where one subsets the data based on a categorical variable and makes a series of similar plots with the same scale. Facetting helps us to show the relationship between more than two categories of data. When we have multiple variables, with faceting it can be plotted in a single plot into smaller plots.
We can easily plot a facetted plot using the facet_wrap() function of the ggplot2 package. When we use facet_wrap() in ggplot2, by default it gives a title in a grey box.
Syntax: plot + facet_wrap( ~facet-variable)
Where:
- facet-variable: determines the variable around which plots have to be divided.