我现在尝试了1.5小时以上,但是无法正常工作...:-\

我有以下矩阵clVrd

            [,1]        [,2] [,3]
 [1,]  0.6618725 -0.04065907    1
 [2,]  0.4646620  0.09859806    2
 [3,]  0.9388307  0.05681554    3
 [4,]  1.1809942  0.12906415    4
 [5,]  1.5476428  0.49644973    5
 [6,] -0.1855485  0.30445869    6
 [7,]  0.4525888  0.49559198    7
 [8,] -0.4004534 -0.06419374    8
 [9,] -1.0669191  0.17292748    9
[10,] -0.9372038  0.02601539   10
[11,]  0.5617849 -5.21857716   11
[12,] -0.9370099 -0.05539107   12
[13,]  0.6803453  0.21223368   13
[14,]  1.3040601  0.47598799   14

我尝试使用以下命令绘制它
ggplot() + geom_point(data=data.frame(clVrd), mapping=aes(x=clVrd[,1], y=clVrd[,2], label=clVrd[,3]))

即使我用clVrd设置行名
rownames(clVrd) <- seq(1:14)

它仍然不起作用。绘制了情节,但没有标签...
有人可以告诉我为什么吗?

谢谢你的帮助!

更新:
daroczig提到的方式有效,但是我需要在更复杂的图中添加图层。

整个代码是:
ggplot() + geom_segment(data=data.frame(test), aes(x=lines[,1], y=lines[,2], xend=lines[,3], yend=lines[,4]), color='grey', alpha = I(0.2)) +
  layer(data=data.frame(clVrd), mapping=aes(x=clVrd[,1], y=clVrd[,2], label=clVrd[,3]), geom = "point", stat="identity", size = I(4), color='black', shape=2) +
  layer(data=data.frame(mid), mapping=aes(x=mid[,1], y=mid[,2]), geom = "point", stat="identity", size = I(4), color='black', shape=22) +
  opts(legend.position = "none") +
  scale_x_continuous('Dimension 1') +
  scale_y_continuous('Dimension 2') +
  opts(axis.title.y = theme_text(vjust=0.2, angle=90)) +
  opts(axis.title.x = theme_text(vjust=0.2, angle=0))

clVrd <- structure(c(0.661872475367366, 0.464661963750941, 0.938830748772559,
1.18099419280727, 1.54764276890947, -0.185548540145922, 0.452588804431998,
-0.400453362842998, -1.06691910257802, -0.937203794581474, 0.56178488859136,
-0.937009852049824, 0.680345320757602, 1.30406005677017, -0.0406590744874299,
0.0985980588613432, 0.0568155367351373, 0.129064147637601, 0.496449734351345,
0.304458694719769, 0.495591983450893, -0.0641937419346143, 0.172927477311218,
0.0260153913187109, -5.21857716109913, -0.0553910678963988, 0.212233679072247,
0.475987991276203, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13,
14), .Dim = c(14L, 3L))

mid <- structure(c(-0.195877196644293, 0.511580674503935, -0.658596511353487,
0.468086299528672, -1.24317797052758, -2.35077729859073, -0.55472838558667,
0.131409158984094, 0.759205542363384, 0.824786100242867, -1.86673280298486,
-0.482522295670435, 0.301242780883547, 0.414223673077983, 0.262357298984787,
-1.49648725810236, 0.238301422916755, 0.0954886028288132, -2.13935195209412,
0.340899933083442, -0.816182528789355, 0.515281428093344, 0.134447522792538,
-4.09755608083992), .Dim = c(12L, 2L))

