一般来说,我对编码和R还是很陌生。我试图弄清楚如何创建作为单个点和向量的图。对于两个选项,我应该都得到相同的结果,但是我似乎无法弄清楚在使用向量时如何关联点的标签。
这是我的个人绘图和plot的代码
plot(
x = NULL,
xlim = c(0, 8),
ylim = c(0, 10),
main = "Problem 3a- Individual Points Fuction",
xlab = "x",
ylab = "y",
las = 1
)
text( 0.6, 7.5, "A" )
points( 1, 7, pch = 19, cex = 3, col = "navy" )
text( 3.4, 2.5, "B" )
points( 4, 3, pch = 15, cex = 6, col = "blueviolet" )
text( 5.6, 4.0, "C" )
points( 6, 5, pch = 17, cex = 4, col = "firebrick2" )
text( 1.6, 1.5, "D" )
points( 2, 2, pch = 18, cex = 5, col = "cyan3" )
text( 6.8, 3.5, "E" )
points( 7, 4, pch = 16, cex = 2, col = "seagreen3" )
这是我的矢量方法代码,带plot:
plot(
x = NULL,
xlim = c(0, 8),
ylim = c(0, 10),
main = "Problem 3b- Vector Points Fuction",
xlab = "x",
ylab = "y",
las = 1
)
points(
x = c(1, 4, 6, 2, 7),
y = c(7, 3, 5, 2, 4),
pch = c(19, 15, 17, 18, 16),
cex = c(3, 6, 4, 5, 2),
col = c("navy", "blueviolet", "firebrick2", "cyan3", "seagreen3"),
)
我似乎无法弄清楚如何标记矢量上的点,并在某些坐标上对其进行标记。我试过只把Text =(“ A”,“ B”,等等)以及试图也使它成为一个向量(text = c(“ A”,etc),但是我一直在出错,任何建议和资源将不胜感激。
一般来说,我对编码和R还是很陌生。我试图弄清楚如何创建作为单个点和向量的图。对于这两个选项,我应该得到相同的结果,但是我不能...
您可以如下所示使用text
功能。我添加了xDisp
变量以轻松设置标签位置(如果需要,您还可以为垂直位置添加yDisp
变量)。