R语言绘图-barplot()

1、柱状图
语法:
barplot(height, width = 1, space = NULL,
names.arg = NULL, legend.text = 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, xpd = TRUE, log = “”,
axes = TRUE, axisnames = TRUE,
cex.axis = par(“cex.axis”), cex.names = par(“cex.axis”),
inside = TRUE, plot = TRUE, axis.lty = 0, offset = 0,
add = FALSE, args.legend = NULL, …)

解析:
height:一个向量或矩阵。
当height是一组向量时,那么柱图的高度是向量的数值;
当height是矩阵且beside=FALSE时,柱图的高度是矩阵的数值,柱状图是水平堆叠的
当height是矩阵且beside=TRUE时,柱图的高度是矩阵的数值,柱状图是并列的

barplot(as.matrix(student[1:5,2:4]),col=c('red','green','blue'),beside=FALSE)

height是矩阵且beside=FALSE

> barplot(as.matrix(student[1:5,2:4]),col=c('red','green','blue'),beside=TRUE)

height是矩阵且beside=TRUE
width:可选 设置柱子的宽度的向量
space:每两个柱子间的距离,默认c(0,1)

> barplot(as.matrix(student[1:5,2:4]),col=c('red','green','blue'),beside=TRUE,space=c(0,1))

space=c(0,1)

> barplot(as.matrix(student[1:5,2:4]),col=c('red','green','blue'),beside=TRUE,space=c(1,1))

space=c(1,1)
names.arg
legend.text
beside
horiz:一个逻辑值。horiz=TRUE y轴在水平展示

>barplot(as.matrix(student[1:5,2:4]),col=c('red','green','blue'),beside=TRUE,horiz=TRUE)

horiz=TRUE

density
angle
col
border
main,sub
xlab
ylab
xlim
ylim
xpd
log
axes
axisnames
cex.axis
cex.names
inside
plot
axis.lty
offset
add
args.legend

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值