lines <- structure(c(0.661872475367366, 0.661872475367366, 0.661872475367366,
0.661872475367366, 0.661872475367366, 0.661872475367366, 0.661872475367366,
0.661872475367366, 0.661872475367366, 0.661872475367366, 0.464661963750941,
0.464661963750941, 0.464661963750941, 0.464661963750941, 0.464661963750941,
0.464661963750941, 0.464661963750941, 0.464661963750941, 0.464661963750941,
0.464661963750941, 0.938830748772559, 0.938830748772559, 0.938830748772559,
0.938830748772559, 0.938830748772559, 0.938830748772559, 0.938830748772559,
0.938830748772559, 0.938830748772559, 0.938830748772559, 1.18099419280727,
1.18099419280727, 1.18099419280727, 1.18099419280727, 1.18099419280727,
1.18099419280727, 1.18099419280727, 1.18099419280727, 1.18099419280727,
1.18099419280727, 1.54764276890947, 1.54764276890947, 1.54764276890947,
1.54764276890947, 1.54764276890947, 1.54764276890947, 1.54764276890947,
1.54764276890947, 1.54764276890947, -0.185548540145922, -0.185548540145922,
-0.185548540145922, -0.185548540145922, -0.185548540145922, -0.185548540145922,
-0.185548540145922, -0.185548540145922, -0.185548540145922, -0.185548540145922,
-0.185548540145922, 0.452588804431998, 0.452588804431998, 0.452588804431998,
0.452588804431998, 0.452588804431998, 0.452588804431998, 0.452588804431998,
0.452588804431998, 0.452588804431998, 0.452588804431998, -0.400453362842998,
-0.400453362842998, -0.400453362842998, -0.400453362842998, -0.400453362842998,
-0.400453362842998, -0.400453362842998, -0.400453362842998, -0.400453362842998,
-0.400453362842998, -0.400453362842998, -1.06691910257802, -1.06691910257802,
-1.06691910257802, -1.06691910257802, -1.06691910257802, -1.06691910257802,
-1.06691910257802, -1.06691910257802, -1.06691910257802, -1.06691910257802,
-1.06691910257802, -1.06691910257802, -0.937203794581474, -0.937203794581474,
-0.937203794581474, -0.937203794581474, -0.937203794581474, -0.937203794581474,
-0.937203794581474, -0.937203794581474, -0.937203794581474, -0.937203794581474,
-0.937203794581474, -0.937203794581474, 0.56178488859136, 0.56178488859136,
0.56178488859136, 0.56178488859136, -0.937009852049824, -0.937009852049824,
-0.937009852049824, -0.937009852049824, -0.937009852049824, -0.937009852049824,
-0.937009852049824, -0.937009852049824, -0.937009852049824, -0.937009852049824,
-0.937009852049824, -0.937009852049824, 0.680345320757602, 0.680345320757602,
0.680345320757602, 0.680345320757602, 0.680345320757602, 0.680345320757602,
0.680345320757602, 0.680345320757602, 0.680345320757602, 0.680345320757602,
-0.0406590744874299, -0.0406590744874299, -0.0406590744874299,
-0.0406590744874299, -0.0406590744874299, -0.0406590744874299,
-0.0406590744874299, -0.0406590744874299, -0.0406590744874299,
-0.0406590744874299, 0.0985980588613432, 0.0985980588613432,
0.0985980588613432, 0.0985980588613432, 0.0985980588613432, 0.0985980588613432,
0.0985980588613432, 0.0985980588613432, 0.0985980588613432, 0.0985980588613432,
0.0568155367351373, 0.0568155367351373, 0.0568155367351373, 0.0568155367351373,
0.0568155367351373, 0.0568155367351373, 0.0568155367351373, 0.0568155367351373,
0.0568155367351373, 0.0568155367351373, 0.129064147637601, 0.129064147637601,
0.129064147637601, 0.129064147637601, 0.129064147637601, 0.129064147637601,
0.129064147637601, 0.129064147637601, 0.129064147637601, 0.129064147637601,
0.496449734351345, 0.496449734351345, 0.496449734351345, 0.496449734351345,
0.496449734351345, 0.496449734351345, 0.496449734351345, 0.496449734351345,
0.496449734351345, 0.304458694719769, 0.304458694719769, 0.304458694719769,
0.304458694719769, 0.304458694719769, 0.304458694719769, 0.304458694719769,
0.304458694719769, 0.304458694719769, 0.304458694719769, 0.304458694719769,
0.495591983450893, 0.495591983450893, 0.495591983450893, 0.495591983450893,
0.495591983450893, 0.495591983450893, 0.495591983450893, 0.495591983450893,
0.495591983450893, 0.495591983450893, -0.0641937419346143, -0.0641937419346143,
-0.0641937419346143, -0.0641937419346143, -0.0641937419346143,
-0.0641937419346143, -0.0641937419346143, -0.0641937419346143,
-0.0641937419346143, -0.0641937419346143, -0.0641937419346143,
0.172927477311218, 0.172927477311218, 0.172927477311218, 0.172927477311218,
0.172927477311218, 0.172927477311218, 0.172927477311218, 0.172927477311218,
0.172927477311218, 0.172927477311218, 0.172927477311218, 0.172927477311218,
0.0260153913187109, 0.0260153913187109, 0.0260153913187109, 0.0260153913187109,
0.0260153913187109, 0.0260153913187109, 0.0260153913187109, 0.0260153913187109,
0.0260153913187109, 0.0260153913187109, 0.0260153913187109, 0.0260153913187109,
-5.21857716109913, -5.21857716109913, -5.21857716109913, -5.21857716109913,
-0.0553910678963988, -0.0553910678963988, -0.0553910678963988,
-0.0553910678963988, -0.0553910678963988, -0.0553910678963988,
-0.0553910678963988, -0.0553910678963988, -0.0553910678963988,
-0.0553910678963988, -0.0553910678963988, -0.0553910678963988,
0.212233679072247, 0.212233679072247, 0.212233679072247, 0.212233679072247,
0.212233679072247, 0.212233679072247, 0.212233679072247, 0.212233679072247,
0.212233679072247, 0.212233679072247, -0.195877196644293, 0.511580674503935,
-0.658596511353487, 0.468086299528672, -1.24317797052758, -0.55472838558667,
0.131409158984094, 0.759205542363384, 0.824786100242867, -0.482522295670435,
-0.195877196644293, 0.511580674503935, -0.658596511353487, 0.468086299528672,
-1.24317797052758, -0.55472838558667, 0.131409158984094, 0.759205542363384,
0.824786100242867, -0.482522295670435, -0.195877196644293, 0.511580674503935,
-0.658596511353487, 0.468086299528672, -1.24317797052758, -0.55472838558667,
0.131409158984094, 0.759205542363384, 0.824786100242867, -0.482522295670435,
-0.195877196644293, 0.511580674503935, -0.658596511353487, 0.468086299528672,
-1.24317797052758, -0.55472838558667, 0.131409158984094, 0.759205542363384,
0.824786100242867, -0.482522295670435, -0.195877196644293, 0.511580674503935,
-0.658596511353487, 0.468086299528672, -0.55472838558667, 0.131409158984094,
0.759205542363384, 0.824786100242867, -0.482522295670435, -0.195877196644293,
0.511580674503935, -0.658596511353487, 0.468086299528672, -1.24317797052758,
-0.55472838558667, 0.131409158984094, 0.759205542363384, 0.824786100242867,
-1.86673280298486, -0.482522295670435, -0.195877196644293, 0.511580674503935,
-0.658596511353487, 0.468086299528672, -1.24317797052758, -0.55472838558667,
0.131409158984094, 0.759205542363384, 0.824786100242867, -0.482522295670435,
-0.195877196644293, 0.511580674503935, -0.658596511353487, 0.468086299528672,
-1.24317797052758, -0.55472838558667, 0.131409158984094, 0.759205542363384,
0.824786100242867, -1.86673280298486, -0.482522295670435, -0.195877196644293,
0.511580674503935, -0.658596511353487, 0.468086299528672, -1.24317797052758,
-2.35077729859073, -0.55472838558667, 0.131409158984094, 0.759205542363384,
0.824786100242867, -1.86673280298486, -0.482522295670435, -0.195877196644293,
0.511580674503935, -0.658596511353487, 0.468086299528672, -1.24317797052758,
-2.35077729859073, -0.55472838558667, 0.131409158984094, 0.759205542363384,
0.824786100242867, -1.86673280298486, -0.482522295670435, 0.468086299528672,
-0.55472838558667, 0.759205542363384, -0.482522295670435, -0.195877196644293,
0.511580674503935, -0.658596511353487, 0.468086299528672, -1.24317797052758,
-2.35077729859073, -0.55472838558667, 0.131409158984094, 0.759205542363384,
0.824786100242867, -1.86673280298486, -0.482522295670435, -0.195877196644293,
0.511580674503935, -0.658596511353487, 0.468086299528672, -1.24317797052758,
-0.55472838558667, 0.131409158984094, 0.759205542363384, 0.824786100242867,
-0.482522295670435, 0.301242780883547, 0.414223673077983, 0.262357298984787,
-1.49648725810236, 0.238301422916755, -2.13935195209412, 0.340899933083442,
-0.816182528789355, 0.515281428093344, -4.09755608083992, 0.301242780883547,
0.414223673077983, 0.262357298984787, -1.49648725810236, 0.238301422916755,
-2.13935195209412, 0.340899933083442, -0.816182528789355, 0.515281428093344,
-4.09755608083992, 0.301242780883547, 0.414223673077983, 0.262357298984787,
-1.49648725810236, 0.238301422916755, -2.13935195209412, 0.340899933083442,
-0.816182528789355, 0.515281428093344, -4.09755608083992, 0.301242780883547,
0.414223673077983, 0.262357298984787, -1.49648725810236, 0.238301422916755,
-2.13935195209412, 0.340899933083442, -0.816182528789355, 0.515281428093344,
-4.09755608083992, 0.301242780883547, 0.414223673077983, 0.262357298984787,
-1.49648725810236, -2.13935195209412, 0.340899933083442, -0.816182528789355,
0.515281428093344, -4.09755608083992, 0.301242780883547, 0.414223673077983,
0.262357298984787, -1.49648725810236, 0.238301422916755, -2.13935195209412,
0.340899933083442, -0.816182528789355, 0.515281428093344, 0.134447522792538,
-4.09755608083992, 0.301242780883547, 0.414223673077983, 0.262357298984787,
-1.49648725810236, 0.238301422916755, -2.13935195209412, 0.340899933083442,
-0.816182528789355, 0.515281428093344, -4.09755608083992, 0.301242780883547,
0.414223673077983, 0.262357298984787, -1.49648725810236, 0.238301422916755,
-2.13935195209412, 0.340899933083442, -0.816182528789355, 0.515281428093344,
0.134447522792538, -4.09755608083992, 0.301242780883547, 0.414223673077983,
0.262357298984787, -1.49648725810236, 0.238301422916755, 0.0954886028288132,
-2.13935195209412, 0.340899933083442, -0.816182528789355, 0.515281428093344,
0.134447522792538, -4.09755608083992, 0.301242780883547, 0.414223673077983,
0.262357298984787, -1.49648725810236, 0.238301422916755, 0.0954886028288132,
-2.13935195209412, 0.340899933083442, -0.816182528789355, 0.515281428093344,
0.134447522792538, -4.09755608083992, -1.49648725810236, -2.13935195209412,
-0.816182528789355, -4.09755608083992, 0.301242780883547, 0.414223673077983,
0.262357298984787, -1.49648725810236, 0.238301422916755, 0.0954886028288132,
-2.13935195209412, 0.340899933083442, -0.816182528789355, 0.515281428093344,
0.134447522792538, -4.09755608083992, 0.301242780883547, 0.414223673077983,
0.262357298984787, -1.49648725810236, 0.238301422916755, -2.13935195209412,
0.340899933083442, -0.816182528789355, 0.515281428093344, -4.09755608083992
), .Dim = c(131L, 4L))

