ggplot 不会标记点
我现在尝试了超过 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))
这不起作用...... 不能先绘制该层
I tried it now for over 1.5h but I can't get the labeling to work... :-\
I have the following matrix 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
I try to plot it with the following command
ggplot() + geom_point(data=data.frame(clVrd), mapping=aes(x=clVrd[,1], y=clVrd[,2], label=clVrd[,3]))
Even if I set the rownames in clVrd with
rownames(clVrd) <- seq(1:14)
It still don't work. The plot is drawn, but without labels...
Can someone tell my why?
Thanks for your help!
Update:
The way daroczig mentioned works, but I need to add the layer in a more complex plot.
The whole code is:
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))
and this don't work...
Plotting this layer first is not an option
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
首先,显示您的数据应该以一种可以轻松粘贴到其他人的 R 会话的方式(正如我在您的其他主题中所写的那样),例如:
或者像您一样,但没有行名称!不管怎样:
如果我是对的,
geom_point
只是没有label
参数,所以不值得尝试这种方式。您应该在打印点后添加一个额外的图层,例如在geom_text
的帮助下,例如:您可能希望将文本移至远离点的下方/左/右等处。
更新:基于OP更新
首先,正如@hadley指出的那样:将矩阵转换为数据框并命名变量是一个很好的实践:
根据上述命令扩展相当复杂的解决方案很容易:
我还添加了
theme_bw()
只是为了满足我的口味:) 这会导致:First of all, showing your data should be in a way that could be easily pasted to other's R sessions (as I wrote in your other topic also), like:
Or like you did, but without row names! Anyway:
If I am right,
geom_point
just do not have alabel
parameter, so it is not worth trying this way. You should add an extra layer after printing your points with e.g. the help ofgeom_text
, like:You might want to shift the text under/left/right etc. away from the points.
UPDATE: based on OP update
First, as @hadley pointed out: converting your matrices to data frames and naming variablesis a good practice:
Extending your quite complex solution is easy based on the above command:
I also added
theme_bw()
just to supply my taste :) This results in: