【发布时间】:2021-06-02 12:20:03
【问题描述】:
所以,我有一个有序列表,例如:
(1, 2, 3, 4, 5, 6, 7, 8)
然后我有多个排列,比如说:
(3, 2, 5, 4, 1, 6, 7, 8),
(7, 2, 4, 1, 3, 5, 8, 6),
...
现在,我需要使用相同的有序列表分别绘制每个排列(在一个新的绘图中),这样我就形成了一个坐标散点图。
-
所以,对于第一个排列,我需要绘制 (1,3), (2,2), (3,5), (4,4), ...
-
对于第二个排列,我需要绘制 (1,7), (2,2), (3,4), (4,1), ...
类似这样的:
Example, where 'a' is the ordered list and 'b' is the first permutation
我为一对 + 排列对创建了这个,但我不知道如何使用多个排列对其进行缩放。我只是每次手动替换排列,但这样需要很长时间:
library(tidyverse)
ordered <- c(1, 2, 3, 4, 5, 6, 7, 8, 9)
permutation <- c(5, 7, 8, 6, 9, 4, 1, 3, 2)
coord.permutations <- data.frame(ordered,permutation)
ggplot(data=coord.permutations)+
geom_point(aes(ordered,permutation,size=3))+
scale_x_continuous(breaks = seq(0,(length(ordered)+1)), minor_breaks = seq(0,(length(ordered)+1)), expand = c(0,0), limits= c(0,(length(ordered)+1)))+
scale_y_continuous(breaks = seq(0,(length(ordered)+1)), minor_breaks = seq(0,(length(ordered)+1)), expand = c(0,0), limits= c(0,(length(ordered)+1)))+
coord_fixed()
提前感谢您的帮助!
【问题讨论】:
标签: r ggplot2 vector coordinates permutation