在ggplot

时间:2018-03-15 20:40:06

标签: r ggplot2

我有10个类似于以下2个输出的列表。列表存储如下。

List of 10
 $ : num [1:126] 0.931 0.981 0.983 0.984 0.995 ...
 $ : num [1:112] 0.963 0.979 0.993 0.99 0.992 ...
 $ : num [1:101] 0.913 0.979 0.997 0.98 0.991 ...
 $ : num [1:109] 0.87 0.933 0.953 0.962 0.979 ...

不同长度和未命名。

我在ggplot尝试做的是叠加并将所有列表叠加在一起。我试过循环,类似的ggplot列表情节,但似乎无法让ggplot绘制它们。

list(c(0.931035, 0.981379, 0.982759, 0.984138, 0.995172, 0.988276, 
0.993103, 0.990345, 0.990345, 0.990345, 0.994483, 0.998621, 0.998621, 
0.997241, 0.997241, 0.994483, 0.994483, 0.995862, 0.995862, 0.995862, 
0.990345, 0.994483, 0.993103, 0.993103, 0.994483, 0.993103, 0.993103, 
0.993103, 0.994483, 0.995862, 0.995862, 0.995862, 0.995862, 0.995862, 
0.995862, 0.995862, 0.995862, 0.995862, 0.995862, 0.998621, 0.998621, 
0.998621, 0.998621, 0.998621, 0.998621, 0.998621, 0.998621, 0.998621, 
0.998621, 0.998621, 0.998621, 0.998621, 0.998621, 0.998621, 0.998621, 
0.998621, 0.998621, 0.998621, 0.998621, 0.998621, 0.998621, 0.998621, 
0.998621, 0.998621, 0.998621, 0.998621, 0.998621, 0.998621, 0.998621, 
0.998621, 0.998621, 0.998621, 0.998621, 0.998621, 0.998621, 0.998621, 
0.998621, 0.998621, 0.998621, 0.998621, 0.998621, 0.998621, 0.998621, 
0.998621, 0.998621, 0.998621, 0.998621, 0.998621, 0.998621, 0.998621, 
0.998621, 0.998621, 0.998621, 0.998621, 0.998621, 0.998621, 0.998621, 
0.998621, 0.998621, 0.998621, 0.998621, 0.998621, 0.998621, 0.998621, 
0.998621, 0.998621, 0.998621, 0.998621, 0.998621, 0.998621, 0.998621, 
0.998621, 0.998621, 0.998621, 0.998621, 0.998621, 0.998621, 0.998621, 
0.998621, 0.998621, 0.998621, 0.998621, 0.998621, 0.998621, 0.998621, 
0.998621), c(0.963194, 0.979167, 0.993056, 0.990278, 0.992361, 
0.99375, 0.988194, 0.986806, 0.990972, 0.992361, 0.992361, 0.99375, 
0.99375, 0.99375, 0.990972, 0.994444, 0.995833, 0.993056, 0.993056, 
0.991667, 0.991667, 0.991667, 0.993056, 0.993056, 0.993056, 0.993056, 
0.993056, 0.993056, 0.993056, 0.993056, 0.993056, 0.993056, 0.993056, 
0.993056, 0.993056, 0.993056, 0.993056, 0.994444, 0.995833, 0.995833, 
0.995833, 0.995833, 0.995833, 0.995833, 0.995833, 0.995833, 0.995833, 
0.997222, 0.997222, 0.997222, 0.995833, 0.995833, 0.995833, 0.995833, 
0.995833, 0.995833, 0.998611, 0.998611, 0.997222, 0.997222, 0.997222, 
0.997222, 0.997222, 0.997222, 0.997222, 0.997222, 0.997222, 0.997222, 
0.998611, 0.998611, 0.998611, 0.998611, 0.998611, 0.998611, 0.998611, 
0.998611, 0.998611, 0.998611, 0.998611, 0.998611, 0.998611, 0.998611, 
0.998611, 0.998611, 0.998611, 0.998611, 0.998611, 0.998611, 0.998611, 
0.998611, 0.998611, 0.998611, 0.998611, 0.998611, 0.998611, 0.998611, 
0.998611, 0.998611, 0.998611, 0.998611, 0.998611, 0.998611, 0.998611, 
0.998611, 0.998611, 0.998611, 0.998611, 0.998611, 0.998611, 0.998611, 
0.998611, 0.998611), c(0.913462, 0.978709, 0.996566, 0.980082, 
0.991071, 0.994505, 0.995879, 0.995879, 0.998626, 1, 1, 1, 1, 
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.998626, 
0.998626, 0.998626, 0.998626, 0.998626, 0.998626, 0.997253, 0.997253, 
0.997253, 0.998626, 0.997253, 0.998626, 0.998626, 0.998626, 0.998626, 
0.998626, 0.998626, 0.998626, 0.998626, 0.998626, 0.998626, 0.998626, 
0.998626, 0.998626, 0.998626, 0.998626, 0.998626, 0.998626, 0.998626, 
0.998626, 0.998626, 0.998626, 0.998626, 0.998626, 0.998626, 0.998626, 
0.998626, 0.998626, 0.998626, 0.998626, 0.998626, 0.998626, 0.998626, 
0.998626, 0.998626, 0.998626, 0.998626, 0.998626, 0.998626, 0.998626, 
0.998626, 0.998626, 0.998626, 0.998626, 0.998626, 0.998626, 0.998626, 
0.998626, 0.998626, 0.998626, 0.998626, 0.998626, 0.998626, 0.998626, 
0.998626, 0.998626, 0.998626, 0.998626, 0.998626, 0.998626, 0.998626
), c(0.869505, 0.933379, 0.953297, 0.961538, 0.979396, 0.975275, 
0.982143, 0.982143, 0.983516, 0.982143, 0.986264, 0.986264, 0.989011, 
0.987637, 0.989011, 0.989011, 0.987637, 0.989011, 0.989011, 0.989011, 
0.990385, 0.989011, 0.990385, 0.987637, 0.987637, 0.990385, 0.989011, 
0.989011, 0.989011, 0.989011, 0.989011, 0.989011, 0.990385, 0.990385, 
0.989011, 0.989011, 0.989011, 0.989011, 0.990385, 0.990385, 0.990385, 
0.990385, 0.990385, 0.989011, 0.989011, 0.989011, 0.989011, 0.990385, 
0.990385, 0.989011, 0.989011, 0.989011, 0.989011, 0.989011, 0.989011, 
0.989011, 0.989011, 0.989011, 0.990385, 0.990385, 0.989011, 0.989011, 
0.989011, 0.989011, 0.989011, 0.990385, 0.990385, 0.990385, 0.990385, 
0.990385, 0.990385, 0.990385, 0.989011, 0.989011, 0.987637, 0.989011, 
0.989011, 0.989011, 0.989011, 0.989011, 0.990385, 0.990385, 0.990385, 
0.990385, 0.990385, 0.990385, 0.991758, 0.991758, 0.991758, 0.991758, 
0.991758, 0.991758, 0.991758, 0.990385, 0.990385, 0.990385, 0.990385, 
0.991758, 0.991758, 0.991758, 0.991758, 0.991758, 0.991758, 0.991758, 
0.991758, 0.991758, 0.991758, 0.991758, 0.991758), c(0.922069, 
0.971724, 0.97931, 0.972414, 0.975172, 0.982759, 0.982759, 0.982759, 
0.983448, 0.984828, 0.986207, 0.987586, 0.987586, 0.988966, 0.987586, 
0.987586, 0.988966, 0.987586, 0.984828, 0.987586, 0.986207, 0.987586, 
0.988966, 0.988966, 0.988966, 0.988966, 0.988966, 0.990345, 0.988966, 
0.990345, 0.990345, 0.990345, 0.991724, 0.990345, 0.991724, 0.991724, 
0.991724, 0.991724, 0.988966, 0.988966, 0.988966, 0.988966, 0.990345, 
0.991724, 0.991724, 0.990345, 0.991724, 0.991724, 0.991724, 0.991724, 
0.991724, 0.991724, 0.991724, 0.991724, 0.991724, 0.991724, 0.991724, 
0.991724, 0.991724, 0.991724, 0.991724, 0.991724, 0.991724, 0.991724, 
0.991724, 0.991724, 0.991724, 0.991724, 0.991724, 0.991724, 0.991724, 
0.991724, 0.991724, 0.991724, 0.991724, 0.991724, 0.991724, 0.991724, 
0.991724, 0.991724, 0.991724, 0.991724, 0.991724, 0.991724, 0.991724, 
0.991724, 0.991724, 0.991724, 0.991724, 0.991724, 0.991724, 0.991724, 
0.991724, 0.993103, 0.993103, 0.994483, 0.994483, 0.993103, 0.993103, 
0.993103, 0.994483, 0.993103, 0.994483, 0.995862, 0.995862))

