Method 2 : Using barplot method
The barplot() method in base R is used to construct successive bar plots from the given input table or matrix. The widths of the bars are equal unless explicitly specified using the width parameter.
barplot(data, xlab, ylab)
Parameters :
- data – The input data frame
- xlab – The label for x axis
- ylab – The label for y axis
Example:
R
# creating a table df < - table (col1= sample ( rep ( c (1, 20, 40), each=26)), col2= sample ( rep ( c (1: 6), each=13)) ) # plotting the data # plotting the barplot with equal bar widths barplot (df, xlab= "col1" , ylab= "col2" ) |
Output
How to Make Grouped Bar Plot with Same Bar Width in R
In this article, we will discuss How to Make Grouped Bar Plot with the Same Bar Width in R Programming Language.