搜索
写经验 领红包

如何用语言绘制条形图(语言绘制条形图加背景颜色)

导语:R语言绘制条形图

数据
> counts  None   Some Marked     42     14     28 
简单条形图

最基本用法:barplot()

> barplot(counts, main = &34;, xlab = &34;, ylab = &34;)

image.png

水平条形图
> barplot(counts, main = &34;, xlab = &34;, ylab = &34;, horiz = TRUE)

image.png

数据
> counts                 Placebo Treated  None        29      13  Some         7       7  Marked       7      21
堆砌条形图
> barplot(counts, main = &34;, xlab = &34;, ylab = &34;, col=c(&34;, &34;, &34;), legend=rownames(counts))

image.png

棘状图
> spine(counts, main = &34;)

image.png

分组条形图
> barplot(counts, main = &34;, xlab = &34;, ylab = &34;, col=c(&34;, &34;, &34;), legend=rownames(counts), beside = TRUE)

image.png

数据
> states = data.frame(state.region, state.x77)> means = aggregate(states$Illiteracy,by=list(state.region),mean)> means        Group.1        x1     Northeast 1.0000002         South 1.7375003 North Central 0.7000004          West 1.023077
均值条形图
> barplot(means$x, names.arg = means$Group.1, main = &34;)

i

本文内容由小欣整理编辑!