# How to change the thickness of the borders of bars in bar plot created by using ggplot2 in R?

R ProgrammingServer Side ProgrammingProgramming

#### Artificial Intelligence : The Future Of Programming

15 Lectures 54 mins

#### Beyond Basic Programming - Intermediate Python

Most Popular

36 Lectures 3 hours

#### C Programming from scratch- Master C Programming

Best Seller

60 Lectures 8 hours

The border thickness highlights the bars and this could be useful in situations where we have similar frequencies. If we want to change the thickness of the bars then size argument under geom_bar function of ggplot2 package can be used and it can be set according to our need starting from 1.

## Example

Consider the below data frame −

x<−c("Male","Female")
F<−c(24,28)
df<−data.frame(x,F)
df

## Output

   x    F
1 Male 24
2 Female 28

Loading ggplot2 package and creating bar plot for x −

library(ggplot2)
ggplot(df,aes(x,F,color=x))+geom_bar(stat="identity")

## Output

Creating the same plot with a little bit larger border size −

ggplot(df,aes(x,F,color=x))+geom_bar(stat="identity",size=2)

## Output

Creating the same plot with a very large border size −

ggplot(df,aes(x,F,color=x))+geom_bar(stat="identity",size=5)

## Output

Updated on 07-Nov-2020 11:29:58