这不起作用...
不能先绘制该层

最佳答案

首先,显示数据的方式应易于粘贴到其他人的R会话中(就像我在其他主题中所写的一样),例如:

> dput(clVrd)
structure(list(x = c(0.464662, 0.9388307, 1.1809942, 1.5476428,
-0.1855485, 0.4525888, -0.4004534, -1.0669191, -0.9372038, 0.5617849,
-0.9370099, 0.6803453, 1.3040601), y = c(0.09859806, 0.05681554,
0.12906415, 0.49644973, 0.30445869, 0.49559198, -0.06419374,
0.17292748, 0.02601539, -5.21857716, -0.05539107, 0.21223368,
0.47598799), label = 2:14), .Names = c("x", "y", "label"), class = "data.frame", row.names = c(NA,
-13L))

还是像您一样,但是没有行名!无论如何:

如果我是对的,则geom_point只是没有label参数,因此不值得尝试这种方式。您可以通过以下方式打印点后再添加一个额外的图层: geom_text的帮助,例如:
ggplot(clVrd, aes(x=x, y=y, label=label)) + geom_point() + geom_text()

您可能希望将文本在下方/向左/向右等移动,远离这些点。

UPDATE :基于OP更新

首先,正如@hadley所指出的:将矩阵转换为数据帧并命名变量是一种好习惯:
clVdr <- as.data.frame(clVdr)
names(clVdr) <- c('x', 'y', 'label')
mid <- as.data.frame(mid)
names(mid) <- c('x', 'y')
lines <- as.data.frame(lines)
names(lines) <- c('x', 'y', 'xend', 'yend')

根据上述命令,可以轻松扩展相当复杂的解决方案:
ggplot(mapping = aes(x, y)) +
  geom_segment(data=lines, aes(xend = xend, yend = yend),
    color = 'grey', alpha = 0.2) +
  geom_point(data = clVdr, size = 4, shape = 2) +
  geom_point(data = mid, size = 4, shape = 22) +
  geom_text(data = clVdr, aes(label=label), hjust = 0, vjust = 0) +
  opts(legend.position = "none") +
  scale_x_continuous('Dimension 1') +
  scale_y_continuous('Dimension 2') +
  opts(axis.title.y = theme_text(vjust = 0.2, angle = 90)) +
  opts(axis.title.x = theme_text(vjust = 0.2, angle = 0)) +
  theme_bw()

我还添加了theme_bw()只是为了提供我的口味:)结果是:

09-06 08:29