组x轴值R

组x轴值R,r,ggplot2,R,Ggplot2,当我试图绘制图形时,我的所有x轴值都相互重叠 cdf <- ggplot(meltedData2, aes(x=id,group=1))+geom_line(aes(y=value,colour=variable),stat="identity") cdf <- cdf + labs(x=xAxis, y=yAxis, title=title, ps=30)+scale_x_discrete(limits=id) dput(头部(熔化数据2)) 能否添加数据集的示例?有关如何包含可

当我试图绘制图形时,我的所有x轴值都相互重叠

cdf <- ggplot(meltedData2, aes(x=id,group=1))+geom_line(aes(y=value,colour=variable),stat="identity")
cdf <- cdf + labs(x=xAxis, y=yAxis, title=title, ps=30)+scale_x_discrete(limits=id)
dput(头部(熔化数据2))


能否添加数据集的示例?有关如何包含可复制示例的想法,请参阅。不使用命令
scale\u x\u discrete(limits=id)
应该可以工作。我刚刚删除了limits=id,现在我看到值没有按x轴进行数字排序。我的x轴看起来像100 20 40 60 80,应该是20 40 60 80100@TwinklingStar如前所述,例如使用
dput()
添加一些示例数据。x轴是离散轴还是连续轴?尝试删除完整的
scale\u x\u discrete(limits=id)
命令。当您错误地使用您认为是数字的x轴值,但实际上是字符或因子时,通常会发生这种情况。有时,当您不正确地导入数据时会发生这种情况,但如果没有其他注释中所述的更多信息,则无法确定。
cdf <- cdf + labs(x=xAxis, y=yAxis, title=title, ps=30)+scale_x_discrete(limits=id, breaks=pretty_breaks())
   rates<-data.frame(rates)
   id <- rownames(rates)
   rates <- cbind(id=id, rates)
   meltedData2 <- melt(rates,id.vars="id", na.rm = TRUE)
   print(meltedData2)
     id variable      value
1     1     run1 0.13661202
2     2     run1 0.54788419
3     3     run1 0.60124611
4     4     run1 0.58677686
5     5     run1 0.58219178
6     6     run1 0.66757493
7     7     run1 0.54103343
...........................
...........................
541 266     run2 0.61267606
542 267     run2 0.45714286
543 268     run2 0.53066038
544 269     run2 0.56542056
545 270     run2 0.55744681
546 271     run2 0.58429119
547 272     run2 0.55922330
548 273     run2 0.63581489
549 274     run2 0.57789855
550 275     run2 0.57085828
structure(list(id = structure(c(1L, 112L, 199L, 210L, 221L, 232L
), .Label = c("1", "10", "100", "101", "102", "103", "104", "105", 
"106", "107", "108", "109", "11", "110", "111", "112", "113", 
"114", "115", "116", "117", "118", "119", "12", "120", "121", 
"122", "123", "124", "125", "126", "127", "128", "129", "13", 
"130", "131", "132", "133", "134", "135", "136", "137", "138", 
"139", "14", "140", "141", "142", "143", "144", "145", "146", 
"147", "148", "149", "15", "150", "151", "152", "153", "154", 
"155", "156", "157", "158", "159", "16", "160", "161", "162", 
"163", "164", "165", "166", "167", "168", "169", "17", "170", 
"171", "172", "173", "174", "175", "176", "177", "178", "179", 
"18", "180", "181", "182", "183", "184", "185", "186", "187", 
"188", "189", "19", "190", "191", "192", "193", "194", "195", 
"196", "197", "198", "199", "2", "20", "200", "201", "202", "203", 
"204", "205", "206", "207", "208", "209", "21", "210", "211", 
"212", "213", "214", "215", "216", "217", "218", "219", "22", 
"220", "221", "222", "223", "224", "225", "226", "227", "228", 
"229", "23", "230", "231", "232", "233", "234", "235", "236", 
"237", "238", "239", "24", "240", "241", "242", "243", "244", 
"245", "246", "247", "248", "249", "25", "250", "251", "252", 
"253", "254", "255", "256", "257", "258", "259", "26", "260", 
"261", "262", "263", "264", "265", "266", "267", "268", "269", 
"27", "270", "271", "272", "273", "274", "275", "28", "29", "3", 
"30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "4", 
"40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "5", 
"50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "6", 
"60", "61", "62", "63", "64", "65", "66", "67", "68", "69", "7", 
"70", "71", "72", "73", "74", "75", "76", "77", "78", "79", "8", 
"80", "81", "82", "83", "84", "85", "86", "87", "88", "89", "9", 
"90", "91", "92", "93", "94", "95", "96", "97", "98", "99"), class = "factor"), 
    run1 = c(0.136612021857924, 0.547884187082405, 0.601246105919003, 
    0.586776859504132, 0.582191780821918, 0.667574931880109), 
    run2 = c(0.136612021857924, 0.547884187082405, 0.601246105919003, 
    0.586776859504132, 0.582191780821918, 0.667574931880109)), .Names = c("id", 
"run1", "run2"), row.names = c(NA, 6L), class = "data.frame")
structure(list(id = structure(c(1L, 112L, 199L, 210L, 221L, 232L
), .Label = c("1", "10", "100", "101", "102", "103", "104", "105", 
"106", "107", "108", "109", "11", "110", "111", "112", "113", 
"114", "115", "116", "117", "118", "119", "12", "120", "121", 
"122", "123", "124", "125", "126", "127", "128", "129", "13", 
"130", "131", "132", "133", "134", "135", "136", "137", "138", 
"139", "14", "140", "141", "142", "143", "144", "145", "146", 
"147", "148", "149", "15", "150", "151", "152", "153", "154", 
"155", "156", "157", "158", "159", "16", "160", "161", "162", 
"163", "164", "165", "166", "167", "168", "169", "17", "170", 
"171", "172", "173", "174", "175", "176", "177", "178", "179", 
"18", "180", "181", "182", "183", "184", "185", "186", "187", 
"188", "189", "19", "190", "191", "192", "193", "194", "195", 
"196", "197", "198", "199", "2", "20", "200", "201", "202", "203", 
"204", "205", "206", "207", "208", "209", "21", "210", "211", 
"212", "213", "214", "215", "216", "217", "218", "219", "22", 
"220", "221", "222", "223", "224", "225", "226", "227", "228", 
"229", "23", "230", "231", "232", "233", "234", "235", "236", 
"237", "238", "239", "24", "240", "241", "242", "243", "244", 
"245", "246", "247", "248", "249", "25", "250", "251", "252", 
"253", "254", "255", "256", "257", "258", "259", "26", "260", 
"261", "262", "263", "264", "265", "266", "267", "268", "269", 
"27", "270", "271", "272", "273", "274", "275", "28", "29", "3", 
"30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "4", 
"40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "5", 
"50", "51", "52", "53", "54", "55", "56", "57", "58", "59", "6", 
"60", "61", "62", "63", "64", "65", "66", "67", "68", "69", "7", 
"70", "71", "72", "73", "74", "75", "76", "77", "78", "79", "8", 
"80", "81", "82", "83", "84", "85", "86", "87", "88", "89", "9", 
"90", "91", "92", "93", "94", "95", "96", "97", "98", "99"), class = "factor"), 
    variable = structure(c(1L, 1L, 1L, 1L, 1L, 1L), .Label = c("run1", 
    "run2"), class = "factor"), value = c(0.136612021857924, 
    0.547884187082405, 0.601246105919003, 0.586776859504132, 
    0.582191780821918, 0.667574931880109)), .Names = c("id", 
"variable", "value"), row.names = c(NA, 6L), class = "data.frame")