【发布时间】:2020-05-16 19:26:16
【问题描述】:
总的来说,我对编码和 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", etc) 以及尝试将其设为向量 (text = c("A",etc),但我不断收到错误。任何建议和资源将不胜感激。
【问题讨论】:
标签: r vector label scatter-plot