Bar chart （bar
chart） It is a graph that uses the height or length of bars with the same width to indicate the amount of data . It is mainly used to show different classifications ( Horizontal axis ) Next numerical variable ( Longitudinal axis ) Value of . In practice , Bar charts are mainly simple bar charts , Combined bar chart and stacked bar chart .

stay R Language can be used in the base package barplot() Function to draw a bar graph .

R In language barplot() The basic syntax format of the function is as follows ：

barplot(height, names.arg = NULL, beside = FALSE,

horiz = FALSE, density = NULL, angle = 45,

col = NULL, border = par("fg"),

main = NULL, sub = NULL, xlab = NULL, ylab = NULL,

xlim = NULL, ylim = NULL,las=NULL ...)

The main parameters are as follows ：

height： Vector or matrix , The values used to form the bars in a bar chart .

names.arg： Text label at the bottom of the bar .

beside: Logical value , by FALSE Draw a stack map when you need to , by TRUE Draw the group diagram when the time is up .

horiz: Logical value , by FALSE Time , Draw vertical bar chart , by TRUE Draw a horizontal bar chart as you go .

density： A vector value . When the value is specified , The bar is filled with a slash . The density of the diagonal per inch .

angle： The angle of the shadow line given in a counter clockwise direction . Default to 45 degree .

col: The fill color of the bar .

border： The border color of the bar , If set to TRUE Time , The border color will be the same as the shadow line color .

main: Specifies the main title of the drawing .

sub： Specifies the secondary title of the drawing .

xlab, ylab : Used to specify x Axis and y Label of shaft .

xlim, ylim: Used to specify x Axis and y Value range of axis .

las:las The default is NULL, The labels representing the horizontal axis are written horizontally , The label on the vertical axis is written vertically ;las=1 Represents the horizontal axis, and the vertical axis labels are written horizontally ;las=2, The labels representing the horizontal axis are written vertically , The label on the vertical axis is written horizontally ;las=3, The labels representing the horizontal axis and the vertical axis are written vertically .

Take an example ：
math <- c(78, 92, 89, 61, 95) names<-c(" Xiaogang ", " Xiao Ming ", " floret ", " Xiaofang ", " Xiaoli ")
barplot(math,names.arg=names,border="green",main=" performance ",
col=c("red","orange","lightblue","yellow","lightgreen"))
The drawing is as follows ：

Technology
Daily Recommendation
views 6