-3

我想将下面的图生成到 R 中。

在 Excel 中绘图以在 R 中重现

到目前为止,我的编码是这样的:

maraqa <- c(84.8,68.9,84.9,92.5)
aqua <- c(75,65.1,79.4,82.3)
mar <- c(84.7,68.3,84.5,77.4)

x <- c("A", "B", "C", "D")

怎么办?谢谢!

4

1 回答 1

2

这是一种解决方案……但请查看帮助页面以了解哪些参数控制着在此处输入图像描述什么……

maraqa <- c(84.8,68.9,84.9,92.5)
aqua <- c(75,65.1,79.4,82.3)
mar <- c(84.7,68.3,84.5,77.4)

# combine data as matrix
mat<-cbind(maraqa, aqua, mar)
rownames(mat)<-c("A", "B", "C", "D")

#define colours
coll<-c("red", "blue", "black")

matplot(mat, type="l", ylim=c(60, 95), ylab="y TBA", main="TBA", xlab="x TBA", 
        axes=FALSE, frame.plot=FALSE, col=coll, lty=rep(1,3))
# axes= do you want standart axis or make your own?
# frame.plot= frame arround plot yes/no

matpoints(mat, pch=rep(17,3), col=coll, ad=TRUE)
# to add points, pch controlls for type of points

axis(side=1, 1:4, labels=rownames(mat))
axis(side=2, 60:95, labels=60:95)
legend("topleft",# position
       legend=c("maraqa", "aqua", "mar"),# names in legend,
       lty=c(1,1,1),# type of filling in this case solide line,
       col = coll,# colour of filling, 
       cex=0.7)# scaling parameter
于 2013-08-07T09:13:15.707 回答