
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to change the thickness of the borders of bars in bar plot created by using ggplot2 in R?
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
- Related Questions & Answers
- How to change the color of bars of a bar plot using ggplot2 in R?
- How to change the bars color to grey shade of a bar graph created by using ggplot2 in R?
- How to change legend values in a bar plot created by using ggplot2 in R?
- How to reverse the bars of a bar plot a using ggplot2 in R?
- How to change the angle of annotated text in plot created by using ggplot2 in R?
- Change the starting point of bars in bar plot for a ggplot2 graph in R.
- How to increase the space between bars of a bar plot using ggplot2 in R?
- How to create a bar plot in R with label of bars on top of the bars using ggplot2?
- How to align the text horizontally in a bar plot created by using ggplot2 in R?
- How to change the size of dots in dotplot created by using ggplot2 in R?
- How to fill bars of a bar plot created using ggplot2 with colors based on frequency?
- How to change the background color of a plot created by using plot function in R?
- How to change the automatic sorting of X-axis of a bar plot using ggplot2 in R?
- How to create bar plot of means with error bars of standard deviations using ggplot2 in R?
- How to change the order of bars in bar chart in R?
Advertisements