I cannot figure out a precise value of a tick location because I do not know how the scale works. For example, in the following scenario:
> dput(df_partial_2)
structure(list(v = 8:400, Tv_partial = c(7.98105946849764, 8.73878705524418,
9.47352664242238, 10.1859798998468, 10.8768274522901, 11.546729501371,
12.1963264293038, 12.826239385031, 13.4370708532459, 14.0294052067967,
14.6038092429507, 15.1608327039841, 15.7010087825473, 16.2248546122473,
16.7328717438707, 17.2255466076639, 17.7033509620725, 18.1667423293303,
18.6161644182794, 19.0520475347892, 19.4748089801349, 19.8848534376828,
20.2825733482202, 20.6683492742624, 21.0425502536523, 21.405534142766,
21.7576479496252, 22.0992281572083, 22.4306010372483, 22.7520829547891,
23.0639806637737, 23.3665915939217, 23.6602041291518, 23.9450978777947,
24.2215439348345, 24.489805136414, 24.7501363068249, 25.0027844982076,
25.2479892231676, 25.4859826805202, 25.7169899743615, 25.941229326661,
26.1589122835664, 26.3702439156033, 26.5754230119487, 26.7746422689521,
26.9680884730723, 27.1559426783938, 27.3383803788816, 27.515571675528,
27.6876814385425, 27.8548694647289, 28.0172906301918, 28.1750950385095,
28.3284281645058, 28.4774309937505, 28.6222401579151, 28.7629880661037,
28.8998030322791, 29.0328093988977, 29.1621276568663, 29.2878745619276,
29.4101632475811, 29.5291033346404, 29.6448010375253, 29.7573592673884,
29.8668777321649, 29.9734530336404, 30.0771787616219, 30.1781455852996,
30.2764413418811, 30.3721511225791, 30.4653573560312, 30.5561398892264,
30.6445760660137, 30.7307408032637, 30.8147066647521, 30.8965439328325,
30.9763206779655, 31.0541028261659, 31.1299542244299, 31.2039367042032,
31.2761101429469, 31.3465325238588, 31.4152599938029, 31.4823469195027,
31.5478459420476, 31.611808029764, 31.6742825294991, 31.7353172163643,
31.7949583419839, 31.8532506812946, 31.9102375779375, 31.9659609882845,
32.0204615241418, 32.0737784941661, 32.1259499440361, 32.1770126954122,
32.227002383724, 32.2759534948179, 32.3238994005003, 32.3708723930087,
32.4169037184423, 32.4620236091842, 32.5062613153437, 32.5496451352497,
32.5922024450215, 32.6339597272468, 32.674942598791, 32.715175837766,
32.7546834096823, 32.7934884928088, 32.8316135027644, 32.8690801163648,
32.9059092947446, 32.9421213057798, 32.9777357458282, 33.0127715608099,
33.0472470666478, 33.0811799690861, 33.1145873829068, 33.14748585056,
33.1798913602291, 33.2118193633436, 33.2432847915594, 33.2743020732209,
33.3048851493212, 33.3350474889736, 33.3648021044129, 33.3941615655357,
33.4231380139978, 33.4517431768788, 33.4799883799295, 33.5078845604127,
33.5354422795497, 33.5626717345866, 33.5895827704883, 33.6161848912738,
33.642487271004, 33.6684987644302, 33.6942279173145, 33.7196829764334,
33.7448718992726, 33.7698023634215, 33.7944817756786, 33.8189172808753,
33.843115770427, 33.8670838906179, 33.8908280506314, 33.9143544303296,
33.937668987792, 33.9607774666199, 33.9836854030141, 34.0063981326306,
34.0289207972252, 34.0512583510889, 34.0734155672827, 34.0953970436786,
34.1172072088102, 34.138850327541, 34.1603305065546, 34.1816516996727,
34.2028177130061, 34.2238322099433, 34.2446987159822, 34.2654206234098,
34.2860011958333, 34.3064435725688, 34.3267507728909, 34.346925700147,
34.3669711457419, 34.3868897929958, 34.4066842208781, 34.4263569076246,
34.4459102342371, 34.4653464878726, 34.484667865123, 34.5038764751908,
34.5229743429622, 34.541963411981, 34.5608455473279, 34.5796225384059,
34.5982961016364, 34.6168678830676, 34.6353394608986, 34.6537123479216,
34.6719879938843, 34.6901677877762, 34.708253060039, 34.7262450847056,
34.7441450814691, 34.761954217683, 34.7796736102968, 34.7973043277266,
34.8148473916649, 34.8323037788297, 34.8496744226562, 34.8669602149322,
34.8841620073785, 34.901280613177, 34.9183168084477, 34.9352713336757,
34.9521448950907, 34.9689381660001, 34.9856517880761, 35.0022863726003,
35.0188425016658, 35.0353207293377, 35.0517215827748, 35.0680455633125,
35.0842931475085, 35.1004647881526, 35.1165609152417, 35.1325819369209,
35.1485282403922, 35.1644001927908, 35.1801981420321, 35.1959224176277,
35.2115733314733, 35.2271511786088, 35.2426562379515, 35.2580887730034,
35.2734490325325, 35.288737251231, 35.3039536503486, 35.3190984383043,
35.3341718112745, 35.3491739537616, 35.3641050391398, 35.3789652301832,
35.3937546795724, 35.4084735303836, 35.4231219165597, 35.437699963363,
35.4522077878117, 35.4666454990999, 35.4810131990013, 35.4953109822585,
35.5095389369564, 35.5236971448821, 35.537785681871, 35.5518046181384,
35.5657540186003, 35.5796339431791, 35.5934444470997, 35.6071855811722,
35.6208573920644, 35.6344599225624, 35.6479932118224, 35.66145729561,
35.6748522065322, 35.6881779742576, 35.7014346257297, 35.7146221853696,
35.7277406752709, 35.7407901153869, 35.7537705237088, 35.7666819164374,
35.7795243081463, 35.792297711939, 35.8050021395982, 35.81763760173,
35.8302041078994, 35.8427016667617, 35.8551302861874, 35.8674899733808,
35.8797807349937, 35.8920025772338, 35.9041555059675, 35.9162395268184,
35.9282546452606, 35.9402008667078, 35.9520781965976, 35.963886640472,
35.9756262040536, 35.9872968933178, 35.9988987145614, 36.0104316744679,
36.0218957801686, 36.0332910393006, 36.0446174600623, 36.0558750512647,
36.0670638223806, 36.0781837835905, 36.0892349458256, 36.1002173208092,
36.111130921094, 36.1219757600986, 36.1327518521402, 36.1434592124663,
36.1540978572838, 36.1646678037854, 36.1751690701755, 36.1856016756927,
36.1959656406317, 36.2062609863626, 36.2164877353493, 36.2266459111657,
36.2367355385108, 36.2467566432224, 36.2567092522888, 36.2665933938604,
36.2764090972585, 36.2861563929844, 36.2958353127264, 36.3054458893661,
36.3149881569836, 36.3244621508616, 36.3338679074887, 36.3432054645623,
36.352474860989, 36.3616761368869, 36.3708093335841, 36.3798744936191,
36.3888716607389, 36.3978008798968, 36.4066621972502, 36.4154556601571,
36.4241813171723, 36.4328392180434, 36.4414294137055, 36.4499519562765,
36.4584068990513, 36.4667942964954, 36.4751142042391, 36.4833666790704,
36.4915517789274, 36.499669562892, 36.507720091181, 36.5157034251392,
36.5236196272302, 36.5314687610289, 36.5392508912119, 36.5469660835497,
36.5546144048966, 36.5621959231825, 36.5697107074028, 36.5771588276094,
36.584540354901, 36.5918553614133, 36.5991039203094, 36.6062861057698,
36.6134019929824, 36.620451658133, 36.6274351783945, 36.6343526319172,
36.6412040978187, 36.6479896561739, 36.6547093880043, 36.6613633752684,
36.667951700851, 36.6744744485537, 36.6809317030839, 36.6873235500453,
36.6936500759276, 36.6999113680962, 36.7061075147822, 36.7122386050729,
36.7183047289007, 36.7243059770343, 36.7302424410682, 36.7361142134128,
36.7419213872849, 36.7476640566979, 36.7533423164519, 36.7589562621244,
36.7645059900605, 36.7699915973636, 36.7754131818859, 36.7807708422192,
36.7860646776854, 36.7912947883274, 36.7964612749003, 36.8015642388619,
36.8066037823638, 36.811580008243, 36.8164930200124, 36.8213429218528,
36.8261298186035, 36.8308538157543, 36.8355150194369, 36.8401135364163,
36.8446494740827, 36.849122940443, 36.853534044113, 36.8578828943088,
36.8621696008394, 36.8663942740982, 36.8705570250556, 36.8746579652508,
36.8786972067844, 36.8826748623109, 36.8865910450307), upper = c(8.03359225925823,
8.80857834632081, 9.5612639540498, 10.2924319542762, 11.0027615088121,
11.6928792116129, 12.3633783233509, 13.0148273942128, 13.6477746695034,
14.2627505985141, 14.8602694075212, 15.4408301755264, 16.0049176292822,
16.5530027709442, 17.085543401016, 17.6029845727229, 18.1057589993884,
18.5942874281687, 19.0689789887631, 19.5302315225719, 19.9784318961527,
20.4139563015338, 20.8371705451927, 21.2484303270819, 21.6480815106972,
22.0364603848133, 22.4138939176628, 22.7807000039433, 23.1371877048629,
23.483657481973, 23.8204014245163, 24.1477034710795, 24.4658396252724,
24.7750781659481, 25.0756798521194, 25.3678981224866, 25.6519792899843,
25.9281627314614, 26.1966810723811, 26.4577603670466, 26.7116202742093,
26.9584742281375, 27.1985296055078, 27.4319878880867, 27.6590448211454,
27.8798905679742, 28.0947098605409, 28.303682146198, 28.5069817307874,
28.7047779179796, 28.8972351451356, 29.0845131157104, 29.2667669283157,
29.4441472022976, 29.6168002003046, 29.7848679474905, 29.9484883479501,
30.1077952978449, 30.2629187955558, 30.4139850494996, 30.5611165825133,
30.7044323337553, 30.8440477582857, 30.9800749232191, 31.1126226023811,
31.2417963677869, 31.3676986784984, 31.4904289682926, 31.610083729402,
31.7267565955176, 31.8405384216734, 31.9515173620422, 32.0597789462855,
32.1654061533981, 32.2684794831148, 32.3690770267303, 32.4672745344442,
32.5631454822052, 32.6567611359263, 32.7481906140996, 32.837500949199,
32.924757146882, 33.0100222434937, 33.0933573629117, 33.1748217705806,
33.2544729270661, 33.3323665397096, 33.4085566127212, 33.4830954965083,
33.5560339350466, 33.6274211119235, 33.6973046960334, 33.7657308845263,
33.8327444461067, 33.8983887619512, 33.9627058662137, 34.0257364851272,
34.0875200750857, 34.1480948594313, 34.2074978650149, 34.2657649565552,
34.3229308710607, 34.3790292508966, 34.4340926756696, 34.4881526941562,
34.5412398538176, 34.5933837311924, 34.6446129601967, 34.6949552603321,
34.7444374635548, 34.7930855410287, 34.8409246284613, 34.8879790518782,
34.9342723507123, 34.9798273022007, 35.0246659442585, 35.0688095978648,
35.1122788884366, 35.155093766912, 35.1972735304098, 35.2388368426575,
35.2798017523627, 35.3201857126241, 35.3600055990019, 35.3992777278467,
35.4380178729083, 35.4762412824328, 35.5139626950424, 35.5511963569724,
35.5879560358473, 35.6242550362788, 35.660106214586, 35.6955219932856,
35.7305143739968, 35.7650949511975, 35.799274924944, 35.8330651144483,
35.8664759690332, 35.8995175805539, 35.9321996949078, 35.9645317237364,
35.9965227545901, 36.0281815616323, 36.0595166157857, 36.0905360958059,
36.1212478965051, 36.1516596385052, 36.181778677794, 36.2116121145547,
36.2411668014046, 36.2704493514818, 36.2994661468907, 36.3282233466523,
36.3567268944537, 36.3849825252517, 36.4129957724961, 36.4407719758422,
36.4683162877621, 36.4956336789202, 36.5227289452774, 36.5496067144771,
36.576271451485, 36.6027274639768, 36.6289789077896, 36.6550297930879,
36.680883989219, 36.7065452293272, 36.7320171152315, 36.7573031227545,
36.7824066060878, 36.8073308017407, 36.8320788325874, 36.8566537133383,
36.8810583533731, 36.9052955606898, 36.9293680454236, 36.9532784242442,
36.9770292236016, 37.0006228824751, 37.0240617555395, 37.0473481170782,
37.0704841638112, 37.0934720175169, 37.1163137271682, 37.1390112728497,
37.1615665679841, 37.1839814617295, 37.2062577405082, 37.2283971318262,
37.2504013057289, 37.2722718773406, 37.2940104076643, 37.3156184070184,
37.3370973368792, 37.358448611312, 37.3796735974135, 37.4007736195177,
37.421749959301, 37.4426038580381, 37.4633365164149, 37.4839490983855,
37.5044427309976, 37.5248185065204, 37.5450774822177, 37.5652206837748,
37.5852491045726, 37.6051637081801, 37.6249654278839, 37.6446551690956,
37.6642338095978, 37.6837022011351, 37.703061169198, 37.7223115139911,
37.741454012788, 37.7604894191547, 37.7794184641224, 37.7982418559697,
37.8169602831027, 37.8355744125794, 37.8540848919306, 37.872492348051,
37.8907973901634, 37.9090006082374, 37.9271025750828, 37.9451038444129,
37.9630049547664, 37.9808064261408, 37.9985087637145, 38.0161124549964,
38.0336179734073, 38.0510257756606, 38.0683363048293, 38.0855499870236,
38.1026672357657, 38.1196884486032, 38.1366140107796, 38.1534442910924,
38.1701796470854, 38.1868204204564, 38.2033669415581, 38.2198195249735,
38.2361784746205, 38.2524440791669, 38.2686166160704, 38.2846963481008,
38.3006835261952, 38.3165783890704, 38.3323811614011, 38.3480920564971,
38.3637112736246, 38.3792390009633, 38.3946754130837, 38.4100206728362,
38.4252749293159, 38.4404383204303, 38.4555109705401, 38.4704929925236,
38.4853844850299, 38.5001855362607, 38.5148962198147, 38.5295165982694,
38.5440467200941, 38.5584866218206, 38.5728363271117, 38.5870958472277,
38.6012651793252, 38.6153443093285, 38.629333208128, 38.6432318360453,
38.6570401376072, 38.670758046363, 38.684385481021, 38.6979223479721,
38.7113685398104, 38.7247239349367, 38.7379884000929, 38.7511617857575,
38.7642439311501, 38.7772346590262, 38.7901337808324, 38.8029410919209,
38.8156563751269, 38.8282793970572, 38.8408099121518, 38.8532476581625,
38.865592361234, 38.877843729249, 38.8900014587311, 38.9020652284304,
38.9140347046908, 38.9259095360921, 38.9376893586157, 38.9493737905985,
38.9609624369689, 38.9724548850766, 38.9838507088844, 38.9951494636204,
39.0063506910751, 39.0174539163475, 39.0284586462466, 39.0393643745615,
39.05017057558, 39.0608767095718, 39.0714822171156, 39.0819865251073,
39.0923890401102, 39.1026891543754, 39.1128862395446, 39.1229796535302,
39.1329687326205, 39.1428527984061, 39.1526311517042, 39.1623030775114,
39.1718678404131, 39.1813246883321, 39.1906728477217, 39.199911528907,
39.2090399205426, 39.2180571938361, 39.2269624992342, 39.2357549667289,
39.2444337083123, 39.2529978130782, 39.2614463525713, 39.2697783738833,
39.2779929070221, 39.28608895693, 39.2940655099318, 39.3019215280794,
39.3096559535962, 39.3172677037989, 39.3247556757764, 39.3321187408153,
39.3393557498253, 39.3464655268798, 39.3534468740051, 39.3602985675711,
39.3670193603561, 39.3736079784372, 39.3800631235048, 39.3863834698938,
39.3925676666143, 39.3986143351158, 39.4045220686833, 39.4102894343671,
39.4159149688177, 39.4213971814072, 39.4267345508319, 39.4319255263988,
39.4369685255292, 39.4418619360456, 39.4466041125389, 39.451193377326,
39.4556280194739, 39.4599062940958, 39.4640264210152, 39.4679865851237,
39.471784934444, 39.4754195799749, 39.4788885944803, 39.4821900115524,
39.4853218247947, 39.4882819872413, 39.4910684089741, 39.4936789576808,
39.4961114568045, 39.4983636822029, 39.5004333662267, 39.5023181900198,
39.5040157873157, 39.5055237408116, 39.5068395794376, 39.5079607785615,
39.5088847588695, 39.5096088825276, 39.5101304540473, 39.5104467142662,
39.5105548434037, 39.5104519552204, 39.510135096546, 39.5096012441735,
39.5088473033011, 39.5078701034415, 39.5066663979697, 39.5052328591409,
39.5035660760377, 39.5016625518232, 39.4995186993156, 39.4971308389636,
39.494495193108, 39.4916078852114, 39.4884649309263, 39.4850622390609
), lower = c(7.92852667773705, 8.66899576416754, 9.38578933079495,
10.0795278454174, 10.7508933957681, 11.4005797911291, 12.0292745352567,
12.6376513758492, 13.2263670369884, 13.7960598150793, 14.3473490783802,
14.8808352324417, 15.3970999358125, 15.8967064535504, 16.3802000867254,
16.8481086426048, 17.3009429247567, 17.7391972304919, 18.1633498477956,
18.5738635470064, 18.9711860641172, 19.3557505738318, 19.7279761512478,
20.088268221443, 20.4370189966073, 20.7746079007188, 21.1014019815875,
21.4177563104733, 21.7240143696337, 22.0205084276052, 22.3075599030311,
22.5854797167639, 22.8545686330312, 23.1151175896412, 23.3674080175496,
23.6117121503413, 23.8482933236656, 24.0774062649539, 24.2992973739542,
24.5142049939938, 24.7223596745136, 24.9239844251844, 25.119294961625,
25.3084999431199, 25.491801202752, 25.66939396993, 25.8414670856036,
26.0082032105896, 26.1697790269758, 26.3263654330763, 26.4781277319494,
26.6252258137474, 26.767814332068, 26.9060428747215, 27.040056128707,
27.1699940400104, 27.2959919678801, 27.4181808343625, 27.5366872690024,
27.6516337482958, 27.7631387312192, 27.8713167900999, 27.9762787368766,
28.0781317460617, 28.1769794726695, 28.2729221669899, 28.3660567858314,
28.4564770989883, 28.5442737938418, 28.6295345750816, 28.7123442620887,
28.792784883116, 28.8709357657768, 28.9468736250546, 29.0206726489125,
29.0924045797971, 29.16213879506, 29.2299423834597, 29.2958802200047,
29.3600150382321, 29.4224074996608, 29.4831162615243, 29.5421980424001,
29.5997076848059, 29.6556982170252, 29.7102209119393, 29.7633253443856,
29.8150594468069, 29.8654695624899, 29.9146004976819, 29.9624955720443,
30.0091966665558, 30.0547442713486, 30.0991775304623, 30.1425342863324,
30.1848511221186, 30.226163402945, 30.2665053157387, 30.3059099080167,
30.3444091246209, 30.3820338444454, 30.4188139149567, 30.454778185988,
30.4899545426987, 30.5243699365313, 30.5580504166818, 30.5910211588507,
30.623306494297, 30.6549299372498, 30.6859142119773, 30.7162812783359,
30.7460523571562, 30.7752479536507, 30.8038878820173, 30.8319912872885,
30.8595766673012, 30.8866618937915, 30.9132642331833, 30.9394003663836,
30.9650864077624, 30.9903379231561, 31.0151699487574, 31.0395970078341,
31.0636331276854, 31.087291855272, 31.1105862735336, 31.1335290162095,
31.1561322829049, 31.1784078518534, 31.200367095224, 31.2220209917168,
31.2433801391715, 31.2644547665734, 31.2852547468285, 31.305789607902,
31.3260685442293, 31.3461004265282, 31.3658938135144, 31.3854569614542,
31.4047978339526, 31.4239241108925, 31.4428431982768, 31.461562236913,
31.4800881110573, 31.4984274555513, 31.5165866652456, 31.5345719023488,
31.5523891034418, 31.570043986708, 31.5875420592547, 31.6048886241021,
31.6220887863492, 31.6391474593759, 31.6560693708075, 31.6728590691987,
31.6895209296817, 31.7060591587233, 31.7224777995951, 31.7387807387001,
31.7549717098046, 31.771054298632, 31.7870319478604, 31.8029079620354,
31.818685512097, 31.8343676388765, 31.8499572576007, 31.8654571623394,
31.8808700299061, 31.8961984230273, 31.9114447942062, 31.9266114897432,
31.9417007534042, 31.9567147284179, 31.9716554618761, 31.9865249077845,
32.0013249303215, 32.0160573060017, 32.03072372678, 32.0453258034493,
32.0598650684224, 32.0743429775776, 32.0887609130007, 32.103120185756,
32.117422038967, 32.1316676489476, 32.145858127859, 32.1599945260391,
32.1740778350442, 32.1881089882518, 32.2020888636823, 32.2160182855976,
32.2298980277018, 32.2437288135753, 32.257511318574, 32.2712461720178,
32.2849339602458, 32.2985752257947, 32.3121704705634, 32.3257201567189,
32.339224709939, 32.3526845185099, 32.3660999363538, 32.3794712836611,
32.3927988497824, 32.4060828923773, 32.4193236406279, 32.4325212951514,
32.4456760307915, 32.458787996454, 32.4718573170272, 32.484884093882,
32.4978684071072, 32.5108103164923, 32.5237098610539, 32.5365670616296,
32.5493819214592, 32.5621544280945, 32.5748845521528, 32.5875722503671,
32.600217465287, 32.612820127852, 32.6253801558434, 32.6378974568276,
32.6503719273791, 32.6628034562844, 32.6751919218421, 32.6875371964082,
32.6998391438086, 32.7120976232832, 32.7243124869592, 32.7364835834842,
32.7486107559379, 32.7606938460958, 32.7727326909604, 32.7847271270201,
32.7966769874202, 32.8085821069102, 32.8204423174316, 32.8322574534563,
32.8440273482061, 32.8557518387685, 32.8674307616563, 32.8790639580336,
32.8906512702879, 32.9021925460985, 32.9136876361492, 32.9251363950583,
32.9365386837237, 32.9478943671477, 32.9592033175954, 32.970465412101,
32.9816805354316, 32.9928485786233, 33.0039694414233, 33.0150430301115,
33.0260692602336, 33.037048054894, 33.0479793478448, 33.0588630800318,
33.0696992040632, 33.080487680927, 33.0912284833659, 33.1019215939782,
33.1125670064116, 33.1231647251472, 33.1337147674364, 33.1442171606589,
33.1546719463397, 33.1650791758897, 33.1754389160296, 33.1857512441582,
33.1960162523946, 33.2062340452232, 33.2164047411336, 33.2265284731705,
33.2366053865426, 33.2466356433653, 33.2566194177858, 33.266556901311,
33.2764482977688, 33.2862938282037, 33.2960937274025, 33.3058482477041,
33.3155576550292, 33.3252222334887, 33.3348422803843, 33.344418112939,
33.353950061466, 33.36343847585, 33.3728837202419, 33.3822861784755,
33.3916462489552, 33.4009643497524, 33.4102409144165, 33.4194763961868,
33.4286712638407, 33.4378260070782, 33.4469411312562, 33.4560171606742,
33.4650546401982, 33.4740541300161, 33.4830162121407, 33.4919414849452,
33.5008305688532, 33.5096841003456, 33.518502738622, 33.5272871595919,
33.5360380621786, 33.5447561614472, 33.553442196504, 33.562096923572,
33.5707211220696, 33.5793155896568, 33.5878811468251, 33.5964186331457,
33.6049289120718, 33.6134128655934, 33.6218713997717, 33.6303054405085,
33.6387159368526, 33.6471038606822, 33.6554702042407, 33.6638159850243,
33.6721422404196, 33.680450034595, 33.6887404511186, 33.6970146009249,
33.7052736158521, 33.7135186542826, 33.7217508966821, 33.7299715506615,
33.7381818462813, 33.7463830416085, 33.754576417274, 33.7627632829134,
33.7709449723599, 33.7791228472345, 33.7872982948628, 33.7954727313648,
33.8036475993218, 33.811824370725, 33.8200045449252, 33.828189650849,
33.8363812475827, 33.8445809224218, 33.8527902950166, 33.8610110142303,
33.8692447615159, 33.8774932496098, 33.8857582250076, 33.8940414656565,
33.9023447845684, 33.9106700288418, 33.9190190806168, 33.9273938577594,
33.9357963151771, 33.9442284444407, 33.9526922757018, 33.9611898778265,
33.9697233595884, 33.978294870584, 33.9869066020308, 33.9955607873286,
34.0042597044217, 34.0130056752231, 34.0218010674443, 34.030648297918,
34.0395498285005, 34.048508173752, 34.0575258971226, 34.0666056145592,
34.0757499972172, 34.0849617712391, 34.0942437188543, 34.1035986822,
34.1130295624387, 34.1225393257587, 34.1321310003018, 34.1418076819866,
34.1515725349625, 34.1614287947003, 34.1713797695316, 34.1814288447239,
34.1915794829163, 34.201835229085, 34.2121997125799, 34.2226766498556,
34.2332698488808, 34.2439832111475, 34.2548207373935, 34.2657865283575,
34.2768847936956, 34.2881198510005)), row.names = 8:400, class = "data.frame")
ggplot(df_partial_2, aes(log(log(v)))) + theme_bw() + xlab("v") + ylab(bquote(lnT[v])) + scale_x_continuous(labels = ~floor(exp(exp(.))), sec.axis=sec_axis(~., name = "ln ln v")) +
geom_line(aes(y=log(upper)), linetype="dashed") +
geom_line(aes(y=log(Tv_partial))) +
geom_line(aes(y=log(lower)), linetype="dashed")
library("grid")
grid.lines(x = unit(c(0, 0), "npc"), y = unit(c(0.05, 0.1), "npc")) # line
grid.lines(x = unit(c(1, 1), "npc"), y = unit(c(0.05, 0.1), "npc")) # line
grid.text("<- unit(c(0, 0)) is here", 0.01, .075, just=c("left", "bottom"))
grid.text("unit(c(1, 1)) is here ->", 0.84, .075, just=c("left", "bottom"))
grid.lines(x = unit(c(0.4, 0.4), "npc"), y = unit(c(0.05, 0.1), "npc")) # line
grid.text("What is the value of v at this tick?", .3, .11,just=c("left", "bottom"))
As shown in the plot, the function grid put the ticks at a location based on a scaled percentage of the entire plot panel (not the axis). In other words, unit(c(0.4, 0.4)) on x means the tick is at the 40%-60% separation of the entire plot panel, not of the axis. As a consequence, I don't know what is the actual value on the axis for the tick location.
Is there a way to figure out what is the axis value of the tick location?
Or, if I want a small tick to be add onto v = 18 in the plot, is there a way to do it?
Any help is appreciated. Thank you!
There's no consistent answer. Per the grid::unit() docs, "all drawing occurs relative to a viewport." Which means the location will change based on the viewport aspect ratio (and maybe other factors too). For instance, in your example, the tick is about 2/3 between 11 and 27. But if my viewport has a lower aspect ratio, the same code puts the tick about halfway between 11 and 27:
If you're trying to add an extra tick mark, specify breaks including the extra tick within scale_x_continuous():
ggplot(df_partial_2, aes(log(log(v)))) +
geom_line(aes(y=log(upper)), linetype="dashed") +
geom_line(aes(y=log(Tv_partial))) +
geom_line(aes(y=log(lower)), linetype="dashed") +
theme_bw() +
xlab("v") +
ylab(bquote(lnT[v])) +
scale_x_continuous(
labels = ~floor(exp(exp(.))),
breaks = c(.9, 1.1, 1.2, 1.5, 1.8),
sec.axis=sec_axis(~., breaks = c(.9, 1.1, 1.2, 1.5, 1.8), name = "ln ln v")
)
Related
Question:
Below can find the data, codes, and output. How can I get the plot sorted according to the original order in the row names, instead of the alphabetic order?
Note: I understand there are many existing questions and answers saying we can use as. character() and specify the orders in factor levels. However, the codes for the heatmap are a result of StackOverflow help, and I don't know how to follow those guidances to modify the codes.
Data:
data <- structure(c(1.56415665339664, 1.88622232430646, 2.7670527911374,
1.92703163268293, 1.92815958820144, 1.53777698134781, 1.85785080937573,
2.73057928043023, 1.91265151742415, 1.91392443413493, 1.51188863842245,
1.82978143286307, 2.69398442644669, 1.89813137541848, 1.89955330864784,
1.48650974337831, 1.80204149133308, 2.65731564638771, 1.88348256348151,
1.8850572392635, 1.46165563934645, 1.77465595548961, 2.62061921610674,
1.86871647260771, 1.87044727645794, 1.4373390243787, 1.74764749626653,
2.58394008473444, 1.85384450032525, 1.85573446770023, 1.41357009067807,
1.72103652543546, 2.5473217079521, 1.83887802369739, 1.84092983214118,
1.39035667008188, 1.69484124901252, 2.51080590056645, 1.82382837308096,
1.82604433604935, 1.36770438358188, 1.66907773176055, 2.47443270873259,
1.80870680674341, 1.81108886908555, 1.34561679288903, 1.64375997112343,
2.4382403018842, 1.79352448643103, 1.79607422149822, 1.3240955522757,
1.61889997899129, 2.40226488416451, 1.77829245397141, 1.78101106231344,
1.30314055915218, 1.59450786977524, 2.36654062491116, 1.76302160898326,
1.7659099185843, 1.28275010205015, 1.57059195336362, 2.33109960753632,
1.74772268775752, 1.7507811557552, 1.26292100489292, 1.54715883163515,
2.29597179596148, 1.73240624336288, 1.73563495918782, 1.24364876662612,
1.52421349731482, 2.26118501761437, 1.71708262702006, 1.72048131688628,
1.22492769546226, 1.50175943407199, 2.22676496187464, 1.70176197077873,
1.70533000345043, 1.20675103715734, 1.47979871687523, 2.19273519276265,
1.68645417152199, 1.69019056527759, 1.18911109688617, 1.45833211173251,
2.15911717460239, 1.67116887631423, 1.67507230702478, 1.17199935441569,
1.43735917405612, 2.12593030935165, 1.65591546909929, 1.65998427933569,
1.15540657239252, 1.41687834499844, 2.09319198427861, 1.64070305874773,
1.6449352678292, 1.13932289766278, 1.39688704520578, 2.06091762867183,
1.6255404684443, 1.62993378333913, 1.12373795562949, 1.37738176553192,
2.02912077829616, 1.6104362263992, 1.61498805338851, 1.10864093772681,
1.35835815434096, 1.99781314634913, 1.5953985578604, 1.60010601487567,
1.09402068215196, 1.33981110110915, 1.96700469972745, 1.58043537839775,
1.58529530794391, 1.07986574804581, 1.32173481610856, 1.93670373947838,
1.56555428842454, 1.57056327100153, 1.06616448335306, 1.30412290602036,
1.90691698438448, 1.55076256891683, 1.55591693685494, 1.05290508662397,
1.28696844538424, 1.87764965670914, 1.53606717828693, 1.54136302991323,
1.04007566304237, 1.27026404384093, 1.84890556921326, 1.52147475036339,
1.52690796441975, 1.02766427498045, 1.25400190916953, 1.82068721263795,
1.50699159342693, 1.51255784366333, 1.01565898739092, 1.23817390615927,
1.79299584293262, 1.49262369024903, 1.49831846011925, 1.0040479083513,
1.22277161138752, 1.76583156759166, 1.47837669907795, 1.48419529646884,
0.992819225075914, 1.2077863640027, 1.73919343054343, 1.46425595551545,
1.47019352744474, 0.98196123570733, 1.19320931263264, 1.71307949511363,
1.45026647522637, 1.45631802244833, 0.9714623771931, 1.17903145855638,
1.68748692465827, 1.43641295742272, 1.4425733488853, 0.96131124954466,
1.16524369529089, 1.66241206053094, 1.42269978906386, 1.42896377616518,
0.951496636765001, 1.15183684475424, 1.63785049711299, 1.40913104971445,
1.41549328031103, 0.942007524719625, 1.13880169017355, 1.61379715369429,
1.39571051700261, 1.40216554912609, 0.932833116212497, 1.12612900591028,
1.59024634304597, 1.38244167262157, 1.38898398786489, 0.923962843515001,
1.11380958437724, 1.56719183657471, 1.36932770881932, 1.37595172535787,
0.915386378581994, 1.10183426022178, 1.54462692599157, 1.35637153532236,
1.3630716205394, 0.907093641174831, 1.09019393194762, 1.52254448146634,
1.34357578664111, 1.35034626933109, 0.899074805097146, 1.07887958114475,
1.50093700627199, 1.33094282970668, 1.33777801183386, 0.89132030273522,
1.06788228949262, 1.47979668795232, 1.31847477179054, 1.32536893978401,
0.883820828081197, 1.05719325369659, 1.45911544607085, 1.30617346866088,
1.31312090423067, 0.876567338404172, 1.04680379851168, 1.4388849766195,
1.29404053293171, 1.30103552339406, 0.869551054721558, 1.03670538800144,
1.41909679318253, 1.28207734256312, 1.28911419066604, 0.862763461210944,
1.02688963517278, 1.39974226496544, 1.2702850494734, 1.27735808271664,
0.856196303691171, 1.01734831012073, 1.38081265180883, 1.25866458822613,
1.26576816767268, 0.849841587290416, 1.00807334680985, 1.36229913631591,
1.24721668475813, 1.25434521333641, 0.843691573408777, 0.99905684861186,
1.34419285322773, 1.23594186511587, 1.24308979541463, 0.837738776073223,
0.990291092711936, 1.3264849161844, 1.22484046417117, 1.23200230573094,
0.831975957773722, 0.981768533488905, 1.3091664420122, 1.21391263428855,
1.22108296039557, 0.826396124860962, 0.973481804967925, 1.29222857267723,
1.20315835391962, 1.21033180790988, 0.820992522578248, 0.965423722437341,
1.27566249504498, 1.19257743610158, 1.1997487371841, 0.815758629792936,
0.957587283315014, 1.25945945858363, 1.18216953683933, 1.18933348544938,
0.810688153486053, 0.949965667343234, 1.24361079114564, 1.17193416335278,
1.17908564604669, 0.805775023052616, 0.942552236185361, 1.22810791295855,
1.1618706821728, 1.16900467607732, 0.801013384459458, 0.935340532491705,
1.21294234895183, 1.15197832707131, 1.15908990390117, 0.796397594302229,
0.928324278496812, 1.19810573954163, 1.14225620681276, 1.14934053647087,
0.791922213798429, 0.921497374205249, 1.18358984999023, 1.13270331271594,
1.13975566649139, 0.787582002749033, 0.914853895218226, 1.16938657845174,
1.12331852601676, 1.13033427939609, 0.783371913497309, 0.908388090248925,
1.15548796281005, 1.11410062502406, 1.12107526013177, 0.779287084909823,
0.902094378370215, 1.14188618640925, 1.10504829206212, 1.11197739974653,
0.775322836401382, 0.895967346034515, 1.12857358277151, 1.09616012019459,
1.10303940177539, 0.771474662022726, 0.89000174390193, 1.11554263939148,
1.08743461972608, 1.09425988841997, 0.767738224627101, 0.884192483509395,
1.10278600069095, 1.07887022447868, 1.08563740651938, 0.764109350129453,
0.878534633810428, 1.09029647021224, 1.07046529784161, 1.07717043331055,
0.760584021869845, 0.873023417612164, 1.07806701212338, 1.0622181385934,
1.06885738197716, 0.757158375090736, 0.867654207933682, 1.06609075210328,
1.05412698649671, 1.06069660698705, 0.753828691536061, 0.862422524307139,
1.05436097767014, 1.04619002766682, 1.05268640921891, 0.750591394178479,
0.857324029040955, 1.04287113801187, 1.03840539971537, 1.04482504087941,
0.747443042079812, 0.852354523462208, 1.03161484337265, 1.03077119667177,
1.03711071021304, 0.744380325388455, 0.847509944153447, 1.02058586404586,
1.02328547368523, 1.02954158600691, 0.741400060476472, 0.84278635919742,
1.00977812901932, 1.01594625151082, 1.02211580189372, 0.738499185218138,
0.838179964441562, 0.999185724315382, 1.00875152078335, 1.0148314604562,
0.735674754410845, 0.833687079792661, 0.988802891064574, 1.00169924608359,
1.00768663713703, 0.732923935338581, 0.829304145550759, 0.978624023348409,
0.994787369801221, 1.00067938395813, 0.730244003477527, 0.82502771879015,
0.968643665843796, 0.988013815799624, 0.993807733054007, 0.727632338342786,
0.820854469794238, 0.958856511298594, 0.981376492887521, 0.987069700023661,
0.725086419474772, 0.816781178550003, 0.949257397865192, 0.974873298102964,
0.980463287105968, 0.722603822563399, 0.812804731306956, 0.939841306316456,
0.968502119815104, 0.973986486183567, 0.72018221570783, 0.808922117204624,
0.930603357166104, 0.96226084064944, 0.967637281620371, 0.717819355809315,
0.805130424971885, 0.921538807713388, 0.956147340242261, 0.961413652937977,
0.715513085094331, 0.801426839700833, 0.912643049029987, 0.950159497830092,
0.955313577336244, 0.713261327765121, 0.797808639697236, 0.903911602905182,
0.944295194679964, 0.94933503206341, 0.711062086774516, 0.794273193409158,
0.895340118763694, 0.938552316366345, 0.943475996641087, 0.708913440721818,
0.79081795643482, 0.886924370569017, 0.932928754900547, 0.937734454949501,
0.706813540866439, 0.787440468610379, 0.878660253723646, 0.927422410718391,
0.932108397178287, 0.704760608255926, 0.784138351177934, 0.870543781976314,
0.922031194531849, 0.926595821648137, 0.702752930964936, 0.780909304033727,
0.862571084345134, 0.916753029050316, 0.921194736508511, 0.700788861441736,
0.777751103056251, 0.854738402064476, 0.911585850577083, 0.915903161316576,
0.698866813958788, 0.77466159751369, 0.847042085562406, 0.906527610486473,
0.910719128502428, 0.696985262163986, 0.771638707549953, 0.839478591474624,
0.901576276586997, 0.905640684725585, 0.695142736729139, 0.768680421748302,
0.832044479699982, 0.896729834375788, 0.90066589212762, 0.693337823092351,
0.765784794771495, 0.824736410501997, 0.891986288189406, 0.895792829485681,
0.691569159290967, 0.762949945077154, 0.817551141659994, 0.887343662256013,
0.891019593271567, 0.689835433881839, 0.760174052707016, 0.810485525673035,
0.882800001653769, 0.886344298620863, 0.6881353839457, 0.757455357148564,
0.803536507019115, 0.878353373180141, 0.88176508021654, 0.686467793172536,
0.754792155267527, 0.796701119471732, 0.874001866136701, 0.877280093091286,
0.684831490024889, 0.7521827993096, 0.789976483475408, 0.869743593033824,
0.872887513352707, 0.683225345976117, 0.749625694969754, 0.783359803581409,
0.865576690219552, 0.868585538835388, 0.681648273820716, 0.74711929952741,
0.776848365944517, 0.86149931843675, 0.864372389683703, 0.680099226053889,
0.744662120045772, 0.770439535881419, 0.857509663312525, 0.860246308869087,
0.678577193317622, 0.742252711633559, 0.764130755491001, 0.853605935783729,
0.856205562645381, 0.677081202910631, 0.739889675767395, 0.75791954133658,
0.849786372462227, 0.852248440945717, 0.67561031735961, 0.737571658673098,
0.751803482189895, 0.846049235943467, 0.84837325772426, 0.674163633049295,
0.735297349764132, 0.745780236836504, 0.842392815061733, 0.844578351246036,
0.67274027890897, 0.733065480135467, 0.739847531942042, 0.838815425095341,
0.840862084327889, 0.671339415153075, 0.730874821111148, 0.734003159978691,
0.835315407924883, 0.837222844533538, 0.66996023207371, 0.728724182843864,
0.728244977211044, 0.831891132147497, 0.83365904432554, 0.66860194888288,
0.726612412964853, 0.72257090174049, 0.828540993150013, 0.830169121176865,
0.667263812602402, 0.724538395282482, 0.716978911607115, 0.825263413143681,
0.826751537644663, 0.6659450969995, 0.722501048527904, 0.71146704294807,
0.822056841163083, 0.823404781408691, 0.664645101566158, 0.720499325146197,
0.706033388211285, 0.818919753031688, 0.820127365276744, 0.663363150540402,
0.718532210131447, 0.700676094423347, 0.815850651296407, 0.81691782715934,
0.662098591967731, 0.716598719904252, 0.695393361510352, 0.812848065133384,
0.813774730015795, 0.660850796801012, 0.714697901230176, 0.690183440670466,
0.809910550227147, 0.810696661773713, 0.659619158037194, 0.712828830177725,
0.685044632796959, 0.807036688625131, 0.807682235223833, 0.65840308988929,
0.710990611114427, 0.679975286950419, 0.804225088569508, 0.804730087892066,
0.657202026992117, 0.709182375739667, 0.674973798878868, 0.801474384308113,
0.801838881890468, 0.656015423640367, 0.707403282152963, 0.670038609584492,
0.798783235886211, 0.799007303748793, 0.654842753057613, 0.705652513956377,
0.665168203935704, 0.796150328920716, 0.796234064228217, 0.653683506694951,
0.703929279389845, 0.66036110932326, 0.793574374358407, 0.793517898118688,
0.652537193557989, 0.702232810498201, 0.655615894359165, 0.791054108219602,
0.79085756402133, 0.651403339560998, 0.700562362328734, 0.650931167617108,
0.788588291328647, 0.788251844117223, 0.650281486907035, 0.698917212158154,
0.646305576413202, 0.786175709032535, 0.785699543923806, 0.649171193492958,
0.697296658747865, 0.641737805625809, 0.78381517090886, 0.783199492040099,
0.64807203233824, 0.695700021626499, 0.63722657655324, 0.781505510464259,
0.780750539881858, 0.646983591036597, 0.694126640398684, 0.632770645808186,
0.779245584824428, 0.778351561407705, 0.645905471229425, 0.692575874079065,
0.628368804247696, 0.777034274416723, 0.776001452837246, 0.644837288100137,
0.691047100450625, 0.624019875937613, 0.7748704826463, 0.773699132362083,
0.643778669888508, 0.689539715446396, 0.619722717150336, 0.772753135566687,
0.771443539850621, 0.642729257424162, 0.688053132553661, 0.615476215394868,
0.77068118154563, 0.769233636547476, 0.641688703678407, 0.686586782239811,
0.611279288478086, 0.768653590926998, 0.767068404768254, 0.640656673333622,
0.685140111399023, 0.607130883596222, 0.766669355689472, 0.764946847590445,
0.63963284236946, 0.683712582818977, 0.603029976455569, 0.764727489102711,
0.76286798854108, 0.638616897665165, 0.682303674666839, 0.598975570421445,
0.762827025381632, 0.760830871281802, 0.637608536617296, 0.680912879993784,
0.594966695694488, 0.760967019339396, 0.758834559291943, 0.636607466772238,
0.67953970625735, 0.591002408513372, 0.759146546039657, 0.75687813555014,
0.635613405472859, 0.678183674860939, 0.587081790383065, 0.757364700448588,
0.754960702215028, 0.634626079518729, 0.67684432070982, 0.583203947327774,
0.755620597087154, 0.753081380305464, 0.633645224839319, 0.675521191782987,
0.579368009167761, 0.75391336968409, 0.751239309380749, 0.632670586179664,
0.674213848720291, 0.575573128819215, 0.752242170829969, 0.749433647221233,
0.631701916797938, 0.672921864424234, 0.571818481616423, 0.750606171632756,
0.747663569509711, 0.630738978174469, 0.671644823675892, 0.568103264655477,
0.749004561375194, 0.745928269513948, 0.629781539731715, 0.67038232276441,
0.564426696158795, 0.747436547174325, 0.74422695777065, 0.62882937856474,
0.66913396912956, 0.560788014859765, 0.745901353643456, 0.742558861771208,
0.627882279181762, 0.667899381016863, 0.557186479406819, 0.74439822255683,
0.740923225649459, 0.626940033254362, 0.666678187144791, 0.553621367786292,
0.742926412517243, 0.73931930987174, 0.626002439376954, 0.665470026383597,
0.550091976763438, 0.741485198626834, 0.737746390929453, 0.62506930283514,
0.664274547445332, 0.54659762134097, 0.740073872161253, 0.736203761034359
), dim = c(5L, 151L), dimnames = list(c("highest_pi_count", "second_pi_count",
"highest_si_count", "max_overhangz_minus", "max_overhangz_plus"
), NULL))
Codes:
library(latticeExtra)
library(ggplot2)
library(tidyverse)
rownames(data)
as.data.frame(data) |>
rownames_to_column() %>%
pivot_longer(-rowname) %>%
ggplot(aes(factor(name, unique(name)), rowname, fill = value)) +
scale_x_discrete(labels = ~., breaks = ~ c(6:29/10)) + ggtitle("Title") + theme(plot.title = element_text(hjust = 0.5)) +
geom_tile() +
scale_fill_gradientn(colours = c("blue4", "white", "red3")) +
scale_y_discrete(position = "right") +
theme(legend.position = "none",
axis.ticks = element_blank(),
axis.title = element_blank(),
text = element_text(face = 2))
Output:
> rownames(data)
[1] "highest_pi_count" "second_pi_count" "highest_si_count" "max_overhangz_minus" "max_overhangz_plus"
To fix your issue convert row name to factor with the order of the levels set according to the row names of your original dataset:
as.data.frame(data) |>
rownames_to_column() |>
pivot_longer(-rowname) |>
mutate(rowname = factor(rowname, rownames(data))) |>
ggplot(aes(factor(name, unique(name)), rowname, fill = value)) +
scale_x_discrete(labels = ~., breaks = ~ c(6:29 / 10)) +
ggtitle("Title") +
theme(plot.title = element_text(hjust = 0.5)) +
geom_tile() +
scale_fill_gradientn(colours = c("blue4", "white", "red3")) +
scale_y_discrete(position = "right") +
theme(
legend.position = "none",
axis.ticks = element_blank(),
axis.title = element_blank(),
text = element_text(face = 2)
)
I have a dataframe with observations of a temporal event. I can easily plot the observations based on their Xand Y values, either in base R or ggplot2:
plot(df$Y ~ df$X)
ggplot(df, aes(x=X, y=Y)) +
geom_point()
What I'd like to do though is add in the temporal dimension by coloring the observations differently depending on the time they were made. This could be done by defining thresholds for different time steps and assigning discrete colors to each time step. But what I'm interested in is a continuous coloring where the flow of time can be directly read off the flow of colors or color hues or color transparencies. Any help is greatly appreciated.
Reproducible data (slightly shorter than data underlying shown graphs):
structure(list(X = c(171.000358830368, 171.453956550099, 171.075127685269,
171.140924277581, 171.271520544141, 171.582558980529, 171.23762532992,
171.70218914837, 171.318375693213, 170.939546828382, 171.70218914837,
171.779948757467, 171.809856299427, 172.066064242221, 171.603494259901,
171.718139837416, 171.947430992445, 171.930483385334, 172.002261486039,
172.153793031971, 122.654817251517, 171.710164492893, 172.012230666692,
171.395138384244, 171.750041215507, 171.631407965731, 171.927492631138,
172.059085815763, 171.816834725885, 170.787018364384, 170.328436054326,
170.083194210252, 170.405198745358, 170.505887469957, 170.429124778926,
171.187779426653, 171.00634033876, 170.984408141322, 170.731190952725,
170.924593057402, 170.570687144205, 170.751129314032, 170.539782684179,
170.561714881617, 170.461026157017, 170.631499146191, 170.686329639785,
170.863781055416, 170.782033774058, 170.655425179759, 170.645455999106,
170.612557702949, 170.658415933955, 170.514859732545, 170.382269629855,
170.167932245806, 170.187870607113, 169.841940038438, 175.365863038509,
190.973612269532, 206.626222813496, 214.924568789419, 214.509850874236,
211.538038121446, 209.610995501136, 207.007045514458, 204.585531533737,
202.489012842319, 200.693563406635, 199.331773329375, 198.61997383072,
198.494362154486, 202.238786407918, 205.8695620019, 206.616253632843,
207.53541208909, 208.81146721273, 209.850255836818, 210.903998231887,
211.630751501523, 211.825150524265, 211.487195300113, 210.759445112412,
209.407624215806, 207.816542983517, 205.843642132201, 203.585622714198,
201.110275157949, 198.862224920598, 196.914247020916, 195.676074783759,
195.283289066014, 196.015026925976, 197.60710507633, 200.479226022586,
204.110001616568, 207.405812740595, 210.878078362188, 214.015379513825,
216.768867210305, 218.423751198776, 219.404718575074, 219.467524413191,
218.760709504862, 217.317172146244, 215.572565531892, 213.46408382369,
211.338654508377, 209.181323814973, 207.720838849244, 206.537497105681,
205.904454134187, 205.898472625795, 205.953303119389, 206.365030280376,
206.977137972497, 208.319986606516, 209.067675155523, 209.547192744954,
210.106463779612, 210.356690214013, 210.602928976153, 210.692651602034,
210.849167738293, 210.88405987058, 210.998705448095, 211.037585252643,
210.902004395756, 210.895025969299, 210.958828725481, 210.92692734739,
210.975776332592, 211.201079815359, 211.164193846942, 211.304759294155,
210.646793371028, 198.816366689593, 179.579835700717, 164.568243472769,
159.956500502489, 159.636489803513, 159.535801078913, 159.997374143168,
160.238628314981, 160.281495791791, 160.576583539133, 160.637395541118,
156.724492134644, 153.810500629644, 153.846389679996, 154.022844177562,
154.29300897327, 154.442546683072, 154.536256981214, 154.665856329709,
154.665856329709, 154.833338564686, 156.847113056681, 176.676810294436,
177.112463488991, 176.71868085318, 176.042770404877, 175.822451512436,
175.75964567432, 176.817375741649, 176.028813551962, 176.347827332872,
176.622976718907, 182.215687065486, 118.910392998086, 174.380907989949,
171.889609744655, 168.855988071813, 164.924143222097, 160.275514283399,
156.671655477181, 154.165403460906, 107.676123319726, 107.769833617868,
108.581324923058, 109.676937876871, 109.244275436511, 110.393721965853,
161.248506315174, 163.97707106002, 165.507340290323, 166.298893234206,
168.008607716271, 169.06434394747, 170.018394536004, 170.41118025375,
170.202824378093, 170.201827460028, 121.025853132745, 117.483803246579,
120.870333914552, 166.984772863163, 166.489304584687, 168.118268703459,
181.382263562859, 196.653054487796, 135.095357788943, 135.297732156208,
202.44614536551, 203.460011037964, 204.440978414263, 205.227546767819,
205.43490572541, 204.935449774673, 203.891676560258, 202.264706277617,
199.827241607851, 176.081650209426, 194.729002621683, 194.670184455827,
191.186952735516, 190.463190220076, 190.508051533017, 191.482040482858,
186.606114225261, 171.208714706025, 158.889798172571, 149.82880987666,
152.986049389604, 156.597883540345, 159.647455902232, 161.754940692369,
162.893421122992, 114.542894953814, 162.976165322415, 114.268742485845,
160.762010299286, 159.259654774813, 157.995562667957, 156.561994489993,
155.638848361484, 154.469463470836, 154.00390273432, 154.431580584353,
154.255126086787, 155.244068807608, 157.058459686534, 159.101144802424,
161.906472238301, 165.29399982434, 120.406767014167, 172.028181355737,
175.03588315888, 177.740521870158, 179.910812498411, 181.483949205524,
181.988389746588, 181.854802725832, 180.508963337618, 178.901931416283,
176.58609075049, 173.537515306668, 170.679351213327, 167.374567826712,
164.487493109477, 162.203553821774, 160.569605112675, 159.562717866678,
159.828894990125, 159.632502131252, 160.2495944137, 161.450880682439,
162.705003608642, 164.622077048298, 166.212161362521, 167.468278124855,
168.602770883216, 169.155063491416, 169.462114255542, 169.404293007752,
169.003531945484, 168.422328713389, 167.728473739909, 166.825265972708,
165.984864043623, 169.386348482576, 183.504702123976, 200.99862033463,
214.553715269111, 218.552353629205, 217.590327696148, 217.000152201465,
216.115885877505, 215.405083296914, 214.675339273083, 214.063231580962,
213.56477254829, 212.972603217475, 212.488101037718, 212.097309156103,
211.685581995116, 211.786270719716, 211.46426618461, 210.97178866033,
210.657759469747, 210.36167480434, 210.032691842776, 209.635918452769,
209.435537921635, 209.197274504018, 209.046739876151, 208.712772324261,
208.585166811897, 208.3319496233, 203.956476234505, 189.73444311431,
179.21097601654, 176.815381905519, 177.826256823777, 175.90718954799,
175.461567172782, 177.582011897768, 177.488301599626, 177.463378647992,
177.577027307441, 177.676719113976, 177.633851637166, 177.843204430888,
177.995732894886, 177.92196095805, 176.699739409939, 176.824354168107,
176.859246300394, 176.68877331122, 175.325986315895, 176.695751737677,
174.103764767783, 176.520294158177, 178.304777495142, 176.684785638959,
176.697745573808, 177.861148956064, 176.614004456319, 176.121526932039,
176.364774939983, 173.25239673998, 176.064702602315, 174.207444246579,
174.133672309744, 173.831606135945, 174.066878799366, 174.03597433934,
175.830426856959, 174.100774013587, 174.019026732229, 173.965193156701,
173.955223976047, 174.028995912883, 173.886436629538, 174.420784712563,
179.872929611928, 198.741597834692, 208.031877285631, 208.418681494985,
208.232257816765, 247.112062365176, 207.772678588642, 207.722832685375,
207.639091567886, 207.613171698187, 207.569307303312, 207.722832685375,
207.850438197739, 208.002966661736, 208.157488961865, 208.43463218403,
208.722741504914, 209.112536468464, 209.628940026312, 210.13038981318,
211.046557515231, 211.660659043483, 212.448224315105, 213.349438246175,
212.024534137333, 215.36321273817, 216.563502088844, 217.81264042472,
217.271313915238, 218.686937568026, 220.266055783531, 221.81426953901,
223.14814591044, 224.246749618449, 225.106092990776, 225.724182191289,
226.127934007753, 226.088057285139, 225.885682917874, 225.557696874376,
225.048271742986, 257.697338382997, 223.992535511786, 223.464168937154,
223.130201385264, 222.831125965661), Y = c(150.561649721083,
150.067708443465, 150.155166858818, 149.178216605502, 149.407794945803,
148.660423032789, 148.913853668186, 148.276798619991, 148.487493893341,
147.692417390134, 148.3284785927, 147.692417390134, 147.963737246853,
147.216365333839, 147.264069924031, 145.992941364529, 145.626212327424,
144.316323788391, 144.345145311632, 143.45465962804, 118.779460351005,
143.071035215242, 143.299619709914, 142.858352250634, 142.574112400738,
141.615051368744, 141.139993158078, 140.643070343573, 140.190870582374,
140.33597204421, 140.341935117984, 139.946384557638, 140.207765958067,
139.045960417756, 139.269575684283, 138.122677828407, 138.177339338002,
137.268964433088, 137.874216421154, 137.406115129891, 138.076960929472,
137.840425669768, 138.343311558047, 137.691348825417, 138.413874597706,
137.837444132881, 138.70109598449, 138.061059399408, 138.395985376384,
137.616810403241, 138.267779290242, 137.52736429663, 138.054102480005,
137.291822882555, 137.941797923927, 137.242130601105, 137.811604146527,
137.343502855264, 137.326607479571, 135.242513195539, 137.238155218589,
138.312502343547, 139.236778778526, 138.86110513076, 139.273551066799,
138.584816045896, 138.903840492808, 137.509475075308, 137.144733729462,
135.697694493625, 135.567500716225, 134.488184363121, 135.142134787009,
134.959267191271, 135.420411563131, 134.819134957581, 135.649989903432,
135.13120248509, 136.041565081262, 135.646014520916, 136.444072561011,
135.969014350344, 136.521592520073, 135.799066747784, 136.416244883398,
135.748380620704, 136.195611153758, 135.349848523472, 135.534703810467,
134.372898270156, 134.413645940945, 133.470486439016, 133.743793986993,
133.129597388266, 133.61658174648, 133.007354375898, 133.341286507245,
132.799640639435, 133.348243426648, 132.845357538369, 133.241901944344,
132.396139314057, 132.584969983569, 131.617958186543, 131.839585761812,
130.896426259883, 130.981896983977, 129.944322147292, 129.993020583113,
128.968365739605, 128.960414974573, 127.798609434262, 128.082849284158,
127.096954420181, 127.450763464109, 126.738176148109, 127.149628238519,
126.326724057699, 127.023409843635, 126.595062377532, 127.240068190759,
126.893216066235, 127.574000322106, 127.072108279456, 127.73997254215,
127.304668156644, 128.098750814222, 127.663446428716, 128.521135206551,
128.014273935757, 128.852085801011, 128.420756798021, 129.41460242703,
128.987248806556, 129.867796033858, 129.49510392298, 129.345033233,
128.14148617627, 130.371675767766, 130.815924763933, 131.900210345182,
131.529505925561, 132.387194703396, 131.814739621087, 132.715163760969,
132.186437886336, 133.071954341783, 132.563105379731, 133.595710988271,
133.373089567373, 134.173135298725, 133.956476951601, 134.797270353743,
134.562722785297, 135.403516187438, 135.163005545218, 135.992866645441,
131.572241287609, 129.463300862852, 122.968519677278, 123.474387102444,
123.527060920781, 124.246605156184, 123.732786965986, 117.399008772312,
123.862980743386, 124.421521986889, 123.70893467089, 124.808127936574,
126.778923818898, 124.377792779213, 122.935722771521, 124.517925012903,
124.076657553623, 124.838937151073, 124.239648236781, 124.81210331909,
125.153986215469, 125.120195464083, 123.901740722918, 123.046039636341,
120.966914580454, 120.263271875116, 121.53241274336, 121.521480441441,
120.071459668717, 121.39228050967, 120.229481123729, 120.093324272555,
118.693989626911, 118.729768069555, 117.589827133082, 118.195079121148,
108.618382640018, 113.465367772695, 107.992259893742, 117.911833116881,
117.31055651133, 118.451491293432, 122.158535489636, 128.127572337464,
125.310019979223, 125.468041434236, 128.644372064548, 129.146264107198,
128.288575329363, 128.90376577372, 128.18124000143, 128.778541224465,
128.358144523394, 129.135331805279, 128.537036736615, 128.94351959888,
128.079867747271, 127.956630889274, 126.952846803975, 126.741157684996,
125.517733715686, 125.563450614621, 124.14026367388, 123.462460954896,
122.454701487081, 125.26330923466, 123.721854664067, 123.747694650421,
122.82639975233, 123.206048782611, 122.267858508827, 115.131053046914,
122.130707812024, 114.510893374412, 122.343390776632, 123.249777990288,
122.697199820559, 123.432645586025, 123.527060920781, 123.925593018014,
123.003304274293, 124.011063742109, 123.917642252982, 125.041681659391,
124.907512499475, 125.786072035519, 125.602210594152, 126.27603793062,
114.507911837525, 126.00571191953, 125.382570710141, 125.88446275279,
125.144047759179, 125.545561393298, 124.766386420155, 124.993977069198,
124.193931337846, 124.197906720362, 123.290525661077, 123.403824062784,
122.544147593691, 122.783664390282, 121.98361865893, 122.607753713948,
122.271833891343, 122.822424369814, 122.699187511817, 122.789627464057,
122.228104683666, 122.501412231644, 121.437997408604, 121.568191186005,
120.996729949324, 121.368428214574, 120.744293159556, 121.303828248688,
120.7800716022, 121.339606691332, 120.856597715634, 121.619871158713,
121.218357524593, 121.974674048269, 121.564215803488, 122.684279827382,
121.975667893898, 124.308223585182, 126.514560881582, 128.363113751539,
128.091793894819, 128.702015111031, 128.509209059003, 129.155208717859,
128.840159653463, 129.56566696264, 129.235710213809, 130.013891341323,
129.748534558377, 130.711570972887, 130.380620378427, 129.980100589936,
129.586537720849, 130.563487974165, 130.419380357958, 131.614976649656,
131.552364375028, 132.790696028774, 132.718145297856, 133.984304629213,
134.010144615568, 135.165987082105, 135.426374636905, 136.790924685535,
135.130208639461, 129.957242140469, 126.592080840645, 127.358335820611,
127.887061695243, 129.049861081184, 128.986254960927, 130.73840480487,
130.834807830884, 132.108917927273, 132.045311807017, 133.056052811719,
132.901012893594, 133.848147778039, 133.514215646692, 134.505079738814,
134.604464301715, 135.360780825391, 135.037780995963, 135.768257533284,
134.735651924744, 135.809999049703, 134.344076746915, 135.788134445865,
127.311625076047, 135.801054439042, 135.322020845859, 127.889049386501,
135.320033154601, 135.615205306417, 126.665625417191, 134.175122989983,
126.25616101804, 134.430541316638, 133.848147778039, 134.240716801498,
133.809387798508, 134.271526015997, 126.20547489096, 134.244692184014,
133.780566275267, 134.294384465464, 133.818332409169, 134.256618331562,
133.891876985716, 134.534895107684, 127.426911169012, 142.477709374724,
146.033689035318, 147.092134630213, 146.619064110804, 170.36998695286,
146.552476453661, 147.216365333839, 146.709504063044, 147.474765197381,
147.046417731278, 147.842488080114, 147.290903756014, 148.023367984594,
147.353516030642, 147.901124972226, 147.171642280533, 147.729189678407,
147.072257717632, 147.535389780751, 147.15474690484, 146.832740921041,
146.568377983725, 146.13207975259, 144.739702026348, 145.216747928273,
144.640317463447, 144.137431575169, 143.147561328676, 141.941032735059,
141.073405500934, 140.496975036109, 140.057695268087, 139.778424646336,
139.654193942709, 139.203981872768, 138.923717405388, 138.393997685126,
137.79868415335, 137.209333695347, 136.706447807069, 165.401752653445,
135.932242062071, 135.629119145223, 135.168968618992, 134.679002723891
), starttime_ms = c(310849, 310865, 310882, 310899, 310915, 310932,
310949, 310965, 310982, 310999, 311015, 311032, 311049, 311065,
311082, 311099, 311115, 311132, 311149, 311165, 311182, 311199,
311215, 311232, 311249, 311265, 311282, 311299, 311315, 311332,
311349, 311365, 311382, 311399, 311415, 311432, 311449, 311465,
311482, 311499, 311515, 311532, 311549, 311565, 311582, 311599,
311615, 311632, 311649, 311665, 311682, 311699, 311715, 311732,
311749, 311765, 311782, 311799, 311815, 311832, 311849, 311865,
311882, 311899, 311915, 311932, 311949, 311965, 311982, 311999,
312015, 312032, 312049, 312065, 312082, 312099, 312115, 312132,
312149, 312165, 312182, 312199, 312215, 312232, 312249, 312265,
312282, 312299, 312315, 312332, 312349, 312365, 312382, 312399,
312415, 312432, 312449, 312465, 312482, 312499, 312515, 312532,
312549, 312565, 312582, 312599, 312615, 312632, 312649, 312665,
312682, 312699, 312715, 312732, 312749, 312765, 312782, 312799,
312815, 312832, 312849, 312865, 312882, 312899, 312915, 312932,
312949, 312965, 312982, 312999, 313015, 313032, 313049, 313065,
313082, 313099, 313115, 313132, 313149, 313165, 313182, 313199,
313215, 313232, 313249, 313265, 313282, 313299, 313315, 313332,
313349, 313365, 313382, 313399, 313415, 313432, 313449, 313465,
313603, 313619, 313636, 313665, 313682, 313699, 313715, 313732,
313749, 313765, 313782, 313799, 313815, 313832, 313849, 313865,
313882, 313899, 313915, 313932, 313949, 313965, 313982, 313999,
314015, 314032, 314049, 314065, 314082, 314099, 314115, 314132,
314149, 314165, 314182, 314199, 314215, 314232, 314249, 314265,
314282, 314299, 314315, 314332, 314349, 314365, 314382, 314399,
314415, 314432, 314449, 314465, 314482, 314499, 314515, 314532,
314549, 314565, 314582, 314599, 314615, 314632, 314649, 314665,
314682, 314699, 314715, 314732, 314749, 314765, 314782, 314799,
314815, 314832, 314849, 314865, 314882, 314899, 314915, 314932,
314949, 314965, 314982, 314999, 315015, 315032, 315049, 315065,
315082, 315099, 315115, 315132, 315149, 315165, 315182, 315199,
315215, 315232, 315249, 315265, 315282, 315299, 315315, 315332,
315349, 315365, 315382, 315399, 315415, 315432, 315449, 315465,
315482, 315499, 315515, 315532, 315549, 315565, 315582, 315599,
315615, 315632, 315649, 315665, 315682, 315699, 315715, 315732,
315749, 315765, 315782, 315799, 315815, 315832, 315849, 315865,
315882, 315899, 315915, 315932, 315949, 315965, 315982, 315999,
316015, 316032, 316049, 316065, 316082, 316099, 316115, 316132,
316149, 316165, 316182, 316199, 316215, 316232, 316249, 316265,
316282, 316299, 316315, 316332, 316349, 316365, 316382, 316399,
316415, 316432, 316449, 316465, 316482, 316499, 316515, 316532,
316549, 316565, 316582, 316599, 316615, 316632, 316649, 316665,
316682, 316699, 316715, 316732, 316749, 316765, 316782, 316799,
316815, 316832, 316849, 316865, 316882, 316899, 316915, 316932,
316949, 316965, 316982, 316999, 317015, 317032, 317049, 317065,
317082, 317099, 317115, 317132, 317149, 317165, 317182, 317199,
317215, 317236, 317253, 317269, 317286, 317303, 317319, 317336,
317353, 317369, 317386, 317403, 317419, 317436, 317453, 317469,
317486, 317503, 317519, 317536, 317553, 317569, 317586, 317603,
317619, 317636, 317653)), row.names = c(123318L, 123324L, 123333L,
123343L, 123354L, 123363L, 123370L, 123373L, 123376L, 123384L,
123391L, 123399L, 123406L, 123414L, 123424L, 123434L, 123438L,
123440L, 123444L, 123446L, 123449L, 123459L, 123468L, 123477L,
123483L, 123491L, 123502L, 123505L, 123509L, 123516L, 123523L,
123526L, 123532L, 123538L, 123548L, 123556L, 123565L, 123570L,
123574L, 123576L, 123580L, 123586L, 123593L, 123602L, 123611L,
123617L, 123623L, 123627L, 123631L, 123640L, 123648L, 123652L,
123663L, 123671L, 123674L, 123677L, 123684L, 123691L, 123696L,
123706L, 123714L, 123725L, 123733L, 123735L, 123739L, 123741L,
123745L, 123751L, 123756L, 123766L, 123775L, 123777L, 123786L,
123794L, 123800L, 123807L, 123813L, 123816L, 123819L, 123823L,
123833L, 123842L, 123850L, 123861L, 123869L, 123876L, 123884L,
123892L, 123897L, 123904L, 123910L, 123912L, 123917L, 123926L,
123933L, 123939L, 123945L, 123949L, 123953L, 123956L, 123962L,
123968L, 123975L, 123981L, 123988L, 123996L, 124005L, 124015L,
124020L, 124023L, 124029L, 124036L, 124045L, 124054L, 124063L,
124069L, 124079L, 124085L, 124094L, 124103L, 124112L, 124117L,
124124L, 124127L, 124130L, 124137L, 124146L, 124158L, 124169L,
124177L, 124184L, 124189L, 124195L, 124203L, 124213L, 124220L,
124227L, 124234L, 124244L, 124252L, 124257L, 124259L, 124262L,
124265L, 124271L, 124279L, 124291L, 124299L, 124304L, 124312L,
124321L, 124324L, 124328L, 124337L, 124343L, 124347L, 124354L,
124363L, 124415L, 124424L, 124426L, 124435L, 124440L, 124446L,
124454L, 124461L, 124467L, 124469L, 124476L, 124486L, 124493L,
124496L, 124504L, 124510L, 124519L, 124524L, 124531L, 124539L,
124550L, 124555L, 124558L, 124560L, 124564L, 124569L, 124579L,
124586L, 124595L, 124599L, 124608L, 124617L, 124622L, 124629L,
124634L, 124636L, 124640L, 124645L, 124653L, 124660L, 124669L,
124681L, 124694L, 124700L, 124709L, 124716L, 124722L, 124727L,
124730L, 124733L, 124738L, 124743L, 124748L, 124755L, 124766L,
124774L, 124782L, 124786L, 124793L, 124801L, 124808L, 124812L,
124821L, 124831L, 124844L, 124852L, 124861L, 124867L, 124873L,
124877L, 124883L, 124890L, 124901L, 124912L, 124917L, 124921L,
124926L, 124934L, 124943L, 124948L, 124956L, 124958L, 124962L,
124968L, 124977L, 124986L, 124995L, 125005L, 125013L, 125015L,
125018L, 125025L, 125036L, 125046L, 125051L, 125056L, 125063L,
125072L, 125076L, 125078L, 125082L, 125084L, 125091L, 125100L,
125111L, 125118L, 125128L, 125135L, 125143L, 125147L, 125155L,
125165L, 125168L, 125170L, 125178L, 125188L, 125195L, 125203L,
125212L, 125217L, 125220L, 125222L, 125226L, 125238L, 125245L,
125252L, 125256L, 125262L, 125269L, 125278L, 125285L, 125288L,
125292L, 125296L, 125307L, 125319L, 125322L, 125325L, 125329L,
125334L, 125342L, 125351L, 125360L, 125372L, 125379L, 125386L,
125389L, 125392L, 125397L, 125402L, 125411L, 125421L, 125428L,
125436L, 125446L, 125451L, 125457L, 125459L, 125465L, 125470L,
125477L, 125483L, 125490L, 125499L, 125508L, 125515L, 125523L,
125526L, 125532L, 125540L, 125548L, 125550L, 125553L, 125558L,
125564L, 125570L, 125580L, 125588L, 125594L, 125600L, 125604L,
125610L, 125617L, 125624L, 125633L, 125640L, 125647L, 125655L,
125661L, 125669L, 125676L, 125679L, 125686L, 125695L, 125706L,
125716L, 125725L, 125733L, 125737L, 125743L, 125755L, 125758L,
125762L, 125764L, 125769L, 125775L, 125783L, 125790L, 125800L,
125808L, 125815L, 125823L, 125828L, 125834L, 125838L, 125845L,
125852L, 125864L, 125871L, 125880L, 125889L, 125893L, 125896L,
125899L, 125902L, 125904L, 125912L, 125920L, 125931L, 125936L,
125944L, 125952L, 125961L, 125963L, 125969L, 125978L, 125984L,
125991L, 126002L, 126009L, 126018L, 126025L, 126028L), class = "data.frame")
You could do:
library(ggplot2)
ggplot(df, aes(x = X, y = Y, color = starttime_ms)) +
geom_point() +
scale_color_gradientn(colors = c("red", "gold", "forestgreen"), name = "time")
An alternative that might help keep track of the motion better would be to use geom_segment:
df$X2 <- dplyr::lag(df$X)
df$Y2 <- dplyr::lag(df$Y)
ggplot(df, aes(x = X, y = Y, color = starttime_ms)) +
geom_segment(aes(xend = X2, yend = Y2), size = 1) +
scale_color_gradientn(colors = c("red", "gold", "forestgreen"), name = "time")
It is my data:
> dput(data)
structure(list(foldchange = c(-0.17853057272962, 3.60013440830337,
0.648944710423407, 1.38528656859267, 2.38882890772698, 1.91371568283765,
1.77591931363495, -1.51447851175922, 3.1416903855924, 1.51711016957237,
3.14707703341916, -1.44751697381751, 1.23658565660726, -0.512829478520189,
1.68928069854351, 2.07214007434345, 1.24799276690488, 6.25149659558487,
6.35918877435554, 5.86088034655694, 6.38890659730165, 5.05510489389194,
4.62060389613534, 3.75508710774868, 4.18575763169519, 5.31627264153051,
5.87091236649665, 6.71464565321037, 5.24000610137973, 4.25821377851955,
7.32277714374523, 3.1963295806222, 7.26249808789293, 4.44427454088613,
6.21495395454133, 8.74469985969472, 7.49982946564144, 4.45020943795387,
5.66199031471621, 5.29959827685333, 8.65819317196484, 5.86664903755707,
4.5740575604176, 8.24504501687473, 5.7916074097308, 4.18199181353134,
6.73956641707995, 4.60357435173805, 5.9205153184753, 3.65014593638562,
3.25607795403669, 5.56919529940933, 5.76811109641351, 6.10600807588152,
5.69234974521511, 5.5102283323841, 4.71232921328194, 6.55727667796477,
6.19995053763513, 4.64209842048131, 2.29238227264409, 6.79465189260383,
7.51968952300944, 7.81695579226993, 6.29926703626301, 4.64687557749141,
-2.44220257171186, 5.33199370895397, 5.18820654974805, 5.03498241997507,
6.29395095024283, 6.27602377186869, 6.78363927671209, 2.93759015053983,
6.65061604346668, 5.671080311536, 8.45199131823131, 5.79230415012306,
6.3270025568739, 7.0934690916107, 3.53800869528685, 3.08683779646569,
6.82111375813946, 3.02729078403818, 5.36024214796805, 4.04778690916444,
5.74765756930797, 4.10788604670319, 6.39978058654016, 5.7746717387066,
2.9247167920294, 7.54315906042106, 4.2742172444481, 6.61121261965006,
3.77012175922873, 4.94407566887151, 7.93185716981795, 7.05304621480995,
5.59261760605766, 5.42381827536197, 4.22645498896606, 5.15806113482742,
4.15403623593809, 6.40153592433128, 7.38902001442131, 2.72654942454391,
3.28741231093207, 3.79334363176751, 5.86527050546341, 5.10320299162235,
3.99883612485974, 6.45475273104195, 4.85567883821983, 6.55055641729645,
5.03746875764267, 7.27660375171087, 3.30817125205364, 5.23766518187252,
7.6588755830143, 3.53552741086444, 5.66455197986778, 8.40623211540503,
3.93151438658523, 4.26875667827774, 4.38704995079332, 6.75232207417316,
3.76563594385214, 6.08008097541859, 2.40905905886796, 5.50981339395085,
5.78780269825563, 0.2322416329745, 5.69410860233132, 4.94656296117567,
4.20594226169741, 4.50293112094816, 6.07430576125864, 3.67684848946483,
5.825851099141, 5.22439201628482, 7.72829018644622, 5.24910611944979,
4.01783420322782, 6.3888069709767, 5.26066649741256, 4.81678726754752,
6.5683773907454, 4.86957242886115, 6.76705114368644, 4.45769029291236,
7.77607596853254, 6.85213457577069, 1.40150885676552, 5.43409652313493,
3.21738153172066, 6.23015085020594, 5.50091556711613, 3.99948543388746,
5.85816098688073, 4.33775608630599, 5.91715214825299, 5.45674826103132,
7.66790792082782, 6.63325838131012, 3.89631178894691, 2.38526575667126,
1.58661549426288, 4.76626341270591, 6.73426272316295, 5.54006035262931,
4.07996836453406, 7.12087390022358, 6.96007461543701, 5.68202490906633,
6.58504044389069, 5.41036820315057, 6.61076809589319, 1.23772469006557,
4.1661166499875, 2.94059625298825, 8.38336956160413, 4.84906289871508,
4.93787691221829, 6.82379835301371, 5.82520798412864, 4.87582657907206,
5.36621724700676, 8.91922991774938, 3.49025109999629, 5.1232073414505,
4.27193651596412, 5.07417945071012, 3.61930149745523, 2.7469092502892,
6.67162003616042, 4.86698118654996, 7.53876919017093, 4.58878989189686,
5.78956520376246, 3.98567045767003, 8.14934433289609, 6.88879716040936,
7.00251456012974, 5.05095662412332, 6.39777439550296, 7.96268799093557,
4.82826575143863, 8.31032763539508, 4.74493707321909, 6.8929416113222,
6.84202549278968, 8.20121430968127, 2.91031632522241, 4.86190488550545,
5.5516465446887, 7.74996457744065, 2.25505738807845, 5.71069872298306,
1.97493599527532, 5.60445326341706, 6.39297603198736, 7.16298115056911,
4.52688105225386, 6.46061751569601, 4.78104064111529, 2.84526825975018,
6.5537923066898, 6.98258253798747, 5.0967396817644, 6.64593966293456,
4.8990397150507, 4.59878411928317, 5.55158425631398, 2.1065660739172,
2.40396884881286, 6.45421536580342, 5.98567305090568, 6.48593538806214,
7.41313242816247, 5.99024340460149, 5.63812101302136, -1.43793573368627
), all_pvalue = c(0.818887590433193, 0.00892139546812015, 0.434133425685163,
0.0536266013313456, 0.0450933986128537, 0.0367856407800243, 0.0941222253709068,
0.213526299326008, 0.00855327289085924, 0.0449444491492238, 0.00465098209958804,
0.0369667514121697, 0.0910501610463896, 0.378892060498093, 0.0595757077704777,
0.031626850730261, 0.0878934608628569, 0.0124722939899662, 0.0249040599008334,
0.0150448394759397, 0.0104024068916351, 0.0340577599419123, 0.0244947271472485,
0.122485247246688, 0.0211309039009709, 0.0201043058824927, 0.0152779076456381,
0.00938733157248341, 0.013807428170544, 0.01948348499862, 0.0119978631408916,
0.0997968486684091, 0.00504808432168479, 0.041226720485986, 0.0127407583225205,
0.00709338243276709, 0.00383605674079435, 0.0399854589187244,
0.0163222001450531, 0.00909800553027099, 4.81144191594885e-06,
0.0105231068132293, 0.0377428014886314, 0.00709059633291303,
0.00743882656849872, 0.0696633906261403, 0.00568508439144595,
0.0142206230933159, 0.0183625193075117, 0.0818974933908099, 0.0609423408539195,
0.00581572852382799, 0.00603085345605447, 0.00684099077236254,
0.0194814381299995, 0.0325641567545152, 0.0404062983698557, 0.00626431765905907,
0.00287654691487974, 0.0183318967557602, 0.202860908663261, 0.0033395497287839,
0.00804091896430431, 0.00524635934550195, 0.0100089274728679,
0.00470611875383887, 0.361169323059008, 3.90129727113067e-06,
0.0205225005371219, 0.0120500045076898, 0.00732055098038156,
0.0229916087025324, 0.00544774481324614, 0.108252753362848, 0.00911923198666818,
0.0122812312739145, 0.00343585528287351, 2.06257208918569e-05,
0.000904993210532763, 0.0015065294739414, 0.102118204143709,
0.118350948568527, 0.0136202759386966, 0.15251012082679, 0.0428316882385798,
0.0752744217284719, 0.00632986043900174, 0.0269567937932686,
0.00707537967267082, 0.0149356605279715, 0.163005190656644, 0.00929612911973378,
0.0196453775259569, 0.0133262667903121, 0.114115405959882, 0.0189109801950218,
0.00590387539250432, 0.00802692325541374, 0.0184346327727756,
0.00104714399950925, 0.0554774130259537, 0.0084910975380844,
0.0349856904843115, 0.0124547169142572, 8.60050865459788e-07,
0.1188515828269, 0.133720711339729, 0.0641704698591151, 0.0075124796175742,
3.94432669779951e-07, 0.0740343932996142, 0.00160775849728933,
6.61326355967731e-06, 0.0106610228625055, 0.00539717052083514,
0.00492255859958016, 0.122531121480312, 0.0159768620962635, 0.00365780586610517,
0.0135086464724098, 0.0256265865459836, 0.00391215568816396,
0.0271580638871089, 0.0512876942387616, 0.0135566028247977, 0.0169110062500104,
0.0848247460082605, 0.0158705161056627, 0.176345767878009, 0.0124719098589431,
0.0152388258990332, 0.866066700538701, 0.042979313425954, 0.0160125031962862,
0.0441592105265668, 0.0124108545467876, 1.80875437447348e-06,
0.0704671677844812, 0.0111351361909711, 1.62883074487165e-07,
0.000694779973318456, 0.0120079549431507, 0.0196183531679123,
0.0100186493225724, 0.0173294242221405, 0.0573614373022037, 1.30612522568528e-07,
0.023898721968545, 0.00665918028588502, 0.06907634259105, 0.00518730999717143,
0.0109717740506543, 0.394662670743417, 0.0165847750353483, 0.0593829446004973,
0.000113216713641592, 0.0222583368635018, 0.0694462386106761,
0.00437955933335859, 0.0631677226779205, 0.00649674049335009,
1.10699021652115e-07, 0.00543997929535101, 0.00292890932795308,
0.021574456097881, 0.17997075681454, 0.279770535484078, 0.050945514039484,
0.0102923410906512, 0.0103389721465925, 0.112227938286441, 0.00398090342551613,
0.0428676019413789, 0.00337313863923396, 0.0092822848687081,
0.00778850900332348, 0.00146877357609246, 0.448950342618974,
0.0801294647165026, 0.0797698230881222, 3.72112644308374e-05,
0.00728653989704988, 0.0320006421510141, 0.000420503611946363,
0.0207086037412542, 0.0448889114898146, 6.94555482668648e-07,
0.000135994029220134, 0.0982385638169219, 0.0130399195487442,
0.0297056523919866, 0.0208455457844783, 0.104595177359326, 0.100684824982166,
0.00110472016462074, 0.0664329210478157, 0.0140428240948167,
0.0468861767036331, 0.0102813794498838, 0.0693803856754811, 0.00566014993761021,
0.00275831473628789, 0.00234550137829788, 0.0116252548991317,
0.0143153463606759, 0.00995352784254985, 0.00238257560505637,
0.00182950280683248, 0.013195116994233, 0.000640921917352429,
0.000171523469251389, 0.0087256530793244, 0.0989386901919075,
0.0321103798387662, 0.0222773975090858, 0.007943310795799, 0.171053950985746,
0.012874269835152, 0.38817395138115, 0.00787508757030877, 0.0114487159712535,
0.0187831808209386, 0.0452479566115196, 0.00640720682677851,
0.0315482155790946, 0.125132833439637, 0.0115284490664364, 0.00538397509568388,
0.00517772137814985, 0.00176762574966497, 0.0273122011845722,
0.0191341545126795, 0.0235413416908084, 0.270326642321866, 0.179926862630332,
0.008734949388329, 0.0138918131322944, 0.00507817315892406, 0.000173786133243839,
0.00225184544628237, 0.0181059516295825, 0.541544494598043),
probename = c("Mark_1", "Mark_2", "Mark_3", "Mark_4", "Mark_5",
"Mark_6", "Mark_7", "Mark_8", "Mark_9", "Mark_10", "Mark_11",
"Mark_12", "Mark_13", "Mark_14", "Mark_15", "Mark_16", "Mark_17",
"Mark_18", "Mark_19", "Mark_20", "Mark_21", "Mark_22", "Mark_23",
"Mark_24", "Mark_25", "Mark_26", "Mark_27", "Mark_28", "Mark_29",
"Mark_30", "Mark_31", "Mark_32", "Mark_33", "Mark_34", "Mark_35",
"Mark_36", "Mark_37", "Mark_38", "Mark_39", "Mark_40", "Mark_41",
"Mark_42", "Mark_43", "Mark_44", "Mark_45", "Mark_46", "Mark_47",
"Mark_48", "Mark_49", "Mark_50", "Mark_51", "Mark_52", "Mark_53",
"Mark_54", "Mark_55", "Mark_56", "Mark_57", "Mark_58", "Mark_59",
"Mark_60", "Mark_61", "Mark_62", "Mark_63", "Mark_64", "Mark_65",
"Mark_66", "Mark_67", "Mark_68", "Mark_69", "Mark_70", "Mark_71",
"Mark_72", "Mark_73", "Mark_74", "Mark_75", "Mark_76", "Mark_77",
"Mark_78", "Mark_79", "Mark_80", "Mark_81", "Mark_82", "Mark_83",
"Mark_84", "Mark_85", "Mark_86", "Mark_87", "Mark_88", "Mark_89",
"Mark_90", "Mark_91", "Mark_92", "Mark_93", "Mark_94", "Mark_95",
"Mark_96", "Mark_97", "Mark_98", "Mark_99", "Mark_100", "Mark_101",
"Mark_102", "Mark_103", "Mark_104", "Mark_105", "Mark_106",
"Mark_107", "Mark_108", "Mark_109", "Mark_110", "Mark_111",
"Mark_112", "Mark_113", "Mark_114", "Mark_115", "Mark_116",
"Mark_117", "Mark_118", "Mark_119", "Mark_120", "Mark_121",
"Mark_122", "Mark_123", "Mark_124", "Mark_125", "Mark_126",
"Mark_127", "Mark_128", "Mark_129", "Mark_130", "Mark_131",
"Mark_132", "Mark_133", "Mark_134", "Mark_135", "Mark_136",
"Mark_137", "Mark_138", "Mark_139", "Mark_140", "Mark_141",
"Mark_142", "Mark_143", "Mark_144", "Mark_145", "Mark_146",
"Mark_147", "Mark_148", "Mark_149", "Mark_150", "Mark_151",
"Mark_152", "Mark_153", "Mark_154", "Mark_155", "Mark_156",
"Mark_157", "Mark_158", "Mark_159", "Mark_160", "Mark_161",
"Mark_162", "Mark_163", "Mark_164", "Mark_165", "Mark_166",
"Mark_167", "Mark_168", "Mark_169", "Mark_170", "Mark_171",
"Mark_172", "Mark_173", "Mark_174", "Mark_175", "Mark_176",
"Mark_177", "Mark_178", "Mark_179", "Mark_180", "Mark_181",
"Mark_182", "Mark_183", "Mark_184", "Mark_185", "Mark_186",
"Mark_187", "Mark_188", "Mark_189", "Mark_190", "Mark_191",
"Mark_192", "Mark_193", "Mark_194", "Mark_195", "Mark_196",
"Mark_197", "Mark_198", "Mark_199", "Mark_200", "Mark_201",
"Mark_202", "Mark_203", "Mark_204", "Mark_205", "Mark_206",
"Mark_207", "Mark_208", "Mark_209", "Mark_210", "Mark_211",
"Mark_212", "Mark_213", "Mark_214", "Mark_215", "Mark_216",
"Mark_217", "Mark_218", "Mark_219", "Mark_220", "Mark_221",
"Mark_222", "Mark_223", "Mark_224", "Mark_225", "Mark_226",
"Mark_227", "Mark_228", "Mark_229", "Mark_230", "Mark_231",
"Mark_232", "Mark_233", "Mark_234", "Mark_235", "Mark_236",
"Mark_237", "Mark_238", "Mark_239", "Mark_240", "Mark_241",
"Mark_242")), row.names = c("Mark_1", "Mark_2", "Mark_3",
"Mark_4", "Mark_5", "Mark_6", "Mark_7", "Mark_8", "Mark_9", "Mark_10",
"Mark_11", "Mark_12", "Mark_13", "Mark_14", "Mark_15", "Mark_16",
"Mark_17", "Mark_18", "Mark_19", "Mark_20", "Mark_21", "Mark_22",
"Mark_23", "Mark_24", "Mark_25", "Mark_26", "Mark_27", "Mark_28",
"Mark_29", "Mark_30", "Mark_31", "Mark_32", "Mark_33", "Mark_34",
"Mark_35", "Mark_36", "Mark_37", "Mark_38", "Mark_39", "Mark_40",
"Mark_41", "Mark_42", "Mark_43", "Mark_44", "Mark_45", "Mark_46",
"Mark_47", "Mark_48", "Mark_49", "Mark_50", "Mark_51", "Mark_52",
"Mark_53", "Mark_54", "Mark_55", "Mark_56", "Mark_57", "Mark_58",
"Mark_59", "Mark_60", "Mark_61", "Mark_62", "Mark_63", "Mark_64",
"Mark_65", "Mark_66", "Mark_67", "Mark_68", "Mark_69", "Mark_70",
"Mark_71", "Mark_72", "Mark_73", "Mark_74", "Mark_75", "Mark_76",
"Mark_77", "Mark_78", "Mark_79", "Mark_80", "Mark_81", "Mark_82",
"Mark_83", "Mark_84", "Mark_85", "Mark_86", "Mark_87", "Mark_88",
"Mark_89", "Mark_90", "Mark_91", "Mark_92", "Mark_93", "Mark_94",
"Mark_95", "Mark_96", "Mark_97", "Mark_98", "Mark_99", "Mark_100",
"Mark_101", "Mark_102", "Mark_103", "Mark_104", "Mark_105", "Mark_106",
"Mark_107", "Mark_108", "Mark_109", "Mark_110", "Mark_111", "Mark_112",
"Mark_113", "Mark_114", "Mark_115", "Mark_116", "Mark_117", "Mark_118",
"Mark_119", "Mark_120", "Mark_121", "Mark_122", "Mark_123", "Mark_124",
"Mark_125", "Mark_126", "Mark_127", "Mark_128", "Mark_129", "Mark_130",
"Mark_131", "Mark_132", "Mark_133", "Mark_134", "Mark_135", "Mark_136",
"Mark_137", "Mark_138", "Mark_139", "Mark_140", "Mark_141", "Mark_142",
"Mark_143", "Mark_144", "Mark_145", "Mark_146", "Mark_147", "Mark_148",
"Mark_149", "Mark_150", "Mark_151", "Mark_152", "Mark_153", "Mark_154",
"Mark_155", "Mark_156", "Mark_157", "Mark_158", "Mark_159", "Mark_160",
"Mark_161", "Mark_162", "Mark_163", "Mark_164", "Mark_165", "Mark_166",
"Mark_167", "Mark_168", "Mark_169", "Mark_170", "Mark_171", "Mark_172",
"Mark_173", "Mark_174", "Mark_175", "Mark_176", "Mark_177", "Mark_178",
"Mark_179", "Mark_180", "Mark_181", "Mark_182", "Mark_183", "Mark_184",
"Mark_185", "Mark_186", "Mark_187", "Mark_188", "Mark_189", "Mark_190",
"Mark_191", "Mark_192", "Mark_193", "Mark_194", "Mark_195", "Mark_196",
"Mark_197", "Mark_198", "Mark_199", "Mark_200", "Mark_201", "Mark_202",
"Mark_203", "Mark_204", "Mark_205", "Mark_206", "Mark_207", "Mark_208",
"Mark_209", "Mark_210", "Mark_211", "Mark_212", "Mark_213", "Mark_214",
"Mark_215", "Mark_216", "Mark_217", "Mark_218", "Mark_219", "Mark_220",
"Mark_221", "Mark_222", "Mark_223", "Mark_224", "Mark_225", "Mark_226",
"Mark_227", "Mark_228", "Mark_229", "Mark_230", "Mark_231", "Mark_232",
"Mark_233", "Mark_234", "Mark_235", "Mark_236", "Mark_237", "Mark_238",
"Mark_239", "Mark_240", "Mark_241", "Mark_242"), class = "data.frame")
I would like to create a nice graph (publication wise) to represent a data stored in this data frame. In general I would like to create a scatterplot or volcano plot with colors/shapes indicating what is important in my data.
I would like to achieve something like that:
Or:
As a filter cutoff we can start with: foldchange > 4 & all_pvalue < 0.05. I would like to also have a possibility to highlight (different color/shape and with a label) only couple of rows. Lets say as a starting point I would like to highlight Mark_23 and Mark_65.
Is it doable in R ? I have already tried something with volcano plot:
volcano = ggplot(data = data, aes(x = foldchange, y = -1*log10(all_pvalue)))
volcano + geom_point()
Can someone help me with going further ?
Here is an attempt to show what's possible
data$zones := interaction(abs(data$foldchange)>4,data$all_pvalue<0.05)
library(ggplot2)
library(ggrepel)
ggplot(data = data, aes(x = foldchange, y = -1*log10(all_pvalue),color = zones))+
geom_point()+
theme_light()+
geom_label_repel(aes(label=ifelse(probename %in% c("Mark_23","Mark_65"),as.character(probename),"")),
box.padding = 0.35,
point.padding = 0.5,
segment.color = 'grey50',show.legend = FALSE) +
geom_hline(yintercept = -1*log10(0.05),linetype = "dashed")+
geom_vline(xintercept = 4,linetype = "dashed")+
scale_color_manual(labels = c("bad", "also bad","good","not sure"), values = c("gray50","green","blue", "red"))+
labs(x = "fold change",
y = expression(log[10](p)),
color = "meaning")
there are many things here. geom_label_repel from library(ggrepel) allow to link your few points you want to show with a label. The easiest way of having the different colours is to create a variable that says in what zone you are. That is what I did with the zones variable, that you use in colour to have a changing color. You can manualy change it with the scale_color_manual function.
In the labs function I used the expression function that allows you to do superscripts. You can of course change the theme including, margins, axis, text size etc.
You can for example add theme(legend.position="top") to your plot to have the legend on top.
Instead of adding legends outside the plot, I want to add names such as "Quantile 1", "Quantile 10" etc. inside the plot as labels.
ggplot() +
geom_line(data=df.quants, aes(x=xvars, y=q01), color="black", size =0.5) +
geom_line(data=df.quants, aes(x=xvars, y=q10), color="black", size =0.7) +
geom_line(data=df.quants, aes(x=xvars, y=q25), color="black", size =1) +
geom_line(data=df.quants, aes(x=xvars, y=q50), color="black", size =1.2) +
geom_line(data=df.quants, aes(x=xvars, y=q75), color="black", size =1) +
geom_line(data=df.quants, aes(x=xvars, y=q90), color="black", size =0.7) +
geom_line(data=df.quants, aes(x=xvars, y=q99), color="black", size =0.5) +
geom_ribbon(data=df.quants,aes(x=xvars,ymin=q25,ymax=q75),alpha=0.8)+
geom_ribbon(data=df.quants,aes(x=xvars,ymin=q10,ymax=q25),alpha=0.5)+
geom_ribbon(data=df.quants,aes(x=xvars,ymin=q75,ymax=q90),alpha=0.5)+
geom_ribbon(data=df.quants,aes(x=xvars,ymin=q01,ymax=q10),alpha=0.2)+
geom_ribbon(data=df.quants,aes(x=xvars,ymin=q90,ymax=q99),alpha=0.2)+
theme_bw()+
ggtitle("Q")+
ggsave("save.png")
How can I add labels on the plot in either or both of these cases:
At the end of the lines (e.g. https://stackoverflow.com/a/37696769/3942806)
Hovering over the lines towards the left hand side (https://stackoverflow.com/a/37672486/3942806)
dput(df.quants)
structure(list(xvars = c(21.1084, 40.4038, 42.4758, 44.0298,
44.8068, 53.0948, 53.3538, 54.3898, 56.4617, 62.9367, 67.3397,
68.8937, 68.8937, 74.3327, 78.7356, 80.2896, 87.8006, 95.0526,
98.6785, 105.6715, 114.4775, 116.5495, 121.7294, 127.4274, 133.6434,
146.3343, 153.0683, 158.2483, 163.6872, 169.9032, 180.7812, 186.4791,
186.9971, 194.5081, 196.3211, 203.8321, 209.789, 215.746, 218.336,
222.998, 230.7679, 237.5019, 241.1279, 242.12505, 250.9698, 254.0778,
264.1788, 274.5387, 284.8987, 292.6687, 303.0286, 310.7986, 326.3385,
336.6985, 344.4684, 362.5983, 378.1383, 389.275200000003, 393.6782,
409.2181, 427.348, 450.6579, 450.6579, 450.6579, 453.2479, 463.6079,
476.5578, 489.5078, 499.8677, 510.2277, 523.1776, 533.5376, 543.8975,
567.2074, 611.2372, 613.8272, 621.5971, 637.1371, 652.677, 660.447,
668.2169, 678.5769, 696.447800000002, 714.8367, 744.880600000001,
764.0465, 766.6365, 779.5864, 784.7664, 810.6663, 815.8463, 839.1561,
852.1061, 872.826, 896.1359, 903.9059, 916.8558, 937.5757, 966.0656,
984.1955), q01 = c(0.07287449, 0.0573897264, 0.0557969357, 0.0537193707,
0.0518303892, 0.0518080158, 0.0514479006, 0.0517025388, 0.0516258276,
0.0459982978, 0.0471084591, 0.0402322638, 0.0406957203, 0.0373694866919881,
0.0375932247971234, 0.0378606448, 0.0374813557445557, 0.036479866,
0.0368506252, 0.0362731762, 0.0367099924, 0.0329852952, 0.0280992996,
0.0278553199, 0.0277327966, 0.0279245722, 0.0279458806, 0.0277967218,
0.0279831703, 0.0237609194, 0.0207585756691242, 0.0207543139705945,
0.0196036650330279, 0.0188940975085873, 0.0186277436, 0.0167249092,
0.0167046666, 0.0166865548, 0.0161687604, 0.0161591718, 0.0161879376,
0.011199656, 0.0111985905, 0.01105689088, 0.0110845916, 0.0106222032239633,
0.0109610059070531, 0.0109652675220967, 0.0109769869296186, 0.01043682232,
0.00988280416, 0.00995951416, 0.0109119973340507, 0.0099936076,
0.00955359025, 0.00895376068, 0.00836565071, 0.00829852949, 0.00825058604,
0.00660771382, 0.00658320918, 0.00658320918, 0.00647347103215001,
0.00720008536, 0.00722565544, 0.00697102063, 0.00688152578, 0.00688898372,
0.00692733882, 0.00618580850401875, 0.0061218835, 0.0061090985,
0.00609311725, 0.00584274444, 0.00583954821, 0.00575325, 0.00575325,
0.0050873645, 0.00522693399, 0.00516087826, 0.00496803746, 0.00490198142,
0.00490198142, 0.00490198142, 0.0057798848, 0.00555082036, 0.00518857905,
0.00508949534, 0.0050127851, 0.0049701683, 0.0049275515, 0.00487428075,
0.00479011332, 0.00476347782, 0.0047783937, 0.00476880492, 0.00487747698,
0.00485510337, 0.0048582996, 0.00479330958), q10 = c(0.492542083954826,
0.45454932, 0.43124864, 0.41944381, 0.37937352, 0.38026848, 0.37053055,
0.37472832, 0.35278072, 0.34281907, 0.34762414, 0.28118472, 0.28004471,
0.272746634508843, 0.24855102, 0.25194972, 0.242531451945451,
0.2256552, 0.206232684634562, 0.19673984, 0.20522054, 0.18095038,
0.170956713240997, 0.16841043, 0.163157896833582, 0.16456426,
0.16100576, 0.15623268, 0.15471976, 0.15003198, 0.143000209281909,
0.1429789, 0.14078417, 0.13547836, 0.13492432, 0.13260178, 0.12952273,
0.1337311, 0.1273386, 0.123471123238866, 0.12135096, 0.10445342,
0.10836355, 0.10458128, 0.10262094, 0.10075645, 0.10061794, 0.099659066,
0.099925431, 0.0973364588484978, 0.0949499261725975, 0.0949499261725975,
0.1001705, 0.09823141, 0.091689753, 0.0820796952618794, 0.080683995,
0.079256336, 0.078052418, 0.0678883475337737, 0.067302367, 0.0675474110377157,
0.065970594, 0.068889834, 0.069379928, 0.06499041, 0.0639143363015129,
0.0628169628570211, 0.061410608, 0.0606541642970382, 0.0605369686562966,
0.06094183, 0.0605476229844449, 0.0566162367773279, 0.056371194,
0.054080544, 0.0546025993937779, 0.051779245, 0.052375877, 0.051907098,
0.050639252, 0.050308969, 0.050308969, 0.050308969, 0.053643725,
0.053505218, 0.0507671, 0.049691026, 0.04884935, 0.04810356,
0.04757085, 0.04687833, 0.045727678, 0.045503944, 0.04687833,
0.046729174, 0.051971022, 0.050308975, 0.0498615, 0.048039636
), q25 = c(0.6404219, 0.6244939, 0.605822475, 0.602040281120818,
0.5927978, 0.588349675, 0.579639875, 0.5777754, 0.5689325, 0.55953015,
0.5641647, 0.53696995, 0.53358725, 0.518511625, 0.509855075,
0.5100149, 0.4870019, 0.477573, 0.46324315, 0.45551885, 0.4599403,
0.4263797, 0.414766675, 0.403526531046239, 0.39313875, 0.385361200596633,
0.3733752, 0.364585555646708, 0.358486025, 0.34375665, 0.321915594917963,
0.3211166, 0.317574060052206, 0.299701695823567, 0.2932026, 0.28931385,
0.27794055, 0.28041765, 0.2627317, 0.252370517653953, 0.248348618836565,
0.2258683, 0.2306094, 0.22400385, 0.2216066, 0.21785105, 0.214521628563819,
0.2121244, 0.210153425, 0.2043469, 0.2011506, 0.2003516, 0.207196875,
0.206317924738973, 0.200431525, 0.189537609205199, 0.187220325,
0.181600263653314, 0.179948860004262, 0.1733433, 0.1733433, 0.170413425,
0.1667377, 0.16812275, 0.16993395, 0.1648199, 0.16276905, 0.15768165,
0.15347325, 0.150916225, 0.14910505, 0.14990415, 0.1474537, 0.1441509,
0.142712575, 0.138690575, 0.14098125, 0.135813975, 0.137385475,
0.14217985, 0.139969074168975, 0.139516275, 0.139516275, 0.139516275,
0.143751322267206, 0.1424995, 0.140688225, 0.1389303, 0.136639675,
0.134801865933305, 0.137785025, 0.135813975, 0.132537822288515,
0.128356075, 0.129900875, 0.1293416, 0.14106115, 0.137598575,
0.1421266, 0.1387705), q50 = c(0.7691242, 0.7631579, 0.75559345,
0.751917760334541, 0.7506925, 0.746484148060942, 0.7420094, 0.7371617,
0.7325804, 0.72565525, 0.72682715, 0.7165992, 0.7147347, 0.702002962412103,
0.69640955, 0.6950778, 0.6869806, 0.6838909, 0.6740358, 0.6714255,
0.6721713, 0.6567228, 0.64947795, 0.63834435, 0.6361602, 0.6261453,
0.613253782228852, 0.603665, 0.593756671084594, 0.579267, 0.5622203,
0.5610484, 0.5582783, 0.5308971, 0.5144897, 0.5100149, 0.49355425,
0.4915832, 0.4779459, 0.4607394, 0.4513105, 0.424462, 0.42510125,
0.4174302, 0.4121031, 0.40336673736416, 0.3968677, 0.3919668,
0.39036865, 0.3808864, 0.373961218836565, 0.3727893, 0.38408265,
0.3834434, 0.37646495, 0.3681014, 0.3637332, 0.3615491, 0.3576603,
0.3552099, 0.35398465, 0.34775195, 0.3416791, 0.3381632, 0.3388025,
0.33187725, 0.33059875, 0.3258044, 0.3180268, 0.3064138, 0.3049222,
0.3091839, 0.3065736, 0.2999148, 0.29900915, 0.2925634, 0.3009802,
0.2956531, 0.29698485, 0.3044961, 0.30412315, 0.3014596, 0.3014596,
0.3014596, 0.3147773, 0.3135521, 0.3128596, 0.30998295, 0.3091306,
0.3039633, 0.30907735, 0.303856783177072, 0.2949073, 0.28595785,
0.285371829778393, 0.2846793, 0.2958662, 0.29607925, 0.3035372,
0.30359045), q75 = c(0.8668229, 0.8637865, 0.86104305, 0.858752425,
0.8584061, 0.8549169, 0.852066925, 0.8492436, 0.8462604, 0.843783275,
0.843410426177285, 0.838909, 0.838349675, 0.833795025, 0.831530975,
0.8301726, 0.8252717, 0.8239399, 0.820557211213509, 0.81797355,
0.8167483, 0.8088643, 0.80244515, 0.7948274, 0.7947475, 0.787183054698487,
0.7810036, 0.77716815, 0.769097575, 0.7540486, 0.74861495, 0.7479224,
0.746617297091413, 0.7200618, 0.704879607926699, 0.702588945727679,
0.690203494363946, 0.68458345, 0.6740891, 0.658480725, 0.6435649,
0.630833155763904, 0.626811225, 0.62129765, 0.6129342, 0.60827295,
0.60275945, 0.593117408906883, 0.59125295, 0.58507352145749,
0.5743661, 0.5681334, 0.5741264, 0.575431476028127, 0.573353929725122,
0.5659493, 0.560702075, 0.556706775, 0.5519923, 0.54645215, 0.53976665,
0.53526525, 0.5334541, 0.5324419, 0.52743445, 0.519204135014916,
0.519017675, 0.517899, 0.50905605, 0.495258875, 0.5004794, 0.50298315,
0.491023875559344, 0.4816748, 0.485164082175581, 0.479171075,
0.48889305, 0.482500525, 0.485696775, 0.4886533, 0.4919028, 0.490890725,
0.490890725, 0.490890725, 0.506552325, 0.50649905, 0.504741075,
0.49978695, 0.502477093543576, 0.492915025, 0.49629765, 0.4903047,
0.4775197, 0.4731249, 0.464175375, 0.4632431, 0.46942255, 0.472725375,
0.4760281, 0.474536573433838), q90 = c(0.9314937, 0.93079054,
0.92979966, 0.928574429757085, 0.92748774, 0.92662476, 0.92585765,
0.9235457, 0.92188366, 0.92058388, 0.91802683, 0.91566162, 0.91534197,
0.9129022, 0.91192198, 0.91067548, 0.907671, 0.9073088, 0.90595568,
0.904773066349883, 0.9035372, 0.897741346746218, 0.89466225,
0.889740052584701, 0.88860004, 0.88158958, 0.88022584, 0.878883448075858,
0.86893244, 0.863030027896868, 0.86177288, 0.8616024, 0.859290453515875,
0.8365012, 0.82799918, 0.824568514587684, 0.819273379833795,
0.81630088, 0.81448968, 0.79439591, 0.78960152, 0.783315567773279,
0.776464946030258, 0.776731300370765, 0.76594926, 0.75919456,
0.75371832, 0.75075644, 0.74735775, 0.74310678, 0.72495204, 0.7112508,
0.713807792386533, 0.7141487, 0.71468144, 0.713530774319199,
0.71050504, 0.707809474097592, 0.70632856, 0.70217348, 0.69276586,
0.68746007, 0.68621354, 0.68354994, 0.67928834, 0.66894312, 0.66838907,
0.66891114, 0.66275304248029, 0.65147025, 0.655188582416365,
0.65889626, 0.64831662, 0.640571045322821, 0.64626035, 0.64103984,
0.637385467717878, 0.63600045, 0.639899844314937, 0.638908996019603,
0.64134882, 0.64137014, 0.64137014, 0.64137014, 0.6497443, 0.64977628,
0.64734715, 0.64238229, 0.6446303, 0.634775211037716, 0.635307911037716,
0.631685502855317, 0.62823354, 0.62139354, 0.61645005, 0.61583208,
0.61267846, 0.61427655, 0.6135734, 0.61338161), q99 = c(0.9813552,
0.983496688, 0.982289538, 0.981875103, 0.98133816, 0.981210342,
0.980869382, 0.98074156, 0.980605188, 0.980628629, 0.980474118,
0.97956530234349, 0.979405495101854, 0.979192435, 0.979102933,
0.97900704, 0.978866424, 0.97889414, 0.978801398, 0.978465764,
0.978167456, 0.97708924, 0.977054095, 0.977258668, 0.975373952,
0.972782846, 0.972770058, 0.972859574, 0.972306655, 0.97231411,
0.972591068, 0.97259746, 0.972355645, 0.962840406286384, 0.963136582842531,
0.943974016, 0.944772016962071, 0.944242504, 0.944018764, 0.935328143137652,
0.935241848623481, 0.934724015665886, 0.926759001178564, 0.926816535265289,
0.926234804, 0.917745605, 0.91511187081824, 0.915103346793096,
0.913937796999999, 0.90959943, 0.903311344, 0.894027274664394,
0.895148090432559, 0.897357759215854, 0.897743441, 0.894050713829107,
0.893945237587897, 0.889042197096101, 0.889281912489239, 0.888979338,
0.886543834, 0.886235893490944, 0.886239091206478, 0.886258277499681,
0.868235644, 0.868526506, 0.870900274999999, 0.871323255148946,
0.869995737948434, 0.867188371, 0.864700617419987, 0.864726187301939,
0.856755777, 0.844385296, 0.855691437, 0.83904428249137, 0.832750945,
0.837923525, 0.856581078, 0.855506063483912, 0.855462386340294,
0.838475343, 0.838475343, 0.838475343, 0.855438949824206, 0.855484757560196,
0.855492214633497, 0.855447472193693, 0.855524173519071, 0.85631259,
0.859764525, 0.861629, 0.865305772, 0.861820776, 0.861149560000001,
0.861581055999999, 0.861485167999999, 0.858912205, 0.86234816,
0.860478344)), .Names = c("xvars", "q01", "q10", "q25", "q50",
"q75", "q90", "q99"), row.names = c(NA, -100L), class = "data.frame")
You should try the directlabels package. Here's an example:
library(tidyverse)
library(directlabels)
df.quants %>%
gather(var,val,-1) %>%
ggplot(aes(xvars,val,fill=var)) +
geom_area(position="identity", alpha = .5) +
geom_line() +
scale_fill_grey(guide="none") +
geom_dl(aes(label=var), method="last.points")
Make sure to browse through its documentation as there are many more options.
You can extend that approach to also use custom labels, linewidths, fillings etc. One way could be:
labs <- setNames(c("G", "F", "E", "D", "C", "B", "A"), c("q99", "q90", "q75", "q50", "q25", "q10", "q01"))
df.quants %>%
rev %>%
gather(var,val,-xvars,factor_key=TRUE) %>%
ggplot(aes(xvars,val,fill=var)) +
geom_area(position="identity") +
geom_line(aes(size=var)) +
scale_fill_manual(values = c(grey.colors(3,.9,.3), grey.colors(4)), guide="none") +
scale_size_manual(values = c(1:3,4:1), guide="none") +
geom_dl(aes(label=labs[var]), method="last.points")
I am trying to find a point where a big change happens on a slope.
Tried to use ecp::e.divisive() function with different settings and couldn't make it identify the change the way I need.
Below code and plot should illustrate more. Grey lines are cutoffs coming from ecp package, and I am trying to it to plot blue line (which is at the moment plotted manually).
Please advise if there are better packages for this task.
library("ecp")
#get cutoff points
ecpOutput <- e.divisive(x, k=1)
ecpOutput$estimates
#plot
plot(x, bty = "n")
abline(h = 0, lty = "dashed", col = "grey")
#add ecp estimates
abline(v = ecpOutput$estimates, col = "grey", lty = 2)
#ideal line, doesn't have to be exact, anything around this line is OK
abline(v = 384, col = "blue", lty = 2)
Data: x is a sorted 1 column matrix (required structure by ecp).
x <- structure(c(-27.0409169663486, -26.129156710088, -24.7600585044449,
-24.3953228174759, -24.1577613311647, -23.5016667274094, -20.6947912955816,
-20.5608424516568, -20.2274448352933, -20.1776769950718, -20.0154244013066,
-19.9185729879804, -18.6495729388285, -18.5966280348446, -18.4877201244377,
-17.8697488852, -17.6964369055135, -17.4580050047899, -17.4503603253745,
-17.2138236467553, -17.1978137674216, -17.0883917900212, -17.0780609255085,
-16.5936774343097, -16.5302509987677, -16.5047064149008, -16.3610339293733,
-16.3179953827084, -15.8098489669017, -15.8017464582135, -15.7931978631991,
-15.7048014947664, -15.6438615495371, -15.5724025176269, -15.4769417976187,
-15.4566078151486, -15.3683766952941, -15.3598144860889, -15.2872530572521,
-15.2615773975834, -15.1553721281872, -15.1253479156971, -14.8574803029005,
-14.7886609612358, -14.7052679457918, -14.6700476095839, -14.4967591359077,
-14.3902100635321, -14.1344579537429, -14.1122694462137, -13.6977777268339,
-13.5002575880219, -13.3931536856711, -13.2720061859572, -13.1630633420915,
-13.120694599871, -13.0989354290794, -13.0305773443162, -13.0247860189105,
-12.9679198987695, -12.9339256928714, -12.7503935672128, -12.6086380226913,
-12.5204925937268, -12.5018027956008, -12.3362734240611, -12.2633206830352,
-12.2389866512024, -12.2261511983906, -12.2082248950284, -12.1988063383678,
-12.1625438078306, -12.105137364671, -12.0283612849999, -12.0207914207455,
-11.9569828730108, -11.9377135887775, -11.7974478043662, -11.7856404961775,
-11.7070359492143, -11.685818522575, -11.6150116648869, -11.5889351441476,
-11.5696939812167, -11.5218497980405, -11.4278460823336, -11.2616735602107,
-11.1371735315344, -11.1101486927449, -11.0545987008828, -11.0497610649959,
-10.9777305856557, -10.9538432991084, -10.8709063558819, -10.8321978567433,
-10.7154060103612, -10.6904665022414, -10.6728147078525, -10.6319097418566,
-10.6084139374132, -10.5435156393802, -10.4969417190754, -10.4910751521816,
-10.4076974735856, -10.1987743033507, -10.1084368444001, -10.067653486032,
-10.0184841375099, -10.0184804878766, -9.98796628047806, -9.92940612537163,
-9.79791464687017, -9.78385633218692, -9.74746828052048, -9.5340969261009,
-9.3872416240278, -9.34975526969295, -9.34350605265574, -9.33678121532548,
-9.28246068708019, -9.26231844050325, -9.24219935644902, -9.22973616812829,
-9.1945301757694, -9.18742543173638, -9.09818179983656, -8.84383892771356,
-8.71390231428188, -8.63727799501085, -8.62365985718404, -8.57368937545283,
-8.56896270190976, -8.51750651338242, -8.36994967607861, -8.34940777555791,
-8.24579609778514, -8.16499004491889, -8.13648089733029, -8.12443902872708,
-8.06884804631702, -8.01978044346555, -8.00857010892087, -7.98752833340474,
-7.98494612290397, -7.92263788171607, -7.92262794402356, -7.91254741704133,
-7.8612668717642, -7.85956255484269, -7.80614005087113, -7.78172738274975,
-7.76590807725416, -7.73362312192246, -7.73353827316045, -7.73074597208869,
-7.66932615651785, -7.63405189653259, -7.52008106079428, -7.4794467369495,
-7.37006671254996, -7.33891732414829, -7.28638734342099, -7.18383241390338,
-7.16967207372779, -7.12414638131948, -7.11845633549842, -7.10069950413643,
-7.08453272839936, -7.06225675561229, -7.01372949292662, -6.97700431366834,
-6.96221498775977, -6.95474531960413, -6.92853733102012, -6.87948984857266,
-6.81875907966932, -6.80049432153244, -6.74491178906506, -6.73722594655536,
-6.65241543109368, -6.64432866218849, -6.57471615362753, -6.538942870458,
-6.48556582657451, -6.44344567639388, -6.44142334658235, -6.40718664187937,
-6.37631310536975, -6.35766817597632, -6.33004629281548, -6.32243131413274,
-6.31465060236999, -6.30957529705468, -6.20042487075657, -6.19852760812695,
-6.19516991943952, -6.19169299941109, -6.14915041772936, -6.1341182105985,
-6.06886854629022, -6.03316938455024, -5.92620275477516, -5.915861751696,
-5.8993712054553, -5.8562854376353, -5.81203754357936, -5.81031989834777,
-5.79005016179402, -5.70715392727825, -5.64380201251138, -5.61822898444235,
-5.61198428778589, -5.55181215637224, -5.5414283688058, -5.51873245882438,
-5.51677200116567, -5.51551938308407, -5.50995967349956, -5.47456882908066,
-5.46182989367447, -5.34425037377986, -5.32571672656563, -5.24036884690065,
-5.2280272754873, -5.13269699736861, -5.13115055948407, -5.09522822858288,
-5.06292167413738, -5.05058297801937, -5.00080776299476, -4.99907315892117,
-4.96652519349395, -4.94319578011658, -4.93410325981468, -4.88778233710964,
-4.86817149761772, -4.86068237590916, -4.86018697766406, -4.79260202993216,
-4.78704006512903, -4.7697286436275, -4.74319640834353, -4.66791717712299,
-4.63451063153309, -4.55913300698176, -4.54773156325591, -4.5029917001588,
-4.50232432311584, -4.48448651461267, -4.48195952916376, -4.45942294767531,
-4.43684117621408, -4.39862573806896, -4.39218230499561, -4.32218627745706,
-4.29986813130089, -4.25622220689577, -4.24164586680005, -4.1312719357839,
-4.12513288512985, -4.07946940297387, -4.07261512152973, -4.01165511465604,
-3.95381138375493, -3.95044337911054, -3.92340302872436, -3.91833355363622,
-3.87865234740553, -3.84667242505411, -3.78315737709957, -3.76505984684618,
-3.76018864171568, -3.71684064078827, -3.70873189126336, -3.69375597807388,
-3.69325959119626, -3.6505984611436, -3.62183744181462, -3.58883235361055,
-3.52391205093927, -3.51617596119693, -3.51388800083065, -3.33813297717772,
-3.26837985172665, -3.25102638292739, -3.24658212799339, -3.22891542458543,
-3.17892565704276, -3.1283260157199, -3.04352634415322, -3.02299584335501,
-3.01373331291241, -2.99552385674378, -2.86372198270148, -2.83811475137176,
-2.77463274263238, -2.69783066358124, -2.69434624147968, -2.65941589188957,
-2.6221506974122, -2.57311913722599, -2.56672727866588, -2.56667581533302,
-2.55574357522681, -2.50395283367281, -2.49786830801457, -2.46604172470746,
-2.42877871397163, -2.4017493435186, -2.369794488014, -2.30769529142191,
-2.28289171086166, -2.24736457553032, -2.22224835097905, -2.21993628534018,
-2.21938775070459, -2.21330765240871, -2.1970203297687, -2.18405609540363,
-2.1707971627096, -2.16975015841871, -2.11020976431672, -1.75392661111203,
-1.73701872449349, -1.7094653013083, -1.68198644925752, -1.67745819232374,
-1.65515644561234, -1.57194744043552, -1.57116047214388, -1.51000042083035,
-1.50463279855355, -1.46346551065156, -1.44224216231154, -1.37311564470336,
-1.32779620730326, -1.32592791352896, -1.31204307149482, -1.27756472934721,
-1.23603794634302, -1.1702376900797, -1.16378397319292, -1.12499060545068,
-1.1088125112075, -0.939262072448041, -0.862163030101959, -0.858354175324213,
-0.654474645495292, -0.628257109630334, -0.606705081751156, -0.550295255225927,
-0.497332185765383, -0.482929007849059, -0.440957523688129, -0.360777543733516,
-0.305426972877309, -0.199639436822714, -0.108018704644053, 0.0346309488381769,
0.034746934017077, 0.0493559949320308, 0.192914632754347, 0.218667918037225,
0.245737147003821, 0.247527541956785, 0.333222558419853, 0.557256844844099,
0.669063496448389, 0.720955292473698, 0.767660102407662, 0.878291398784322,
0.946178076488395, 0.946467111772845, 1.11121506783806, 1.22835778244999,
1.24961769756564, 1.29790330264223, 1.30574614563616, 1.30823862002444,
1.35802473804966, 1.48779920673317, 1.6470804669896, 1.75657725379367,
1.91434060426954, 3.12793082392592, 4.05818631097523, 5.87762107232264,
7.87360999893622, 54.7844606150857), .Dim = c(389L, 1L))
Try:
e.divisive(diff(x), k = 1, min.size = 2)