编辑:更多信息

plot(list[[2]]) 

给出以下输出。

enter image description here

我正在尝试的是(现在只是绘制一个线图)所有列表项。

1 个答案:

答案 0 :(得分:1)

您可以import sys from PyQt5.QtWidgets import * app = QApplication(sys.argv) ID = 17452 aLink = " <a href='http://***/archive/edit?id=%s'>%s</a>" % (ID, ID) w = QTextBrowser() w.append(aLink) w.show() sys.exit(app.exec_()) stacklistdata.frame条目(我假设list被称为lst,请参阅下面的示例数据);然后使用ggplot

# Name list entries
names(lst) <- paste0("L", 1:length(lst));

# Stack and plot
library(tidyverse);
stack(lst) %>%
    group_by(ind) %>%
    mutate(x = 1:n()) %>%
    ggplot(aes(x, values, colour = ind)) + geom_line();

enter image description here

样本数据

lst <- list(c(0.931035, 0.981379, 0.982759, 0.984138, 0.995172, 0.988276,
0.993103, 0.990345, 0.990345, 0.990345, 0.994483, 0.998621, 0.998621,
0.997241, 0.997241, 0.994483, 0.994483, 0.995862, 0.995862, 0.995862,
0.990345, 0.994483, 0.993103, 0.993103, 0.994483, 0.993103, 0.993103,
0.993103, 0.994483, 0.995862, 0.995862, 0.995862, 0.995862, 0.995862,
0.995862, 0.995862, 0.995862, 0.995862, 0.995862, 0.998621, 0.998621,
0.998621, 0.998621, 0.998621, 0.998621, 0.998621, 0.998621, 0.998621,
0.998621, 0.998621, 0.998621, 0.998621, 0.998621, 0.998621, 0.998621,
0.998621, 0.998621, 0.998621, 0.998621, 0.998621, 0.998621, 0.998621,
0.998621, 0.998621, 0.998621, 0.998621, 0.998621, 0.998621, 0.998621,
0.998621, 0.998621, 0.998621, 0.998621, 0.998621, 0.998621, 0.998621,
0.998621, 0.998621, 0.998621, 0.998621, 0.998621, 0.998621, 0.998621,
0.998621, 0.998621, 0.998621, 0.998621, 0.998621, 0.998621, 0.998621,
0.998621, 0.998621, 0.998621, 0.998621, 0.998621, 0.998621, 0.998621,
0.998621, 0.998621, 0.998621, 0.998621, 0.998621, 0.998621, 0.998621,
0.998621, 0.998621, 0.998621, 0.998621, 0.998621, 0.998621, 0.998621,
0.998621, 0.998621, 0.998621, 0.998621, 0.998621, 0.998621, 0.998621,
0.998621, 0.998621, 0.998621, 0.998621, 0.998621, 0.998621, 0.998621,
0.998621), c(0.963194, 0.979167, 0.993056, 0.990278, 0.992361,
0.99375, 0.988194, 0.986806, 0.990972, 0.992361, 0.992361, 0.99375,
0.99375, 0.99375, 0.990972, 0.994444, 0.995833, 0.993056, 0.993056,
0.991667, 0.991667, 0.991667, 0.993056, 0.993056, 0.993056, 0.993056,
0.993056, 0.993056, 0.993056, 0.993056, 0.993056, 0.993056, 0.993056,
0.993056, 0.993056, 0.993056, 0.993056, 0.994444, 0.995833, 0.995833,
0.995833, 0.995833, 0.995833, 0.995833, 0.995833, 0.995833, 0.995833,
0.997222, 0.997222, 0.997222, 0.995833, 0.995833, 0.995833, 0.995833,
0.995833, 0.995833, 0.998611, 0.998611, 0.997222, 0.997222, 0.997222,
0.997222, 0.997222, 0.997222, 0.997222, 0.997222, 0.997222, 0.997222,
0.998611, 0.998611, 0.998611, 0.998611, 0.998611, 0.998611, 0.998611,
0.998611, 0.998611, 0.998611, 0.998611, 0.998611, 0.998611, 0.998611,
0.998611, 0.998611, 0.998611, 0.998611, 0.998611, 0.998611, 0.998611,
0.998611, 0.998611, 0.998611, 0.998611, 0.998611, 0.998611, 0.998611,
0.998611, 0.998611, 0.998611, 0.998611, 0.998611, 0.998611, 0.998611,
0.998611, 0.998611, 0.998611, 0.998611, 0.998611, 0.998611, 0.998611,
0.998611, 0.998611), c(0.913462, 0.978709, 0.996566, 0.980082,
0.991071, 0.994505, 0.995879, 0.995879, 0.998626, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0.998626,
0.998626, 0.998626, 0.998626, 0.998626, 0.998626, 0.997253, 0.997253,
0.997253, 0.998626, 0.997253, 0.998626, 0.998626, 0.998626, 0.998626,
0.998626, 0.998626, 0.998626, 0.998626, 0.998626, 0.998626, 0.998626,
0.998626, 0.998626, 0.998626, 0.998626, 0.998626, 0.998626, 0.998626,
0.998626, 0.998626, 0.998626, 0.998626, 0.998626, 0.998626, 0.998626,
0.998626, 0.998626, 0.998626, 0.998626, 0.998626, 0.998626, 0.998626,
0.998626, 0.998626, 0.998626, 0.998626, 0.998626, 0.998626, 0.998626,
0.998626, 0.998626, 0.998626, 0.998626, 0.998626, 0.998626, 0.998626,
0.998626, 0.998626, 0.998626, 0.998626, 0.998626, 0.998626, 0.998626,
0.998626, 0.998626, 0.998626, 0.998626, 0.998626, 0.998626, 0.998626
), c(0.869505, 0.933379, 0.953297, 0.961538, 0.979396, 0.975275,
0.982143, 0.982143, 0.983516, 0.982143, 0.986264, 0.986264, 0.989011,
0.987637, 0.989011, 0.989011, 0.987637, 0.989011, 0.989011, 0.989011,
0.990385, 0.989011, 0.990385, 0.987637, 0.987637, 0.990385, 0.989011,
0.989011, 0.989011, 0.989011, 0.989011, 0.989011, 0.990385, 0.990385,
0.989011, 0.989011, 0.989011, 0.989011, 0.990385, 0.990385, 0.990385,
0.990385, 0.990385, 0.989011, 0.989011, 0.989011, 0.989011, 0.990385,
0.990385, 0.989011, 0.989011, 0.989011, 0.989011, 0.989011, 0.989011,
0.989011, 0.989011, 0.989011, 0.990385, 0.990385, 0.989011, 0.989011,
0.989011, 0.989011, 0.989011, 0.990385, 0.990385, 0.990385, 0.990385,
0.990385, 0.990385, 0.990385, 0.989011, 0.989011, 0.987637, 0.989011,
0.989011, 0.989011, 0.989011, 0.989011, 0.990385, 0.990385, 0.990385,
0.990385, 0.990385, 0.990385, 0.991758, 0.991758, 0.991758, 0.991758,
0.991758, 0.991758, 0.991758, 0.990385, 0.990385, 0.990385, 0.990385,
0.991758, 0.991758, 0.991758, 0.991758, 0.991758, 0.991758, 0.991758,
0.991758, 0.991758, 0.991758, 0.991758, 0.991758), c(0.922069,
0.971724, 0.97931, 0.972414, 0.975172, 0.982759, 0.982759, 0.982759,
0.983448, 0.984828, 0.986207, 0.987586, 0.987586, 0.988966, 0.987586,
0.987586, 0.988966, 0.987586, 0.984828, 0.987586, 0.986207, 0.987586,
0.988966, 0.988966, 0.988966, 0.988966, 0.988966, 0.990345, 0.988966,
0.990345, 0.990345, 0.990345, 0.991724, 0.990345, 0.991724, 0.991724,
0.991724, 0.991724, 0.988966, 0.988966, 0.988966, 0.988966, 0.990345,
0.991724, 0.991724, 0.990345, 0.991724, 0.991724, 0.991724, 0.991724,
0.991724, 0.991724, 0.991724, 0.991724, 0.991724, 0.991724, 0.991724,
0.991724, 0.991724, 0.991724, 0.991724, 0.991724, 0.991724, 0.991724,
0.991724, 0.991724, 0.991724, 0.991724, 0.991724, 0.991724, 0.991724,
0.991724, 0.991724, 0.991724, 0.991724, 0.991724, 0.991724, 0.991724,
0.991724, 0.991724, 0.991724, 0.991724, 0.991724, 0.991724, 0.991724,
0.991724, 0.991724, 0.991724, 0.991724, 0.991724, 0.991724, 0.991724,
0.991724, 0.993103, 0.993103, 0.994483, 0.994483, 0.993103, 0.993103,
0.993103, 0.994483, 0.993103, 0.994483, 0.995862, 0.995862))