如何在热图中插入轴

时间:2017-02-14 16:34:20

标签: r ggplot2 heatmap

我正在尝试使用ComplexHeatmap包创建热图图。我的表格包含以下内容

> str(X)
'data.frame':   513 obs. of  4 variables:
 $ Dist       : num  0 0.0122 0.0244 0.0366 0.0488 ...
 $ Prob_0 vs 0: num  NaN 0.238 0.53 0.712 0.802 ...
 $ Prob_4 vs 0: num  NaN 0.478 0.589 0.611 0.566 ...
 $ Prob_4 vs 4: num  NaN 1.38 1.47 1.55 1.63 ... 

第一列是估计每个后续变量的距离。我使用了ComplexHeatmap包,它运行得很漂亮,我转换数据(现在我使用的是rownames,因为它更容易)。但是我想在热图中使用实际距离值作为底部注释,但不是因为它们被呈现。我想添加一条连续线(如轴),显示距离的间隔(如0-10范围的值)。这可能吗?

以下是我使用的代码:

ft <- X[,-1] #removes the first line
Heatmap(t(ft), col = colorRamp2(c(-(max(abs(data.frame(t(ft))), na.rm = TRUE)), 0, max(abs(data.frame(t(ft))), na.rm = TRUE)),  
                                                             c("red", "white", "blue")),cluster_columns = FALSE,
        heatmap_legend_param = list(title = "Std. Coeff."))

解决方案不限于ComplexHeatmap包。我也会接受不同包装的解决方案。

编辑:

根据thisisrg的要求,我将添加表格的输入

