自定义添加到ggplot的几何线的图例

问题描述 投票:0回答:1

我已将geom_lines添加到原本不想修改的绘图中。这些线与已经绘制的数据有关。

[如果您查看图,我想做的是在图例中显示geom_lines的颜色而不是线型。

!current output

我希望原型A线显示与原型A绘图相同的颜色,对于原型B线,则相同。我什至不需要显示线型,只需显示颜色即可。

我无法找到一种方法,而不会弄乱测试类型的图例。我看过类似的堆栈交换问题,但找不到可以帮助我解决此问题的答案。

下面的代码:

graphOutputCombined <- ggplot(Typebdata, aes(x = conc0, y = signal, color = "Prototype B")) +
  geom_point() +
  geom_ribbon(data=newdata_Typeb, aes(x=conc, y=p, ymin=pmin, ymax=pmax, color="Prototype B",  fill = "Prototype B"), alpha=0.2) +
  geom_line(data=newdata_Typeb, aes(x=conc, y=p, color = "Prototype B")) +
    geom_ribbon(data=newdata_TypeA, aes(x=conc, y=p, ymin=pmin, ymax=pmax, color = "Prototype A",  fill = "Prototype A"), alpha = 0.2) +
  geom_line(data=newdata_TypeA, aes(x=conc, y=p, color = "Prototype A")) +
  geom_point(data=TypeAdata2, aes(x=conc0, y=signal, color = "Prototype A")) +

  scale_x_log10(breaks= c(1, 10, 100, 1000)) +
  xlab("Concentration (pg/mL)") + ylab("Signal") +
    geom_vline(aes(xintercept = LODest_Typeb[1], linetype = "Prototype B", color = "Prototype B")) +
    geom_vline(aes(xintercept = LODest_TypeA[1], linetype = "Prototype A", color = "Prototype A")) +
    geom_hline(aes(yintercept = LOD_abs_cutoff_Typeb, linetype = "Prototype B", color = "Prototype B")) +
    geom_hline(aes(yintercept = LOD_abs_cutoff_TypeA, linetype = "Prototype A", color = "Prototype A")) +
  theme_bw() + theme(plot.title = element_text(hjust = 0.5)) + ggtitle("Dose Response")+
  scale_linetype_manual(name = "Limits of Detection", values = c(5,4,5, 4))+
  scale_fill_manual("Test Type",breaks = c("Prototype B", "Prototype A"), values = c("Prototype A" = "#0fafc1","Prototype B" = "#4286f4"))+
  scale_color_manual("Test Type", breaks = c( "Prototype B", "Prototype A"), values =c("Prototype B" = "#4286f4",  "Prototype A" = "#0fafc1"))+  
  labs(fill='LFA Type',
       color='LOD') 

包含重现当前图的数据的完整代码

rm(list = ls())
library(drc)
library(ggplot2)
library(dplyr)
Typebdata <- data.frame(
  signal = c(900.93, 578.52, 866.07, 263.91, 233.51, 284.09, 142.14,
             212.77, 152.03, 81.2, 91.43, 81.43, 70.93, 111.64, 81.28,
             91.43, 60.72, 60.89, 60.93, 70.96, 60.88),
  conc = c(800L, 800L, 800L, 400L, 400L, 400L, 200L, 200L, 200L, 100L,
           100L, 100L, 50L, 50L, 50L, 25L, 25L, 25L, 0L, 0L, 0L),
  conc0 = c(800, 800, 800, 400, 400, 400, 200, 200, 200, 100, 100, 100,
            50, 50, 50, 25, 25, 25, 2.5, 2.5, 2.5),
  ï..Sample.ID = as.factor(c("800-1", "800-2", "800-3", "400-1", "400-2",
                             "400-3", "200-1", "200-2", "200-3", "100-1",
                             "100-2", "100-3", "50-1", "50-2", "50-3", "25-1",
                             "25-2", "25-3", "0-1", "0-2", "0-3")),
  group = as.factor(c("Prototype B", "Prototype B", "Prototype B",
                      "Prototype B", "Prototype B", "Prototype B",
                      "Prototype B", "Prototype B", "Prototype B",
                      "Prototype B", "Prototype B", "Prototype B", "Prototype B",
                      "Prototype B", "Prototype B", "Prototype B",
                      "Prototype B", "Prototype B", "Prototype B",
                      "Prototype B", "Prototype B"))
)

typeadata <- data.frame(
  signal = c(121.46, 141.67, 223.27, 111.35, 152.23, 121.46, 60.76,
             71.5, 71.41, 91.89, 80.98, 71.47, 91.1, 81.72, 71.47,
             81.01, 81.72, 71.47, 71.47, 51.03, 71.72, 81.94, 50.75, 71.69),
  conc = c(1600L, 1600L, 1600L, 800L, 800L, 800L, 400L, 400L, 400L,
           200L, 200L, 200L, 100L, 100L, 100L, 50L, 50L, 50L, 25L,
           25L, 25L, 0L, 0L, 0L),
  ï..Sample.ID = as.factor(c("1600_a", "1600_b", "1600_c", "800_a", "800_b",
                             "800_c", "400_a", "400_b", "400_c", "200_a",
                             "200_b", "200_c", "100_a", "100_b", "100_c", "50_a",
                             "50_b", "50_c", "25_a", "25_b", "25_c", "0_a", "0_b",
                             "0_c")),
  group = as.factor(c("Prototype A", "Prototype A", "Prototype A",
                      "Prototype A", "Prototype A", "Prototype A",
                      "Prototype A", "Prototype A", "Prototype A",
                      "Prototype A", "Prototype A", "Prototype A", "Prototype A",
                      "Prototype A", "Prototype A", "Prototype A",
                      "Prototype A", "Prototype A", "Prototype A",
                      "Prototype A", "Prototype A", "Prototype A", "Prototype A",
                      "Prototype A"))
)

LODest_TypeA <-     c(739.975694651606)
LODest_Typeb <-     c(127.320897642717)
LOD_abs_cutoff_TypeA <- c(109.888021163345)
LOD_abs_cutoff_Typeb <- c(100.575760504039)

newdata_TypeA <-     data.frame(
  conc = c(2.5, 2.64999194539132, 2.80898292425554, 2.97751284960757,
           3.15615402750368, 3.34551310051965, 3.54623310783128,
           3.75899566889316, 3.98452329813109, 4.22358185850857,
           4.47698316229944, 4.74558772789842, 5.03030770203148,
           5.33210995728933, 5.65201937550302, 5.99112232811147, 6.35057036533979,
           6.73158412671649, 7.13545748620909, 7.5635619460545,
           8.01735129420508, 8.49836654120645, 9.00824115327205, 9.54870659932541,
           10.1215982308469, 10.7288615144925, 11.3725586386496,
           12.0548755163648, 12.7781292084246, 13.5447757917979,
           14.3574187001583, 15.2188175648121, 16.1318975860528, 17.099759466767,
           18.1256899420246, 19.2131729404102, 20.3659014149989,
           21.5877898841523, 22.8829877247215, 24.2558932628002,
           25.7111687098768, 27.2537559951083, 28.8888935474789, 30.6221340848345,
           32.4593634702017, 34.4068206994254, 36.4711190880003,
           38.6592687290433, 40.9787002986732, 43.4372902896355,
           46.0433877588634, 48.8058426798069, 51.7340359958095, 54.8379114765919,
           58.1280094860202, 61.6155027758334, 65.312234426878,
           69.2307580666944, 73.38438050003, 77.7872068970445,
           82.4541886926623, 87.4011743597323, 92.644963228413, 98.2033625345477,
           104.095247890758, 110.340627385608, 116.960709528515,
           123.977975271127, 131.416254349764, 139.300806208148,
           147.658405775244, 156.517434389488, 165.907976178182, 175.861920219343,
           186.413068832924, 197.59725236917, 209.452450883902,
           222.018923113925, 235.339343190542, 249.458945555447, 264.425678571098,
           280.290367347217, 297.10688633636, 314.932342284659,
           333.827268159027, 353.855828709363, 375.086038363832,
           397.589992197158, 421.444110756266, 446.729399574684, 473.531724256964,
           501.942102067287, 532.057011012439, 563.978717468776,
           597.815623465753, 633.682634805333, 671.701551267392,
           712.001480226176, 754.719275082425, 800),
  p = c(71.744798892418, 71.744798892418, 71.744798892418,
        71.744798892418, 71.744798892418, 71.744798892418,
        71.744798892418, 71.744798892418, 71.744798892418, 71.744798892418,
        71.744798892418, 71.744798892418, 71.744798892418,
        71.744798892418, 71.744798892418, 71.744798892418, 71.744798892418,
        71.744798892418, 71.744798892418, 71.744798892418,
        71.744798892418, 71.744798892418, 71.744798892418, 71.744798892418,
        71.744798892418, 71.744798892418, 71.744798892418,
        71.744798892418, 71.744798892418, 71.744798892418, 71.744798892418,
        71.744798892418, 71.744798892418, 71.744798892418,
        71.744798892418, 71.744798892418, 71.744798892418, 71.744798892418,
        71.744798892418, 71.744798892418, 71.744798892418,
        71.744798892418, 71.744798892418, 71.7447988924181, 71.7447988924181,
        71.7447988924183, 71.7447988924185, 71.744798892419,
        71.7447988924199, 71.7447988924215, 71.7447988924246,
        71.7447988924304, 71.7447988924413, 71.7447988924618, 71.7447988925003,
        71.7447988925725, 71.7447988927082, 71.7447988929629,
        71.7447988934411, 71.7447988943392, 71.7447988960254,
        71.7447988991918, 71.7447989051373, 71.7447989163013, 71.7447989372641,
        71.7447989766266, 71.7447990505384, 71.7447991893242,
        71.7447994499253, 71.7447999392619, 71.7448008581, 71.7448025834226,
        71.7448058230991, 71.744811906311, 71.7448233288905,
        71.7448447773131, 71.7448850514617, 71.7449606750159,
        71.7451026746576, 71.7453693091786, 71.7458699699432, 71.7468100548625,
        71.7485752135401, 71.7518894808634, 71.7581120127183,
        71.7697935851946, 71.7917191219762, 71.8328567419413,
        71.9099875603493, 72.0544164668914, 72.3242074519078, 72.8258981605767,
        73.7510186877681, 75.4308292432405, 78.3972424753,
        83.3869407445449, 91.1305779502946, 101.764259517316,
        114.152667233493, 126.098286761261),
  pmin = c(63.8677497308185, 63.8677497308185, 63.8677497308185,
           63.8677497308185, 63.8677497308185, 63.8677497308185,
           63.8677497308185, 63.8677497308185, 63.8677497308185,
           63.8677497308185, 63.8677497308185, 63.8677497308185,
           63.8677497308185, 63.8677497308185, 63.8677497308185, 63.8677497308185,
           63.8677497308185, 63.8677497308185, 63.8677497308185,
           63.8677497308185, 63.8677497308185, 63.8677497308185,
           63.8677497308185, 63.8677497308185, 63.8677497308185, 63.8677497308185,
           63.8677497308185, 63.8677497308185, 63.8677497308185,
           63.8677497308185, 63.8677497308185, 63.8677497308185,
           63.8677497308185, 63.8677497308185, 63.8677497308185, 63.8677497308185,
           63.8677497308185, 63.8677497308185, 63.8677497308185,
           63.8677497308186, 63.8677497308186, 63.8677497308187,
           63.8677497308189, 63.8677497308192, 63.8677497308198, 63.8677497308208,
           63.8677497308228, 63.8677497308265, 63.8677497308333,
           63.8677497308458, 63.8677497308689, 63.8677497309115, 63.86774973099,
           63.8677497311349, 63.8677497314019, 63.8677497318939,
           63.8677497328002, 63.8677497344687, 63.8677497375397,
           63.8677497431894, 63.8677497535789, 63.8677497726763, 63.8677498077633,
           63.8677498721965, 63.8677499904604, 63.8677502074125,
           63.8677506051828, 63.8677513340441, 63.8677526687529,
           63.8677551112804, 63.8677595779288, 63.8677677397018, 63.8677826404264,
           63.8678098167502, 63.867859320891, 63.8679493554734,
           63.8681127522389, 63.8684083611307, 63.8689405855827,
           63.8698913693818, 63.8715676825148, 63.8744555974346, 63.8792213339494,
           63.8864216169945, 63.8951127061807, 63.8978109290033,
           63.8643725050119, 63.6957589753457, 63.1142443091432,
           61.4983006192232, 57.8490659753502, 51.007918638137, 39.8546777690955,
           23.7145953299892, 3.76333384234943, -14.2139097515311,
           -17.6912106408981, 7.2051458289407, 58.427964316296,
           100.576514794464),
  pmax = c(79.6218480540175, 79.6218480540175, 79.6218480540175,
           79.6218480540175, 79.6218480540175, 79.6218480540175,
           79.6218480540175, 79.6218480540175, 79.6218480540175,
           79.6218480540175, 79.6218480540175, 79.6218480540175,
           79.6218480540175, 79.6218480540175, 79.6218480540175, 79.6218480540175,
           79.6218480540175, 79.6218480540175, 79.6218480540175,
           79.6218480540175, 79.6218480540175, 79.6218480540175,
           79.6218480540175, 79.6218480540175, 79.6218480540175, 79.6218480540175,
           79.6218480540175, 79.6218480540175, 79.6218480540175,
           79.6218480540175, 79.6218480540175, 79.6218480540175,
           79.6218480540175, 79.6218480540175, 79.6218480540175, 79.6218480540175,
           79.6218480540175, 79.6218480540174, 79.6218480540174,
           79.6218480540174, 79.6218480540174, 79.6218480540173,
           79.6218480540172, 79.621848054017, 79.6218480540165, 79.6218480540157,
           79.6218480540142, 79.6218480540115, 79.6218480540064,
           79.6218480539972, 79.6218480539803, 79.6218480539494, 79.6218480538926,
           79.6218480537887, 79.6218480535987, 79.6218480532511,
           79.6218480526162, 79.621848051457, 79.6218480493426,
           79.6218480454889, 79.6218480384719, 79.6218480257073, 79.6218480025113,
           79.6218479604061, 79.6218478840679, 79.6218477458407,
           79.621847495894, 79.6218470446042, 79.6218462310977,
           79.6218447672433, 79.6218421382712, 79.6218374271435, 79.6218290057719,
           79.6218139958718, 79.6217873368901, 79.6217401991529,
           79.6216573506846, 79.621512988901, 79.6212647637325,
           79.6208472489754, 79.6201722573716, 79.6191645122904, 79.6179290931308,
           79.6173573447323, 79.621111319256, 79.6417762413859,
           79.7190657389405, 79.9699545085368, 80.7057308115553,
           82.6105323145595, 86.7993489284655, 94.6438776830165, 107.647359606441,
           127.147063156492, 153.031151108251, 180.987791240621,
           199.952366541487, 196.323373205692, 169.87737015069,
           151.620058728057)
)

newdata_Typeb <-    data.frame(
  conc = c(2.5, 2.64999194539132, 2.80898292425554, 2.97751284960757,
           3.15615402750368, 3.34551310051965, 3.54623310783128,
           3.75899566889316, 3.98452329813109, 4.22358185850857,
           4.47698316229944, 4.74558772789842, 5.03030770203148,
           5.33210995728933, 5.65201937550302, 5.99112232811147, 6.35057036533979,
           6.73158412671649, 7.13545748620909, 7.5635619460545,
           8.01735129420508, 8.49836654120645, 9.00824115327205, 9.54870659932541,
           10.1215982308469, 10.7288615144925, 11.3725586386496,
           12.0548755163648, 12.7781292084246, 13.5447757917979,
           14.3574187001583, 15.2188175648121, 16.1318975860528, 17.099759466767,
           18.1256899420246, 19.2131729404102, 20.3659014149989,
           21.5877898841523, 22.8829877247215, 24.2558932628002,
           25.7111687098768, 27.2537559951083, 28.8888935474789, 30.6221340848345,
           32.4593634702017, 34.4068206994254, 36.4711190880003,
           38.6592687290433, 40.9787002986732, 43.4372902896355,
           46.0433877588634, 48.8058426798069, 51.7340359958095, 54.8379114765919,
           58.1280094860202, 61.6155027758334, 65.312234426878,
           69.2307580666944, 73.38438050003, 77.7872068970445,
           82.4541886926623, 87.4011743597323, 92.644963228413, 98.2033625345477,
           104.095247890758, 110.340627385608, 116.960709528515,
           123.977975271127, 131.416254349764, 139.300806208148,
           147.658405775244, 156.517434389488, 165.907976178182, 175.861920219343,
           186.413068832924, 197.59725236917, 209.452450883902,
           222.018923113925, 235.339343190542, 249.458945555447, 264.425678571098,
           280.290367347217, 297.10688633636, 314.932342284659,
           333.827268159027, 353.855828709363, 375.086038363832,
           397.589992197158, 421.444110756266, 446.729399574684, 473.531724256964,
           501.942102067287, 532.057011012439, 563.978717468776,
           597.815623465753, 633.682634805333, 671.701551267392,
           712.001480226176, 754.719275082425, 800),
  p = c(69.3358587627781, 69.3399869135461, 69.3445442310385,
        69.3495753314742, 69.355129469294, 69.3612610193241,
        69.3680300090569, 69.3755027062603, 69.3837522676642,
        69.392859455072, 69.4029134259024, 69.4140126058976, 69.4262656525338,
        69.4397925185595, 69.4547256260627, 69.4712111625511,
        69.4894105117195, 69.5095018328932, 69.5316818045918,
        69.5561675492549, 69.5831987579432, 69.6130400357767, 69.645983491027,
        69.6823515931521, 69.7225003276872, 69.7668226787917,
        69.8157524734455, 69.8697686248019, 69.9293998160893,
        69.9952296707286, 70.0679024590556, 70.1481293972404, 70.2366955997314,
        70.3344677528783, 70.4424025843551, 70.5615562106887,
        70.6930944536586, 70.838304225656, 70.9986060943585,
        71.1755681483772, 71.3709212979752, 71.5865761586474, 71.8246416804073,
        72.0874457021838, 72.377557628928, 72.697813449018,
        73.0513433314958, 73.4416020667523, 73.8724026406818, 74.34795326126,
        74.8728981881754, 75.4523627507942, 76.0920029775908,
        76.7980603014973, 77.5774218506538, 78.4376868830503,
        79.3872399767989, 80.4353316455149, 81.5921671107675, 82.8690040309995,
        84.2782600589051, 85.8336311771308, 87.5502218453904,
        89.4446880806493, 91.5353946857718, 93.8425879406448,
        96.3885851727669, 99.1979827308516, 102.297883994038, 105.718149159297,
        109.491668658565, 113.654662162354, 118.247005224669,
        123.312585710628, 128.899692217809, 135.061436748063,
        141.856213900032, 149.348198823346, 157.607886090841, 166.712671489855,
        176.747478489198, 187.805430782893, 199.988571819277,
        213.408631564034, 228.187839882804, 244.459784822502,
        262.37031267398, 282.078464960351, 303.757445357829, 327.59560695761,
        353.797447153128, 382.584593721193, 414.196761294964,
        448.892652345861, 486.950770959374, 528.670111088704,
        574.370673618245, 624.393758533862, 679.101969914686, 738.878862556744),
  pmin = c(50.6207761194391, 50.6302972038606, 50.6407356025517,
           50.6521788624508, 50.6647227681339, 50.6784720992188,
           50.6935414545902, 50.7100561488662, 50.728153186884,
           50.7479823223456, 50.7697072071238, 50.7935066380978, 50.8195759087337,
           50.848128272964, 50.8793965292243, 50.9136347327697,
           50.9511200446015, 50.992154725457, 51.0370682833451,
           51.0862197829931, 51.1400003252905, 51.1988357043135, 51.2631892487365,
           51.3335648533229, 51.410510204644, 51.4946202031132,
           51.5865405807108, 51.6869717102867, 51.7966725978656,
           51.9164650437639, 52.047237951294, 52.1899517530997, 52.3456429144086,
           52.5154284593013, 52.7005104500754, 52.9021803304216,
           53.1218230199666, 53.360920620269, 53.6210555601991,
           53.9039129715898, 54.2112820442785, 54.5450560640325, 54.9072307892772,
           55.2999007767752, 55.7252532288611, 56.1855589161191,
           56.6831597461032, 57.2204526259549, 57.7998694412177,
           58.4238532960627, 59.09483169983, 59.8151882260739, 60.5872354075841,
           61.4131933490193, 62.295180774298, 63.2352279009233,
           64.2353233626806, 65.2975097904367, 66.4240436443552, 67.6176332185256,
           68.8817632085028, 70.2211043314092, 71.6419931841191,
           73.1529537436939, 74.7652221002396, 76.4932344871206,
           78.355047376824, 80.3726754163026, 82.5723530080037, 84.9847422012205,
           87.6451189239225, 90.5935704877183, 93.8752316648517,
           97.5405776708414, 101.645782978611, 106.253146767825,
           111.431579473649, 117.257139957397, 123.813608417796, 131.193075227889,
           139.496519222475, 148.83433916928, 159.326787413309,
           171.104232439029, 184.307143661607, 199.085641854888,
           215.598385091676, 234.010454456607, 254.489759655112, 277.201308069176,
           302.298517256222, 329.910742262835, 360.126664794545,
           392.974719796458, 428.404832126156, 466.279662170118,
           506.38444981609, 548.456549916487, 592.21985328592, 637.400181359255),
  pmax = c(88.0509414061171, 88.0496766232317, 88.0483528595254,
           88.0469718004975, 88.0455361704542, 88.0440499394295,
           88.0425185635235, 88.0409492636544, 88.0393513484445,
           88.0377365877985, 88.0361196446811, 88.0345185736974,
           88.0329553963339, 88.0314567641549, 88.030054722901, 88.0287875923325,
           88.0277009788374, 88.0268489403293, 88.0262953258384,
           88.0261153155167, 88.0263971905958, 88.0272443672399, 88.0287777333175,
           88.0311383329813, 88.0344904507303, 88.0390251544703,
           88.0449643661801, 88.052565539317, 88.062127034313,
           88.0739942976933, 88.0885669668173, 88.1063070413811, 88.1277482850543,
           88.1535070464553, 88.1842947186347, 88.2209320909558,
           88.2643658873506, 88.315687831043, 88.3761566285179,
           88.4472233251647, 88.5305605516719, 88.6280962532623, 88.7420525715374,
           88.8749906275923, 89.0298620289949, 89.2100679819169,
           89.4195269168883, 89.6627515075496, 89.9449358401459,
           90.2720532264572, 90.6509646765209, 91.0895372755145, 91.5967705475975,
           92.1829272539753, 92.8596629270096, 93.6401458651774,
           94.5391565909171, 95.573153500593, 96.7602905771798,
           98.1203748434734, 99.6747569093074, 101.446158022852, 103.458450506662,
           105.736422417605, 108.305567271304, 111.191941394169,
           114.42212296871, 118.023290045401, 122.023414980073,
           126.451556117373, 131.338218393207, 136.715753836991, 142.618778784487,
           149.084593750416, 156.153601457007, 163.8697267283,
           172.280848326416, 181.439257689295, 191.402163763886, 202.232267751821,
           213.998437755921, 226.776522396505, 240.650356225245,
           255.713030689039, 272.068536104001, 289.833927790116,
           309.142240256284, 330.146475464096, 353.025131060546, 377.989905846043,
           405.296377050034, 435.258445179552, 468.266857795383,
           504.810584895264, 545.496709792593, 591.06056000729,
           642.356897420401, 700.330967151238, 765.984086543452, 840.357543754232)
)




TypeAdata2 <-     data.frame(
  signal = c(111.35, 152.23, 121.46, 60.76, 71.5, 71.41, 91.89, 80.98,
             71.47, 91.1, 81.72, 71.47, 81.01, 81.72, 71.47, 71.47,
             51.03, 71.72, 81.94, 50.75, 71.69),
  conc = c(800L, 800L, 800L, 400L, 400L, 400L, 200L, 200L, 200L, 100L,
           100L, 100L, 50L, 50L, 50L, 25L, 25L, 25L, 0L, 0L, 0L),
  conc0 = c(800, 800, 800, 400, 400, 400, 200, 200, 200, 100, 100, 100,
            50, 50, 50, 25, 25, 25, 2.5, 2.5, 2.5),
  ï..Sample.ID = as.factor(c("800_a", "800_b", "800_c", "400_a", "400_b",
                             "400_c", "200_a", "200_b", "200_c", "100_a",
                             "100_b", "100_c", "50_a", "50_b", "50_c",
                             "25_a", "25_b", "25_c", "0_a", "0_b", "0_c")),
  group = as.factor(c("Prototype A", "Prototype A", "Prototype A",
                      "Prototype A", "Prototype A", "Prototype A",
                      "Prototype A", "Prototype A", "Prototype A",
                      "Prototype A", "Prototype A", "Prototype A",
                      "Prototype A", "Prototype A", "Prototype A",
                      "Prototype A", "Prototype A", "Prototype A",
                      "Prototype A", "Prototype A", "Prototype A"))
)





graphOutputCombined <- ggplot(Typebdata, aes(x = conc0, y = signal, color = "Prototype B")) +
  geom_point() +
  geom_ribbon(data=newdata_Typeb, aes(x=conc, y=p, ymin=pmin, ymax=pmax, color="Prototype B",  fill = "Prototype B"), alpha=0.2) +
  geom_line(data=newdata_Typeb, aes(x=conc, y=p, color = "Prototype B")) +
  geom_ribbon(data=newdata_TypeA, aes(x=conc, y=p, ymin=pmin, ymax=pmax, color = "Prototype A",  fill = "Prototype A"), alpha = 0.2) +
  geom_line(data=newdata_TypeA, aes(x=conc, y=p, color = "Prototype A")) +
  geom_point(data=TypeAdata2, aes(x=conc0, y=signal, color = "Prototype A")) +

  scale_x_log10(breaks= c(1, 10, 100, 1000)) +
  xlab("Concentration (pg/mL)") + ylab("Signal") +
  geom_vline(aes(xintercept = LODest_Typeb[1], linetype = "Prototype B LOD ", color = "Prototype B LOD")) +
  geom_vline(aes(xintercept = LODest_TypeA[1], linetype = "Prototype A LOD ", color = "Prototype A LOD")) +
  geom_hline(aes(yintercept = LOD_abs_cutoff_Typeb, linetype = "Prototype B LOD", color = "Prototype B LOD")) +
  geom_hline(aes(yintercept = LOD_abs_cutoff_TypeA, linetype = "Prototype A LOD", color = "Prototype A LOD")) +

  scale_linetype_manual(name = "Limits of Detection", breaks = c("Prototype B LOD", "Prototype A LOD"), values = c(5,4,5, 4))+
  scale_fill_manual("Test Type",breaks = c("Prototype B", "Prototype A"), values = c("Prototype A" = "#0fafc1","Prototype B" = "#4286f4"))+
  scale_color_manual("Limits of Detection ", breaks = c("Prototype B LOD", "Prototype A LOD"), values =c("Prototype B" = "#4286f4",  "Prototype A" = "#0fafc1", "Prototype B LOD" = "#4286f4",  "Prototype A LOD" = "#0fafc1"))+  
  labs(fill='LFA Type',
       color='Limits of Detection') +

  theme_bw() + theme(plot.title = element_text(hjust = 0.5)) + ggtitle("Dose Response")

r ggplot2 data-visualization
1个回答
2
投票
None
热门问题
推荐问题
最新问题