我在R中制作散点图,为每个点使用数字标注系统。有12种类型的点,所以我想使用数字1到12作为点符号。我正在尝试“
pch=c("1","2","3","4","5","6","7","8","9","11","12")
但问题在于它在情节和图例中呈现“10”,“11”和“12”,全部为“1”。显然,pch只接受“”之间的单字符长度符号。有没有办法在图上使用多位数符号?
编辑:使用text()
有助于绘制情节,但图例仍会截断一个字符。
以下是新的完整代码:
fig <- ordiplot(mds1, type = "none", xlim=c(-200,200), ylim=c(-150,150), main = "Attractors in Human Subsistence Economy")
ordispider(mds1, mclus1.out$clustering, label = FALSE, col="#00000050")
text(mds1$points, adj=0, labels=d2.1_label$subsis_ecol, cex=1, col=c("red","blue","green","orange","purple","magenta","cyan","brown")[mclus1.out$clustering])
legend(130,100, pt.cex=0.7, text.width=60, inset=10, y.intersp=0.8 , c("Gathering", "Hunting and/or \nMarine Animals", "Fishing", "Anadromous Fishing", "Mounted Hunting", "Pastoralism", "Shifting Cultivation, \nWooden Implements", "Shifting Cultivation, \nMetal Implements", "Horticultural Gardens \nor Tree Fruits", "Intensive Agriculture, \nNo Plow", "Intensive Agriculture, \nPlow"), pch=as.character(1:12), cex=0.7)
以下是结果图:https://dl.dropboxusercontent.com/u/7325374/plot_zoom_png.png
答案 0 :(得分:3)
是的建议:
plot(1, type="n", xlab="", ylab="", ylim = c(1,12), xlim=c(1,12))
text(1:12, 1:12, pch=as.character(1:12))
怎么样?
plot(1, type="n", xlab="", ylab="", ylim = c(1,12), xlim=c(1,12))
text(1:12, 1:12, as.character(1:12))
答案 1 :(得分:0)
好吧,我的“回答”是在导出绘图后只在图形程序中编辑图例。不理想,但它“有效”。