Setting the X-axis limit of the bar plot
The xlim parameter of the barplot() method can be used to set limits to portray on the display window. It contains a vector containing lower and higher limit.
Example: Setting the X-axis limit
R
# creating a data frame data_frame <- data.frame (col1 = 1:20, col2 = 1:20, col3 = 1) # printing the data frame print ( "Original DataFrame" ) print (data_frame) # plotting a barplot barplot (data_frame$col2, names.arg = data_frame$col1 , xlim= c (0,50) ) |
Output
How to customize the axis of a Bar Plot in R
Barplots in R programming language can be created using the barplot() method. It takes as input a matrix or vector of values. The bar heights are equivalent to the values contained in the vector.
Syntax: barplot(H, xlab, ylab, main, names.arg, col)