##数据准备
install.packages('vcd',repos='http://cran.us.r-project.org')
library(grid)
library(vcd)
counts<- table(Arthritis$Improved)
# simple bar plot
barplot(counts, main = "Simple Bar Plot", xlab = "Improvement",
ylab = "Frequency")
# stacked barplot
counts <- table(Arthritis$Improved, Arthritis$Treatment)
barplot(counts, main = "Stacked Bar Plot", xlab = "Treatment",
ylab = "Frequency", col = c("red", "yellow", "green"),
legend = rownames(counts))
//(使用las=2)旋转了条形的标签、修改了标签文本,并(使用mar)增加了y
边界的大小,为了让标签更合适,(使用cex.names=0.8)缩小了字体大小。
par(mar = c(5, 8, 4, 2))
par(las
R基本图形
最新推荐文章于 2024-08-22 22:56:36 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)