R中几种常用的绘图命令

1.条形图:barplot()
添加标题:main = ’ ’
添加坐标轴标题:xlab = ’ ’ , ylab = ’ ’
region2 <- table(example1 R e g i o n 2 ) r l a b e l s < − c ( ′ N o r t h ′ , ′ S o u t h ′ , ′ F o r e i g n ′ , ′ E a s t ′ , ′ W e s t ′ ) b a r p l o t ( r e g i o n 2 ) b a r p l o t ( r e g i o n 2 , n a m e s . a r g = r l a b e l s ) b a r p l o t ( r e g i o n 2 , n a m e s . a r g = r l a b e l s , m a i n = " B a r C h a r t f o r R e g i o n " ) b a r p l o t ( r e g i o n 2 , n a m e s . a r g = r l a b e l s , m a i n = " B a r C h a r t f o r R e g i o n " , x l a b = " R e g i o n " , y l a b = " C o u n t " ) 2. 饼 图 : p i e ( ) p i e ( r e g i o n 2 ) p i e ( r e g i o n 2 , m a i n = ′ P i e C h a r t f o r R e g i o n ′ , l a b e l s = r l a b e l s ) 3. 直 方 图 : h i s t ( ) h i s t ( e x a m p l e 1 Region2) rlabels <- c('North', 'South', 'Foreign', 'East', 'West') barplot(region2) barplot(region2, names.arg = rlabels) barplot(region2, names.arg = rlabels, main = "Bar Chart for Region") barplot(region2, names.arg = rlabels, main = "Bar Chart for Region", xlab = "Region", ylab = "Count") 2.饼图:pie() pie(region2) pie(region2, main = 'Pie Chart for Region', labels = rlabels) 3.直方图:hist() hist(example1 Region2)rlabels<c(North,South,Foreign,East,West)barplot(region2)barplot(region2,names.arg=rlabels)barplot(region2,names.arg=rlabels,main="BarChartforRegion")barplot(region2,names.arg=rlabels,main="BarChartforRegion",xlab="Region",ylab="Count")2.pie()pie(region2)pie(region2,main=PieChartforRegion,labels=rlabels)3.hist()hist(example1Price)
hist(example1 P r i c e , b r e a k s = 1 ) h i s t ( e x a m p l e 1 Price, breaks = 1) hist(example1 Price,breaks=1)hist(example1Price, breaks = c(1.3, 1.9, 2.5, 3.1, 3.7, 4.3))
4.箱线图:boxplot()
添加参考线:abline()
boxplot(example1 P r i c e ) a b l i n e ( h = 3 , c o l = ′ r e d ′ ) b o x p l o t ( e x a m p l e 1 Price) abline(h = 3, col = 'red') boxplot(example1 Price)abline(h=3,col=red)boxplot(example1Price, horizontal = TRUE)
abline(v = 2, col = ‘blue’)
boxplot(example1 P r i c e   e x a m p l e 1 Price~example1 Price example1Region2, names = rlabels)
5.散点图:plot()
plot(example1 P r i c e , e x a m p l e 1 Price, example1 Price,example1Kilogram)
abline(a = 0, b = 0.5, col = ‘pink’)
text(x = 3.5, y = 2, labels = ‘y=0.5x’, col = ‘yellow’)
9.分区画图:par(mfrow = c(n,m))
par(mfrow = c(2,2))
barplot(region2, names.arg = rlabels, main = “Bar Chart for Region”, xlab = “Region”, ylab = “Count”)
pie(region2, main = ‘Pie Chart for Region’, labels = rlabels)
boxplot(example1 P r i c e   e x a m p l e 1 Price~example1 Price example1Region2, names = rlabels)
plot(example1 P r i c e , e x a m p l e 1 Price, example1 Price,example1Kilogram)

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值