我正在为按国家/地区分组的公司绘制销售点图。所以我的代码是dotchart(sales, labels=company, groups=country, data=mydata). 我还创建了一个按国家/地区划分的平均销售额表。有没有办法将此表作为图例包含在点图中?
四个小时后......我偶然发现了一种使用包中的addtable2plot命令将表格信息添加到绘图的非常巧妙的方法plotrix。跟进 chl 的例子:
res <- matrix(nc=3, nr=4)
for (i in 1:4) res[i,] <- tapply(iris[,i], iris[,5], mean)
colnames(res) <- levels(iris[,5])
rownames(res) <- colnames(iris)[1:4]
library(plotrix)
dotchart(res, auto.key=list(position="top", column=3), xlab="Mean"); addtable2plot(3,15, res, cex=.8)
Run Code Online (Sandbox Code Playgroud)