X <- structure(list(Dist = c(0, 0.01220703125, 0.0244140625, 0.03662109375, 
0.048828125, 0.06103515625, 0.0732421875, 0.08544921875, 0.09765625, 
0.10986328125, 0.1220703125, 0.13427734375, 0.146484375, 0.15869140625, 
0.1708984375, 0.18310546875, 0.1953125, 0.20751953125, 0.2197265625, 
0.23193359375, 0.244140625, 0.25634765625, 0.2685546875, 0.28076171875, 
0.29296875, 0.30517578125, 0.3173828125, 0.32958984375, 0.341796875, 
0.35400390625, 0.3662109375, 0.37841796875, 0.390625, 0.40283203125, 
0.4150390625, 0.42724609375, 0.439453125, 0.45166015625, 0.4638671875, 
0.47607421875, 0.48828125, 0.50048828125, 0.5126953125, 0.52490234375, 
0.537109375, 0.54931640625, 0.5615234375, 0.57373046875, 0.5859375, 
0.59814453125, 0.6103515625, 0.62255859375, 0.634765625, 0.64697265625, 
0.6591796875, 0.67138671875, 0.68359375, 0.69580078125, 0.7080078125, 
0.72021484375, 0.732421875, 0.74462890625, 0.7568359375, 0.76904296875, 
0.78125, 0.79345703125, 0.8056640625, 0.81787109375, 0.830078125, 
0.84228515625, 0.8544921875, 0.86669921875, 0.87890625, 0.89111328125, 
0.9033203125, 0.91552734375, 0.927734375, 0.93994140625, 0.9521484375, 
0.96435546875, 0.9765625, 0.98876953125, 1.0009765625, 1.01318359375, 
1.025390625, 1.03759765625, 1.0498046875, 1.06201171875, 1.07421875, 
1.08642578125, 1.0986328125, 1.11083984375, 1.123046875, 1.13525390625, 
1.1474609375, 1.15966796875, 1.171875, 1.18408203125, 1.1962890625, 
1.20849609375, 1.220703125, 1.23291015625, 1.2451171875, 1.25732421875, 
1.26953125, 1.28173828125, 1.2939453125, 1.30615234375, 1.318359375, 
1.33056640625, 1.3427734375, 1.35498046875, 1.3671875, 1.37939453125, 
1.3916015625, 1.40380859375, 1.416015625, 1.42822265625, 1.4404296875, 
1.45263671875, 1.46484375, 1.47705078125, 1.4892578125, 1.50146484375, 
1.513671875, 1.52587890625, 1.5380859375, 1.55029296875, 1.5625, 
1.57470703125, 1.5869140625, 1.59912109375, 1.611328125, 1.62353515625, 
1.6357421875, 1.64794921875, 1.66015625, 1.67236328125, 1.6845703125, 
1.69677734375, 1.708984375, 1.72119140625, 1.7333984375, 1.74560546875, 
1.7578125, 1.77001953125, 1.7822265625, 1.79443359375, 1.806640625, 
1.81884765625, 1.8310546875, 1.84326171875, 1.85546875, 1.86767578125, 
1.8798828125, 1.89208984375, 1.904296875, 1.91650390625, 1.9287109375, 
1.94091796875, 1.953125, 1.96533203125, 1.9775390625, 1.98974609375, 
2.001953125, 2.01416015625, 2.0263671875, 2.03857421875, 2.05078125, 
2.06298828125, 2.0751953125, 2.08740234375, 2.099609375, 2.11181640625, 
2.1240234375, 2.13623046875, 2.1484375, 2.16064453125, 2.1728515625, 
2.18505859375, 2.197265625, 2.20947265625, 2.2216796875, 2.23388671875, 
2.24609375, 2.25830078125, 2.2705078125, 2.28271484375, 2.294921875, 
2.30712890625, 2.3193359375, 2.33154296875, 2.34375, 2.35595703125, 
2.3681640625, 2.38037109375, 2.392578125, 2.40478515625, 2.4169921875, 
2.42919921875, 2.44140625, 2.45361328125, 2.4658203125, 2.47802734375, 
2.490234375, 2.50244140625, 2.5146484375, 2.52685546875, 2.5390625, 
2.55126953125, 2.5634765625, 2.57568359375, 2.587890625, 2.60009765625, 
2.6123046875, 2.62451171875, 2.63671875, 2.64892578125, 2.6611328125, 
2.67333984375, 2.685546875, 2.69775390625, 2.7099609375, 2.72216796875, 
2.734375, 2.74658203125, 2.7587890625, 2.77099609375, 2.783203125, 
2.79541015625, 2.8076171875, 2.81982421875, 2.83203125, 2.84423828125, 
2.8564453125, 2.86865234375, 2.880859375, 2.89306640625, 2.9052734375, 
2.91748046875, 2.9296875, 2.94189453125, 2.9541015625, 2.96630859375, 
2.978515625, 2.99072265625, 3.0029296875, 3.01513671875, 3.02734375, 
3.03955078125, 3.0517578125, 3.06396484375, 3.076171875, 3.08837890625, 
3.1005859375, 3.11279296875, 3.125, 3.13720703125, 3.1494140625, 
3.16162109375, 3.173828125, 3.18603515625, 3.1982421875, 3.21044921875, 
3.22265625, 3.23486328125, 3.2470703125, 3.25927734375, 3.271484375, 
3.28369140625, 3.2958984375, 3.30810546875, 3.3203125, 3.33251953125, 
3.3447265625, 3.35693359375, 3.369140625, 3.38134765625, 3.3935546875, 
3.40576171875, 3.41796875, 3.43017578125, 3.4423828125, 3.45458984375, 
3.466796875, 3.47900390625, 3.4912109375, 3.50341796875, 3.515625, 
3.52783203125, 3.5400390625, 3.55224609375, 3.564453125, 3.57666015625, 
3.5888671875, 3.60107421875, 3.61328125, 3.62548828125, 3.6376953125, 
3.64990234375), `Prob_0 vs 0` = c(NaN, 0.237576420544701, 0.530243745611471, 
0.712131719708788, 0.802271955686006, 0.813756100443225, 0.9227537054007, 
1.13350585109593, 1.43349058067932, 1.78945709095286, 2.06095184683552, 
2.2273963944522, 2.360212814586, 2.49808638550077, 2.54474369482735, 
2.55292644989474, 2.62127842108026, 2.77283212106261, 2.96510939846837, 
3.13535124706203, 3.30213097411516, 3.37630464370054, 3.35222203455243, 
3.2714299353741, 3.33627708538652, 3.49176465027504, 3.5540603339226, 
3.75250787652294, 3.91827782842129, 4.0044070913819, 4.08976492047229, 
4.20375657992172, 4.31700924667487, 4.42566202147765, 4.44440076962983, 
4.56082436897128, 4.72557926865402, 4.8740331806815, 5.00441636073648, 
5.02062090967459, 4.96632870502554, 4.96772839556676, 5.07092080591646, 
5.2313643833741, 5.32685592803999, 5.41766215746194, 5.44441764167056, 
5.43606362140635, 5.411902474122, 5.51001879144363, 5.53935683201949, 
5.51328527571126, 5.43982875047105, 5.44962004122367, 5.4543599702636, 
5.33953065199409, 5.19967721754027, 5.08767333677512, 4.92863575797286, 
4.75434216240437, 4.69579038226983, 4.70307840733031, 4.57422895104066, 
4.4620642311161, 4.35307162836119, 4.32321117114019, 4.36581921785176, 
4.43898474437526, 4.51676237748074, 4.58619818971311, 4.58969256320526, 
4.73173779187246, 4.89265812606088, 4.99750494755418, 5.14412455064222, 
5.31250854543885, 5.49535711142462, 5.72337528501464, 5.9495580972485, 
6.15744565152309, 6.15928281609593, 6.13768803214605, 6.24658524021035, 
6.4473325589996, 6.62622074786493, 6.86699964962475, 7.01602432570131, 
7.04301998100178, 6.98735893391799, 6.94446513941456, 6.9753044467289, 
6.87969341833369, 6.7039510131255, 6.58267869135413, 6.44898283558379, 
6.24428619306375, 5.96897002113917, 5.68230081578111, 5.36787409068825, 
5.03580956233143, 4.73749750278834, 4.57596584593804, 4.47271878316157, 
4.30510167803549, 4.12027437262511, 4.01284715436542, 3.95817117397236, 
4.00326257852433, 4.07690344768176, 4.09407841463112, 4.12515581185398, 
4.24215809829794, 4.32809205688012, 4.34240005184899, 4.34123505839222, 
4.39807932705815, 4.38844664234205, 4.45061150792117, 4.65164012222767, 
4.87067077563656, 5.01419492945936, 5.02718999628037, 5.0129396678448, 
5.05513659196026, 5.13086135099235, 5.18029901993765, 5.28836584159578, 
5.31699535509692, 5.32601617300431, 5.34475147530333, 5.37158528502475, 
5.48173294865045, 5.48833224088715, 5.47175200270752, 5.56063321340602, 
5.58024801256755, 5.57279692717146, 5.57533414154514, 5.53351681792857, 
5.43705109320126, 5.42202080052863, 5.5023613647921, 5.58355856606389, 
5.5719210796375, 5.57229377578397, 5.53991450429585, 5.47968310754111, 
5.52274738577026, 5.57685355250361, 5.63214664455547, 5.65677893337438, 
5.73224889796731, 5.99936233861073, 6.24679969408281, 6.43985878262727, 
6.51972384327445, 6.49350318842942, 6.43018559707729, 6.42478898892372, 
6.506193188021, 6.62865926349153, 6.57360912592453, 6.42389326567735, 
6.28202145157725, 6.20632766414902, 6.09396911193412, 6.0226863932659, 
6.00625647490843, 5.91973889558252, 5.81238152369007, 5.77619193660644, 
5.64645119183251, 5.50151310999086, 5.35307557495697, 5.29900724815286, 
5.29600565877108, 5.35479867091857, 5.38204237079873, 5.35612345465627, 
5.19181892815486, 5.13619465603709, 5.20931643323833, 5.24579326821275, 
5.31493278463207, 5.35077079297442, 5.33075318977146, 5.259377420969, 
5.17409634087382, 5.351622602699, 5.51295858534917, 5.5882698087635, 
5.54832922756616, 5.56344896636778, 5.60192056575074, 5.5671784523359, 
5.48254022592186, 5.4894950757978, 5.37064029303164, 5.19069581395775, 
5.05079303599233, 4.92947445795189, 4.76883820732186, 4.57677894419868, 
4.34579136896423, 4.16545601241833, 3.99936103873175, 3.87868937704688, 
3.67712924824816, 3.46986190010122, 3.28027868099765, 3.1645778909222, 
3.08210624078864, 2.96943610874946, 2.83415082957585, 2.71295790918139, 
2.574872527898, 2.56130620876291, 2.63934245429256, 2.70847015054856, 
2.73065389222475, 2.66699979442995, 2.65668873380784, 2.74476180854439, 
2.76356764280366, 2.93087053849981, 3.06524245728706, 3.13595430936636, 
3.14862518021699, 3.17086661973146, 3.30729040097112, 3.40846072897391, 
3.4436398443871, 3.60484104144658, 3.8185230179118, 4.02072029592777, 
4.15814878283129, 4.25896516446361, 4.32471484146874, 4.32109756504036, 
4.27227278546762, 4.26607087553645, 4.18018265913158, 4.07315277006633, 
3.89162806524799, 3.71912098354144, 3.55955180643683, 3.37271915496058, 
3.19019410752165, 2.99466582188851, 2.77867675219537, 2.63794279062893, 
2.54812047113694, 2.4559485493108, 2.33786970668933, 2.23482818875559, 
2.15058001979509, 2.05386335667065, 2.00313636035246, 2.06068374289317, 
2.01137842596851, 1.8880880493917, 1.74441283310472, 1.68116868553537, 
1.60683006861109, 1.4935675136126, 1.54858112096455, 1.61989202309324, 
1.61860166577077, 1.64081500171071, 1.68829329024331, 1.7489812778711, 
1.79525477958204, 1.82242439448046, 1.99882914054592, 2.21050673908558, 
2.34190406817834, 2.42554046859403, 2.40003353632323, 2.3878314749601, 
2.41180766976115, 2.45348721202242, 2.55077591978968, 2.57223921674726, 
2.55142651225624, 2.50780720036314, 2.43688529960885, 2.44695847274735, 
2.53893568496856, 2.6022640809884, 2.67985683500395, 2.77833367204192, 
2.90600967282694, 2.99544085801814, 3.00031686100334, 3.01318649496748, 
3.04978626765603, 3.06199037701806, 3.1368326522569, 3.20699888665, 
3.24241891399719), `Prob_4 vs 0` = c(NaN, 0.477792133571875, 
0.588927152046119, 0.610721048165817, 0.565972160023058, 0.478172957982378, 
0.414480476524951, 0.404447721771221, 0.425196754380851, 0.435268339639429, 
0.398727128735965, 0.31207604280227, 0.228815034061013, 0.190514449735361, 
0.106673211890841, -0.00404426795890488, -0.083193938438331, 
-0.152226915372251, -0.198534089917443, -0.251659599169851, -0.314407820341815, 
-0.419199018672874, -0.569199261141938, -0.735714655512978, -0.783508526229381, 
-0.738894473918789, -0.721114475777898, -0.647795824485678, -0.607509076911712, 
-0.633429495705338, -0.696850191266574, -0.752207860889537, -0.82289700978424, 
-0.920858804332431, -1.05052495361504, -1.02736563842405, -0.945495864947358, 
-0.862755289687419, -0.756948944274033, -0.704286061742866, -0.690037133622123, 
-0.641068865624117, -0.553347027765726, -0.446016426289374, -0.380402040626425, 
-0.349665458681469, -0.371307540472583, -0.435289102695054, -0.500295831797303, 
-0.479226554755189, -0.481691953481598, -0.500986211055798, -0.540456620451864, 
-0.482228767467164, -0.397433052600045, -0.3753787416637, -0.400740328444308, 
-0.447130773237572, -0.525812700944285, -0.591623649569839, -0.567387836485351, 
-0.491645951408295, -0.493328128921377, -0.53774545244907, -0.594279173978339, 
-0.551993501794608, -0.471544256122073, -0.390599948048027, -0.318969233490778, 
-0.268100057367518, -0.25060632258581, -0.124988455842626, 0.0104063802352669, 
0.0837738678676931, 0.19689927843391, 0.370660068646712, 0.544229262005795, 
0.705507940820144, 0.843943647895285, 0.984421476967287, 1.01844260451862, 
1.02295363504543, 1.06329357009237, 1.17368224822219, 1.25933664737669, 
1.34792956690098, 1.39905126863037, 1.4332136059028, 1.47802460238819, 
1.61700102296192, 1.83791725220699, 1.994757260602, 2.08718478032481, 
2.15095386630809, 2.22423259447231, 2.29330324422517, 2.30808496115807, 
2.28586088375826, 2.20381278940513, 2.07403870517872, 1.95289948209375, 
1.89734292830151, 1.82262656717447, 1.69060893760042, 1.52454259323329, 
1.36335009873144, 1.19830296990912, 1.05079496076587, 0.924837245099042, 
0.742580400945877, 0.567570184791599, 0.504322564804986, 0.446754532599028, 
0.368144185253863, 0.274809602193992, 0.230249497407905, 0.12437137962986, 
0.0130875333324446, -0.0427333409482995, -0.0321883200089077, 
-0.068889922909012, -0.186363652178987, -0.312651903179775, -0.390818060212873, 
-0.454344467103993, -0.514428890914057, -0.522745542984893, -0.569137437369841, 
-0.619508967937939, -0.693714563277258, -0.712967498787624, -0.610745057818886, 
-0.559935546338996, -0.52721513821141, -0.437731128637054, -0.392356388421712, 
-0.356357778143342, -0.346307836806892, -0.348817593085204, -0.374117005445102, 
-0.408075684269023, -0.436735272598008, -0.493125504993966, -0.616380474540766, 
-0.700777671005841, -0.786477293237285, -0.89500044580524, -0.843039399395264, 
-0.713768003736369, -0.580170566745676, -0.483533262866157, -0.378596888254511, 
-0.232480444977859, -0.121315336959782, -0.00845188515323656, 
0.0793751647586257, 0.136185744134835, 0.15547746021849, 0.187010979776089, 
0.243827518426242, 0.305216479029943, 0.251168347165336, 0.147968430880456, 
0.122461763722924, 0.147662577017664, 0.123384966130929, 0.221630460158248, 
0.429588307730026, 0.595246738098493, 0.7149073000771, 0.824924818976334, 
0.86722269878929, 0.935667138481236, 0.977733491461596, 1.06057174686387, 
1.17501083568156, 1.24432404758934, 1.24443615182021, 1.16682967589736, 
0.988872571103608, 0.860191492548988, 0.760180409713832, 0.642139972961295, 
0.659162229659174, 0.66395200881135, 0.615386103469677, 0.480402267934889, 
0.285648535522419, 0.257750548737593, 0.248907103885739, 0.235547081202872, 
0.182893911032161, 0.130685882965059, 0.067027703531308, -0.0226515154872363, 
-0.148952153362413, -0.26967123664653, -0.44628175044009, -0.613498517490384, 
-0.679914627911155, -0.741755709217102, -0.827799186650666, -0.880945055431556, 
-0.906000337483702, -0.865134301519513, -0.842939541117545, -0.834565993997025, 
-0.860304286277763, -0.842223286995313, -0.830450832172453, -0.764049457051867, 
-0.688473331865812, -0.662751293527776, -0.639603846601932, -0.551798059188554, 
-0.415875322221927, -0.278953459693901, -0.154401453176449, -0.017539128064584, 
0.108056598247199, 0.145946666403759, 0.185959981708326, 0.23663781355132, 
0.22550853852847, 0.332682305269027, 0.415496309486489, 0.481579166901776, 
0.519116017612548, 0.520229873255494, 0.625792300345416, 0.732620897116329, 
0.751807783229535, 0.838573848476462, 0.995742145741838, 1.17755024838674, 
1.31727013462255, 1.44127383958416, 1.57150071739327, 1.69732239413941, 
1.88300080090357, 2.16329795581447, 2.36407437947783, 2.56972079940026, 
2.71810027626716, 2.83903031914215, 2.94500097360362, 3.02687667996369, 
3.07087631503565, 3.05677754584274, 3.02815113782413, 3.12532150004985, 
3.27268700954295, 3.35187907363343, 3.38515514584783, 3.44629293123952, 
3.50122373604648, 3.52925609277051, 3.57113297889877, 3.69850835887627, 
3.7466822567094, 3.69202566492508, 3.60770957514372, 3.56151984837457, 
3.45281558850282, 3.24713064838216, 3.12452046182277, 2.99927826563787, 
2.79751430410385, 2.6172880282587, 2.49156796756458, 2.41917097245111, 
2.29743008291031, 2.1606966112501, 2.14879514630136, 2.17737989404793, 
2.17316330421881, 2.12198425099147, 1.96163185780732, 1.86631180062758, 
1.80367216131764, 1.73234129251917, 1.70798156590154, 1.61885265041055, 
1.47939116411407, 1.29880114404848, 1.06501022195411, 0.863330872170816, 
0.677574063777555, 0.469446319890244, 0.244328885824219, 0.0345717924508068, 
-0.122582073365085, -0.238650937317652, -0.365714611891161, -0.411947600888338, 
-0.465668481543213, -0.54439843942999, -0.491700489819452, -0.3907749545788, 
-0.338233819617352), `Prob_4 vs 4` = c(NaN, 1.37780666307805, 
1.4725275886289, 1.55385873790092, 1.63299121997062, 1.71614370364268, 
1.8052996055504, 1.86511116456155, 1.89777645895477, 1.93775028434649, 
2.0436139763077, 2.1366139306554, 2.21308819976811, 2.31675900629849, 
2.41050991226295, 2.47832189442482, 2.5436737029822, 2.63229070363353, 
2.77037469591184, 2.92086084200672, 3.04969781131255, 3.19097370962398, 
3.33417670980401, 3.44764776637523, 3.53493630082226, 3.60318878729804, 
3.6630121689498, 3.74944823273155, 3.8320013507338, 3.90519976852509, 
3.95892802144771, 4.01096488808319, 4.05111480263065, 4.06950204043984, 
4.07079901729213, 4.05470409876546, 4.03379527735477, 4.01234852523016, 
3.99164672274924, 3.99681251948855, 3.99711425170286, 3.97448981850333, 
3.93876821852018, 3.90040241203455, 3.85378876254916, 3.80113112408473, 
3.74629316083519, 3.68129783790125, 3.5942238244781, 3.50963558131377, 
3.43964898614209, 3.39554301734087, 3.33681927153041, 3.27715540443891, 
3.21749194012147, 3.14104479409262, 3.05335858504992, 3.00530537869742, 
2.97901260622561, 2.93978523370788, 2.93365170885745, 2.96834117599315, 
2.99129045580257, 2.99268209211839, 2.97380635891734, 2.9422793762789, 
2.91914301589093, 2.90265015392611, 2.8937619102338, 2.89336979377124, 
2.88106888538723, 2.84987330216002, 2.80992646231958, 2.77229832074174, 
2.77281028915168, 2.76251421915151, 2.73477851080489, 2.71315162013501, 
2.68379879084725, 2.65829946257843, 2.6396977618408, 2.63098158976705, 
2.64535725585492, 2.688174273947, 2.74835888370192, 2.86159154081837, 
2.98249639817784, 3.08685004393822, 3.16931598436241, 3.21897237482787, 
3.25935113125491, 3.33887438803471, 3.45834369634728, 3.57478478426174, 
3.69017458464168, 3.79325830522796, 3.88908609947997, 3.99294048484392, 
4.07774724803085, 4.13809358434585, 4.18263889677732, 4.23539674176399, 
4.29338567713509, 4.36534029581382, 4.42676026052074, 4.46632398703805, 
4.47403485735211, 4.46594242653918, 4.45604123197776, 4.43994922230385, 
4.4231602294028, 4.38851052504888, 4.35000258394121, 4.29405601134326, 
4.23288652284307, 4.17459631010998, 4.13059887913383, 4.13631790386642, 
4.13292276067544, 4.11188323644998, 4.07793153625944, 4.04130531699981, 
4.00954760951172, 3.96024934114032, 3.92067959652055, 3.90838618903747, 
3.88098708228887, 3.8323913094154, 3.75785019474706, 3.65715807333941, 
3.54424489541011, 3.45110473223952, 3.36951966366798, 3.3163128403477, 
3.27985621920431, 3.24389621243461, 3.18906869541302, 3.12670019976798, 
3.08349212511208, 3.01121325588143, 2.91093747707495, 2.79530183502609, 
2.66611984383011, 2.54004564103154, 2.40579942678954, 2.26697150655179, 
2.12424828352976, 1.98082869623338, 1.84063485010153, 1.74471722775992, 
1.65782033568626, 1.5816552243751, 1.53075843734506, 1.48039371206381, 
1.42905797174249, 1.39630689767353, 1.4013915352715, 1.41278844411431, 
1.44594261069203, 1.47328275317087, 1.4991119092394, 1.54504852595795, 
1.58377106712873, 1.61478834976319, 1.64334022596303, 1.66872214880715, 
1.70021838466266, 1.7463521087072, 1.7908801750069, 1.82163068587928, 
1.83717734445056, 1.83437251181936, 1.82291928859751, 1.82184324820881, 
1.90510789955122, 1.98763754380599, 2.06237803058395, 2.11352324624535, 
2.15988826675703, 2.1955285299417, 2.22689177532639, 2.28308604699562, 
2.34267128604331, 2.38431900624195, 2.42812970502857, 2.46634901409718, 
2.50096184006983, 2.51416962005652, 2.5113095888583, 2.51551875082136, 
2.53036521026406, 2.5282393901726, 2.49344575061342, 2.42838042536251, 
2.35922424031949, 2.29334783814947, 2.2365964669389, 2.20045631743012, 
2.18634482191576, 2.18594065822349, 2.19586571268904, 2.21921226358382, 
2.24103586252682, 2.23944218277328, 2.2161577519493, 2.19184793119813, 
2.16714895525322, 2.13906636865961, 2.10498782017214, 2.05712347259895, 
2.00085820821056, 1.92616440983848, 1.83763052331116, 1.75951503423699, 
1.68495293075615, 1.63880203183006, 1.60911414535356, 1.59948859968256, 
1.64202022453628, 1.70412457458834, 1.77130716661865, 1.8341456254363, 
1.90031977703847, 1.96396768137055, 2.02365058058005, 2.0987293632452, 
2.16962870971253, 2.23373439452671, 2.31681482468529, 2.37139494619984, 
2.40472066972257, 2.46388554146483, 2.51999151144953, 2.56245740099444, 
2.59399808777485, 2.60851735555898, 2.61527369495308, 2.62088800199853, 
2.68300149065833, 2.75538021051776, 2.81231128943125, 2.84784269653891, 
2.87379739735238, 2.90718146921268, 2.94999625926136, 2.95982162881057, 
2.94618998109943, 2.91070664576965, 2.87721962086832, 2.84530299479219, 
2.79857591457344, 2.75399169675124, 2.69764692211061, 2.65484679879876, 
2.62058845345589, 2.58906707337837, 2.55590555849319, 2.50530104878225, 
2.46045451286688, 2.41969110530247, 2.37487788379151, 2.31736691124102, 
2.24392192999809, 2.17355283841108, 2.15211087335599, 2.16990550945958, 
2.18022998325559, 2.17713063787078, 2.15753060883505, 2.11772934175838, 
2.06447314643645, 2.02143611062015, 1.99845007350776, 1.9671439081047, 
1.90862858763493, 1.82201819297394, 1.73231466814849, 1.63966678266851, 
1.54046466867822, 1.44844209479308, 1.35660227846191, 1.28791896462259, 
1.25485909330113, 1.25042630062716, 1.24650272978085, 1.24544928905662, 
1.23281890434873, 1.21926675575615, 1.2178450454364, 1.23899023262545, 
1.26073514539275, 1.28741971393219, 1.34048451602406, 1.38819556311431, 
1.42622271944637, 1.46521605153005, 1.49961214116728, 1.54602418627472, 
1.60433230206472, 1.66487403899632)), .Names = c("Dist", "Prob_0 vs 0", 
"Prob_4 vs 0", "Prob_4 vs 4"), row.names = c(NA, 300L), class = "data.frame")

1 个答案:

答案 0 :(得分:0)

怎么样: 1)使用您的数据框;

SELECT
    severity,
    timestamp AS Time,
    protoPayload.host AS Host,
    protoPayload.status AS Status,
    protoPayload.resource AS Path,
    httpRequest.status,
    httpRequest.requestMethod,
    httpRequest.userAgent,
    httpRequest.remoteIp
FROM
    [MY_PROJECT:MYLOGS.appengine_googleapis_com_request_log_20170214]
WHERE
    httpRequest.requestMethod = 'GET'
LIMIT
    10

2)使用 m=as.matrix(df[,-1) 这有效吗?:

library(plotly)

enter image description here

使用ggplot2

p <- plot_ly( x = names(df[,-1]), y = df$Dist, z = m, type = "heatmap" ) 使用gather

tidyr

ggplot(需要努力使其漂亮):

df<-X %>% gather(var,val,`Prob_0 vs 0`:`Prob_4 vs 4`)