如何在这个ggplot中添加x轴下方的文本?

huangapple go评论70阅读模式
英文:

How to add the text under x-axis in this ggplot?

问题

我正在尝试在我的ggplot中添加一个x轴标签。我尝试了label在我的ggplot中,但它不起作用。可能是因为我已经使用了ggtitlescale_x_discrete。这是我的代码:

require(ggplot2)
require(ggrepel)
require(hrbrthemes)
require(tidyverse)
require(latticeExtra)

orders <- seq(0.50, 3, by = 0.01)

df <- structure(c(1.54137910425764, 2.10084622379172, 2.10473376216618, 
1.86545451317025, 2.03514908169308, 1.53513100398568, 2.09528925067253, 
2.09908844637651, 1.85867556361438, 2.02913317321576, 1.5289247020257, 
2.08974020107911, 2.09344381663128, 1.85198725172281, 2.02315831469781, 
1.52276204365728, 2.0842010197597, 2.08780206091594, 1.84538899526698, 
2.01722479782677, 1.51664470513004, 2.07867354097175, 2.08216526098196, 
1.83888005502821, 2.01133283287461, 1.51057420219207, 2.07315949253134, 
2.07653539536405, 1.83245955252801, 2.0054825568723, 1.50455189839532, 
2.06766049980719, 2.07091434241102, 1.82612648648521, 1.99967404111145, 
1.49857901316634, 2.06217808965208, 2.06530388332111, 1.81987974805715, 
1.99390729801856, 1.49265662963319, 2.05671369426529, 2.05970570517345, 
1.81371813492316, 1.9881822874458, 1.48678570220122, 2.05126865498072, 
2.05412140394803, 1.80764036426882, 1.98249892241983, 1.48096706387252, 
2.04584422597575, 2.04855248752714, 1.80164508472972, 1.97685707438801, 
1.47520143330546, 2.04044157789694, 2.04300037867186, 1.79573088735256, 
1.97125657799933, 1.46948942161227, 2.03506180139903, 2.03746641796785, 
1.78989631563045, 1.965697235455, 1.4638315388942, 2.0297059105946, 
2.03195186673511, 1.78413987466836, 1.96017882046189, 1.45822820051481, 
2.02437484641202, 2.02645790989718, 1.77846003953249, 1.95470108181965, 
1.45267973311309, 2.01906947986, 2.0209856588054, 1.77285526283629, 
1.94926374667066, 1.44718638035935, 2.01379061519758, 2.01553615401464, 
1.76732398161332, 1.94386652343992, 1.44174830845725, 2.00853899300857, 
2.01011036800727, 1.7618646235256, 1.93850910449013, 1.43636561139641, 
2.00331529318016, 2.0047092078624, 1.75647561245372, 1.93319116851574, 
1.43103831596061, 1.99812013778561, 1.99933351786813, 1.75115537351293, 
1.92791238269769, 1.42576638649693, 1.99295409387118, 1.99398408207466, 
1.74590233753728, 1.9226724046395

<details>
<summary>英文:</summary>

I am trying to add a label to my x-axis in my ggplot. I tried ```label``` in my ggplot but it doesn&#39;t work. Maybe due to the fact I have already used ```ggtitle``` and ```scale_x_discrete```. Here is my Code:

require(ggplot2)
require(ggrepel)
require(hrbrthemes)
require(tidyverse)
require(latticeExtra)

orders <- seq(0.50, 3, by = 0.01)

df <- structure(c(1.54137910425764, 2.10084622379172, 2.10473376216618,
1.86545451317025, 2.03514908169308, 1.53513100398568, 2.09528925067253,
2.09908844637651, 1.85867556361438, 2.02913317321576, 1.5289247020257,
2.08974020107911, 2.09344381663128, 1.85198725172281, 2.02315831469781,
1.52276204365728, 2.0842010197597, 2.08780206091594, 1.84538899526698,
2.01722479782677, 1.51664470513004, 2.07867354097175, 2.08216526098196,
1.83888005502821, 2.01133283287461, 1.51057420219207, 2.07315949253134,
2.07653539536405, 1.83245955252801, 2.0054825568723, 1.50455189839532,
2.06766049980719, 2.07091434241102, 1.82612648648521, 1.99967404111145,
1.49857901316634, 2.06217808965208, 2.06530388332111, 1.81987974805715,
1.99390729801856, 1.49265662963319, 2.05671369426529, 2.05970570517345,
1.81371813492316, 1.9881822874458, 1.48678570220122, 2.05126865498072,
2.05412140394803, 1.80764036426882, 1.98249892241983, 1.48096706387252,
2.04584422597575, 2.04855248752714, 1.80164508472972, 1.97685707438801,
1.47520143330546, 2.04044157789694, 2.04300037867186, 1.79573088735256,
1.97125657799933, 1.46948942161227, 2.03506180139903, 2.03746641796785,
1.78989631563045, 1.965697235455, 1.4638315388942, 2.0297059105946,
2.03195186673511, 1.78413987466836, 1.96017882046189, 1.45822820051481,
2.02437484641202, 2.02645790989718, 1.77846003953249, 1.95470108181965,
1.45267973311309, 2.01906947986, 2.0209856588054, 1.77285526283629,
1.94926374667066, 1.44718638035935, 2.01379061519758, 2.01553615401464,
1.76732398161332, 1.94386652343992, 1.44174830845725, 2.00853899300857,
2.01011036800727, 1.7618646235256, 1.93850910449013, 1.43636561139641,
2.00331529318016, 2.0047092078624, 1.75647561245372, 1.93319116851574,
1.43103831596061, 1.99812013778561, 1.99933351786813, 1.75115537351293,
1.92791238269769, 1.42576638649693, 1.99295409387118, 1.99398408207466,
1.74590233753728, 1.9226724046395, 1.42054972945196, 1.98781767614797,
1.98866162678654, 1.74071494507163, 1.91747088410337, 1.41538819768131,
1.98271134958939, 1.98336682299271, 1.73559164990931, 1.91230746456392,
1.41028159453903, 1.97763553193534, 1.97810028873324, 1.73053092221097,
1.90718178459581, 1.40522967775396, 1.97259059610435, 1.97286259140198,
1.72553125123808, 1.90209347911, 1.40023216309978, 1.9675768725151,
1.96765424998444, 1.72059114773281, 1.89704218045264, 1.39528872786621,
1.96259465131887, 1.96247573723079, 1.71570914597342, 1.89202751937921,
1.39039901413833, 1.95764418454469, 1.95732748176368, 1.7108838055333,
1.88704912591542, 1.38556263189147, 1.95272568815904, 1.95220987012107,
1.70611371276902, 1.88210663011596, 1.38077916190879, 1.94783934404195,
1.94712324873426, 1.70139748206182, 1.87719966273054, 1.3760481585288,
1.94298530188167, 1.94206792584172, 1.69673375683485, 1.87232785578649,
1.37136915223, 1.93816368098979, 1.93704417333898, 1.692121210367,
1.86749084309616, 1.36674165205958, 1.93337457203917, 1.93205222856568,
1.6875585464227, 1.86268826069645, 1.36216514791313, 1.9286180387267,
1.92709229603017, 1.68304449971569, 1.85791974722766, 1.35763911267227,
1.92389411936315, 1.92216454907297, 1.67857783622326, 1.85318494425772,
1.35316300420657, 1.91920282839236, 1.91726913146987, 1.67415735336642,
1.8484834965576, 1.34873626724649, 1.91454415784196, 1.91240615897574,
1.66978188006999, 1.84381505233307, 1.34435833513345, 1.90991807870785,
1.90757572081043, 1.66545027671582, 1.83917926341757, 1.34002863145322,
1.90532454227468, 1.90277788108773, 1.661161435001, 1.83457578543053,
1.33574657155849, 1.90076348137459, 1.8980126801888, 1.65691427771215,
1.83000427790485, 1.33151156398639, 1.89623481158622, 1.89328013608131,
1.65270775842576, 1.82546440438725, 1.32732301177643, 1.8917384323764,
1.88858024558573, 1.64854086114404, 1.82095583251458, 1.32318031369422,
1.8872742281864, 1.88391298558998, 1.64441259987444, 1.81647823406893,
1.31908286536601, 1.882842069465, 1.87927831421397, 1.64032201816079,
1.81203128501423, 1.31503006032908, 1.87844181365033, 1.87467617192536,
1.63626818857293, 1.80761466551655, 1.31102129100256, 1.87407330610261,
1.87010648260792, 1.63225021216127, 1.80322805995025, 1.30705594958337,
1.86973638098953, 1.86556915458402, 1.62826721788203, 1.79887115689189,
1.30313342887135, 1.86543086212651, 1.86106408159252, 1.62431836199843,
1.79454364910349, 1.29925312302803, 1.86115656377334, 1.85659114372348,
1.62040282746259, 1.79024523350671, 1.29541442827268, 1.85691329138935,
1.85215020831125, 1.61651982328231, 1.78597561114929, 1.29161674351961,
1.85270084234866, 1.84774113078703, 1.61266858387666, 1.78173448716491,
1.2878594709602, 1.84851900661731, 1.84336375549255, 1.60884836842383,
1.77752157072754, 1.28414201659317, 1.84436756739389, 1.83901791645607,
1.60505846020423, 1.77333657500125, 1.28046379070612, 1.84024630171536,
1.83470343813196, 1.60129816594168, 1.7691792170863, 1.27682420831175,
1.83615498102954, 1.83042013610537, 1.59756681514507, 1.76504921796214,
1.27322268954136, 1.83209337173577, 1.82616781776304, 1.59386375945271,
1.76094630242825, 1.26965865999861, 1.82806123569529, 1.82194628293173,
1.59018837198115, 1.75687019904298, 1.26613155107608, 1.82405833071259,
1.81775532448523, 1.58654004668031, 1.7528206400613, 1.26264080023715,
1.82008441098924, 1.81359472892142, 1.58291819769623, 1.74879736137153,
1.25918585126551, 1.81613922755141, 1.80946427691038, 1.57932225874277,
1.74480010243174, 1.25576615448459, 1.81222252865231, 1.80536374381467,
1.57575168248335, 1.74082860620588, 1.25238116694894, 1.80833406015084,
1.80129290018308, 1.57220593992356, 1.7368826191001, 1.24903035260958,
1.80447356586755, 1.79725151221867, 1.56868451981557, 1.73296189089939,
1.24571318245522, 1.80064078791903, 1.79323934222238, 1.56518692807489,
1.7290661747048, 1.24242913463098, 1.79683546703177, 1.78925614901304,
1.56171268720993, 1.72519522687141, 1.23917769453644, 1.79305734283658,
1.78530168832493, 1.55826133576502, 1.7213488069471, 1.23595835490449,
1.7893061541445, 1.78137571318375, 1.55483242777692, 1.71752667761241,
1.2327706158624, 1.78558163920511, 1.77747797426187, 1.55142553224532,
1.71372860462136, 1.2296139849766, 1.78188353594825, 1.77360822021398,
1.5480402326173, 1.70995435674351, 1.22648797728238, 1.77821158220983,
1.76976619799368, 1.54467612628596, 1.70620370570721, 1.22339211529974,
1.77456551594275, 1.76595165315219, 1.54133282410319, 1.70247642614409,
1.22032592903654, 1.77094507541355, 1.76216433011971, 1.53800994990657,
1.69877229553481, 1.21728895598005, 1.76734999938569, 1.75840397247034,
1.53470714006041, 1.69509109415615, 1.21428074107781, 1.76378002728998,
1.75467032317135, 1.53142404301062, 1.6914326050294, 1.21130083670878,
1.76023489938305, 1.75096312481736, 1.52816031885355, 1.68779661387006,
1.20834880264572, 1.7567143568944, 1.74728211985035, 1.52491563891831,
1.68418290903879, 1.20542420600946, 1.75321814216264, 1.74362705076593,
1.52168968536265, 1.68059128149377, 1.20252662121602, 1.74974599876157,
1.73999766030671, 1.51848215078193, 1.67702152474419, 1.19965562991704,
1.74629767161663, 1.7363936916433, 1.51529273783115, 1.67347343480511,
1.19681082093445, 1.74287290711223, 1.73281488854355, 1.51212115885955,
1.66994681015348, 1.19399179018982, 1.73947145319055, 1.72926099553057,
1.5089671355577, 1.6664414516854, 1.19119814062896, 1.73609305944225,
1.72573175803012, 1.50583039861666, 1.66295716267454, 1.18842948214241,
1.73273747718948, 1.72222692250795, 1.50271068739901, 1.65949374873168,
1.18568543148224, 1.72940445956176, 1.7187462365974, 1.49960774962136,
1.65605101776541, 1.18296561217563, 1.7260937615651, 1.71528944921799,
1.49652134104804, 1.65262877994387, 1.18026965443564, 1.7228051401447,
1.7118563106853, 1.49345122519574, 1.64922684765751, 1.17759719506957,
1.71953835424164, 1.7084465728126, 1.49039717304872, 1.64584503548297,
1.17494787738534, 1.716293164844, 1.70505998900473, 1.48735896278424,
1.64248316014781, 1.17232135109611, 1.71306933503262, 1.70169631434457,
1.48433637950802, 1.63914104049624, 1.16971727222349, 1.70986663002183,
1.6983553056725, 1.48132921499931, 1.63581849745581, 1.16713530299974,
1.70668481719565, 1.69503672165926, 1.47833726746528, 1.63251535400487,
1.164575111769, 1.70352366613945, 1.69174032287247, 1.4753603413045,
1.62923143514104, 1.162036372888, 1.70038294866755, 1.68846587183727,
1.47239824687911, 1.6259665678503, 1.15951876662637, 1.69726243884702,
1.68521313309135, 1.46945080029546, 1.62272058107705, 1.1570219790667,
1.69416191301778, 1.68198187323462, 1.46651782319295, 1.61949330569485,
1.15454570200474, 1.69108114980939, 1.67877186097393, 1.46359914254065,
1.61628457447787, 1.1520896328496, 1.68801993015461, 1.67558286716302,
1.4606945904416, 1.61309422207311, 1.14965347452443, 1.6849780373001,
1.67241466483802, 1.45780400394446, 1.60992208497323, 1.14723693536746,
1.68195525681433, 1.66926702924877, 1.45492722486211, 1.60676800149011,
1.14483972903368, 1.67895137659287, 1.66613973788611, 1.45206409959724,
1.603631811729, 1.14246157439719, 1.67596618686136, 1.66303257050554,
1.44921447897435, 1.60051335756325, 1.1401021954544, 1.67299948017622,
1.65994530914728, 1.44637821807818, 1.59741248260969, 1.13776132122808,
1.67005105142331, 1.65687773815306, 1.44355517609815, 1.5943290322045,
1.13543868567242, 1.66712069781464, 1.65382964417986, 1.44074521617878,
1.59126285337972, 1.13313402757914, 1.66420821888332, 1.65080081621064,
1.4379482052756, 1.58821379484018, 1.13084709048469, 1.66131341647685,
1.64779104556242, 1.43516401401664, 1.58518170694099, 1.12857762257868,
1.65843609474889, 1.64480012589182, 1.43239251656905, 1.58216644166554,
1.12632537661348, 1.65557606014962, 1.64182785319807, 1.42963359051079,
1.5791678526039, 1.12409010981512, 1.65273312141477, 1.638874025824,
1.42688711670713, 1.57618579493172, 1.12187158379545, 1.64990708955349,
1.63593844445469, 1.42415297919183, 1.57322012538959, 1.11966956446571,
1.64709777783514, 1.63302091211439, 1.42143106505279, 1.57027070226275,
1.11748382195137, 1.64430500177498, 1.63012123416147, 1.41872126432192,
1.5673373853613, 1.11531413050845, 1.64152857911905, 1.62723921828174,
1.41602346986927, 1.5644200360007, 1.11316026844112, 1.63876832982812,
1.62437467448019, 1.41333757730104, 1.56151851698274, 1.11102201802086,
1.63602407606094, 1.62152741507125, 1.41066348486143, 1.55863269257685,
1.10889916540685, 1.63329564215675, 1.61869725466771, 1.40800109333814,
1.55576242850174, 1.10679150056798, 1.63058285461721, 1.61588401016836,
1.40535030597146, 1.55290759190744, 1.10469881720615, 1.6278855420877,
1.61308750074452, 1.40271102836667, 1.55006805135761, 1.10262091268107,
1.6252035353382, 1.61030754782547, 1.40008316840977, 1.54724367681221,
1.10055758793641, 1.62253666724364, 1.60754397508285, 1.39746663618623,
1.54443433961051, 1.09850864742747, 1.6198847727639, 1.60479660841428,
1.3948613439029, 1.54163991245434, 1.09647389905016, 1.61724768892346,
1.60206527592601, 1.39226720581267, 1.53886026939169, 1.09445315407145,
1.61462525479073, 1.59934980791496, 1.389684138142, 1.53609528580057,
1.0924462270612, 1.61201731145711, 1.59665003684992, 1.38711205902104,
1.53334483837314, 1.09045293582528, 1.60942370201587, 1.59396579735229,
1.38455088841643, 1.53060880510013, 1.08847310134024, 1.60684427154078,
1.59129692617612, 1.38200054806642, 1.52788706525554, 1.08650654768909,
1.60427886706466, 1.58864326218776, 1.37946096141849, 1.52517949938152,
1.08455310199863, 1.60172733755775, 1.58600464634494, 1.37693205356917,
1.52248598927358, 1.08261259437795, 1.59918953390602, 1.5833809216756,
1.3744137512061, 1.51980641796597, 1.0806848578583, 1.59666530888943,
1.58077193325622, 1.37190598255213, 1.51714066971738, 1.07876972833419,
1.59415451716014, 1.57817752818992, 1.36940867731153, 1.51448862999675,
1.07686704450578, 1.59165701522065, 1.57559755558434, 1.36692176661807,
1.51185018546942, 1.07497664782251, 1.5891726614021, 1.57303186652914,
1.36444518298503, 1.50922522398339, 1.07309838242792, 1.58670131584243,
1.57048031407352, 1.36197886025699, 1.50661363455587, 1.0712320951057,
1.58424284046468, 1.56794275320337, 1.35952273356333, 1.50401530736,
1.06937763522686, 1.58179709895538, 1.56541904081849, 1.35707673927344,
1.50143013371172, 1.06753485469817, 1.57936395674293, 1.56290903570959,
1.35464081495347, 1.49885800605696, 1.06570360791157, 1.57694328097617,
1.56041259853527, 1.35221489932474, 1.49629881795886, 1.06388375169482,
1.57453494050301, 1.55792959179897, 1.34979893222348, 1.49375246408529,
1.06207514526323, 1.57213880584919, 1.5554598798259, 1.34739285456212,
1.4912188401965, 1.06027765017236, 1.56975474919719, 1.55300332874,
1.34499660829192, 1.48869784313294, 1.05849113027188, 1.56738264436527,
1.55055980644088, 1.34261013636691, 1.48618937080329, 1.05671545166042,
1.56502236678666, 1.54812918258087, 1.34023338270911, 1.48369332217258,
1.05495048264136, 1.56267379348895, 1.54571132854213, 1.33786629217498,
1.48120959725054, 1.05319609367975, 1.56033680307361, 1.54330611741382,
1.33550881052309, 1.47873809708011, 1.05145215735999, 1.55801127569568,
1.54091342396937, 1.33316088438287, 1.476278723726, 1.04971854834465,
1.55569709304369, 1.53853312464395, 1.33082246122449, 1.47383138026355,
1.04799514333411, 1.55339413831976, 1.53616509751194, 1.3284934893298,
1.47139597076761, 1.04628182102708, 1.55110229621984, 1.53380922226468,
1.32617391776429, 1.46897240030163, 1.04457846208205, 1.5488214529142,
1.53146538018826, 1.32386369635001, 1.4665605749069, 1.04288494907962,
1.54655149602812, 1.52913345414157, 1.32156277563948, 1.46416040159181,
1.04120116648559, 1.54429231462279, 1.52681332853446, 1.31927110689048,
1.46177178832143, 1.03952700061497, 1.54204379917636, 1.52450488930611,
1.31698864204172, 1.45939464400704, 1.03786233959669, 1.53980584156529,
1.5222080239036, 1.31471533368939, 1.45702887849592, 1.03620707333919,
1.53757833504584, 1.51992262126067, 1.31245113506449, 1.45467440256117,
1.03456109349673, 1.53536117423582, 1.5176485717767, 1.31019600001101,
1.45233112789169, 1.03292429343644, 1.53315425509652, 1.51538576729584,
1.30794988296479, 1.4499989670823, 1.03129656820611, 1.5309574749149,
1.51313410108648, 1.3057127389332, 1.44767783362393, 1.02967781450273,
1.52877073228593, 1.5108934678208, 1.30348452347544, 1.44536764189396,
1.02806793064167, 1.52659392709523, 1.50866376355465, 1.30126519268367,
1.44306830714664, 1.02646681652657, 1.52442696050186, 1.50644488570762,
1.29905470316462, 1.44077974550365, 1.02487437361986, 1.52226973492137,
1.50423673304332, 1.29685301202198, 1.43850187394473, 1.02329050491404,
1.52012215400902, 1.50203920564996, 1.29466007683934, 1.43623461029845,
1.02171511490341, 1.51798412264327, 1.49985220492106, 1.29247585566379,
1.43397787323307, 1.02014810955657, 1.51585554690944, 1.49767563353654,
1.29030030698997, 1.43173158224747, 1.01858939628948, 1.51373633408363,
1.49550939544391, 1.28813338974484, 1.42949565766222, 1.01703888393903,
1.51162639261679, 1.49335339583979, 1.28597506327286, 1.42727002061073,
1.01549648273732, 1.50952563211905, 1.49120754115163, 1.28382528732177,
1.42505459303048, 1.01396210428638, 1.50743396334424, 1.4890717390197,
1.2816840220288, 1.42284929765437, 1.01243566153352, 1.50535129817466,
1.48694589827929, 1.27955122790743, 1.42065405800214, 1.01091706874712,
1.50327754960594, 1.48482992894318, 1.27742686583459, 1.41846879837186,
1.00940624149305, 1.50121263173227, 1.48272374218431, 1.27531089703835,
1.41629344383157, 1.00790309661151, 1.49915645973169, 1.48062725031876,
1.27320328308593, 1.41412792021093, 1.00640755219439, 1.49710894985166,
1.47854036678889, 1.27110398587232, 1.41197215409303, 1.00491952756312,
1.4950700193948, 1.47646300614677, 1.26901296760916, 1.4098260728062,
1.003438943247, 1.49303958670481, 1.47439508403783, 1.26693019081405,
1.40768960441596, 1.00196572096195, 1.49101757115266, 1.47233651718473,
1.26485561830031, 1.40556267771707, 1.00049978358975, 1.48900389312287,
1.47028722337149, 1.26278921316703, 1.40344522222557, 0.999041055157682,
1.48699847400002, 1.46824712142786, 1.26073093878952, 1.40133716817096,
0.997589460818623, 1.4850012361555, 1.46621613121388, 1.25868075881011,
1.39923844648849, 0.996144926831535, 1.48301210293437, 1.46419417360467,
1.25663863712924, 1.39714898881142, 0.994707380542371, 1.48103099864242,
1.4621811704755, 1.25460453789693, 1.39506872746348, 0.993276750365371,
1.47905784853346, 1.46017704468706, 1.25257842550457, 1.39299759545128,
0.991852965764744, 1.4770925787967, 1.45818172007087, 1.25056026457694,
1.39093552645689, 0.990435957236729, 1.47513511654441, 1.45619512141507,
1.2485500199646, 1.38888245483043, 0.989025656292018, 1.47318538979966,
1.45421717445026, 1.24654765673654, 1.38683831558276, 0.987621995438539,
1.47124332748428, 1.45224780583569, 1.24455314017307, 1.38480304437824,
0.986224908164587, 1.46930885940698, 1.45028694314555, 1.24256643575905,
1.38277657752753, 0.9848343289223, 1.46738191625163, 1.44833451485558,
1.24058750917733, 1.3807588519805, 0.983450193111463, 1.46546242956571,
1.44639045032975, 1.23861632630241, 1.37874980531913, 0.982072437063633,
1.46355033174892, 1.44445467980732, 1.23665285319443, 1.37674937575062,
0.980700998026591, 1.46164555604193, 1.44252713438993, 1.23469705609332,
1.37475750210037, 0.979335814149093, 1.45974803651533, 1.44060774602898,
1.23274890141317, 1.3727741238052, 0.977976824465926, 1.45785770805867,
1.43869644751321, 1.23080835573693, 1.37079918090654, 0.97662396888326,
1.45597450636972, 1.43679317245643, 1.22887538581113, 1.36883261404369,
0.975277188164281, 1.45409836794386, 1.43489785528548, 1.22694995854103,
1.36687436444717, 0.973936423915116, 1.45222923006354, 1.43301043122835,
1.22503204098576, 1.36492437393212, 0.972601618571015, 1.45036703078801,
1.43113083630249, 1.22312160035382, 1.36298258489173, 0.971272715382815,
1.44851170894312, 1.42925900730332, 1.22121860399863, 1.36104894029082,
0.969949658403656, 1.44666320411125, 1.42739488179291, 1.21932301941438,
1.35912338365934, 0.968632392475956, 1.44482145662143, 1.42553839808884,
1.21743481423197, 1.35720585908606, 0.967320863218632, 1.44298640753954,
1.4236894952532, 1.21555395621513, 1.35529631121227, 0.966015017014561,
1.44115799865868, 1.42184811308182, 1.21368041325677, 1.3533946852255,
0.964714800998288, 1.43933617248967, 1.42001419209363, 1.21181415337537,
1.35150092685336, 0.963420163043953, 1.43752087225166, 1.41818767352021,
1.20995514471164, 1.34961498235739, 0.962131051753451, 1.43571204186288,
1.41636849929546, 1.20810335552528, 1.347736798527, 0.960847416444815,
1.43390962593152, 1.41455661204549, 1.20625875419185, 1.34586632267346,
0.959569207140805, 1.43211356974673, 1.41275195507863, 1.20442130919982,
1.34400350262393, 0.958296374557721, 1.43032381926974, 1.4109544723756,
1.20259098914775, 1.34214828671553, 0.957028870094409, 1.42854032112507,
1.40916410857985, 1.20076776274158, 1.34030062378955, 0.955766645821476,
1.42676302259194, 1.40738080898802, 1.19895159879208, 1.33846046318558,
0.9545096544707, 1.4249918715957, 1.40560451954059, 1.19714246621237,
1.33662775473583, 0.953257849424631, 1.42322681669945, 1.40383518681265,
1.1953403340156, 1.33480244875942, 0.95201118470638, 1.42146780709569,
1.40207275800479, 1.19354517131273, 1.33298449605674, 0.95076961496959,
1.41971479259819, 1.40031718093422, 1.1917569473104, 1.33117384790388,
0.949533095488592, 1.41796772363388, 1.39856840402588, 1.18997563130894,
1.32937045604709, 0.948301582148728, 1.41622655123485, 1.39682637630385,
1.18820119270046, 1.32757427269732, 0.947075031436853, 1.41449122703053,
1.39509104738279, 1.18643360096704, 1.32578525052481, 0.945853400431998,
1.41276170323991, 1.39336236745953, 1.18467282567901, 1.32400334265367,
0.944636646796205, 1.41103793266384, 1.39164028730479, 1.18291883649335,
1.32222850265664, 0.943424728765511, 1.40931986867753, 1.38992475825507,
1.18117160315213, 1.32046068454973, 0.942217605141101, 1.40760746522302,
1.38821573220463, 1.1794310954811, 1.31869984278708, 0.941015235280607,
1.40590067680188, 1.38651316159753, 1.1776972833883, 1.31694593225578,
0.939817579089556, 1.40419945846788, 1.38481699941995, 1.17597013686277,
1.31519890827072, 0.938624597012972, 1.40250376581985, 1.38312719919245,
1.17424962597339, 1.31345872656955, 0.937436250027113, 1.40081355499458,
1.3814437149625, 1.17253572086768, 1.3117253433077, 0.936252499631354,
1.39912878265985, 1.37976650129699, 1.17082839177081, 1.30999871505334,
0.935073307840207, 1.3974494060075, 1.37809551327497, 1.16912760898454,
1.30827879878255, 0.933898637175475, 1.39577538274663, 1.37643070648044,
1.16743334288635, 1.30656555187438, 0.932728450658535, 1.3941066710969,
1.37477203699522, 1.16574556392856, 1.30485893210608, 0.931562711802754,
1.39244322978182, 1.37311946139202, 1.16406424263753, 1.30315889764833,
0.930401384606031, 1.39078501802228, 1.37147293672752, 1.1623893496129,
1.3014654070605, 0.929244433543461, 1.38913199553003, 1.36983242053562,
1.16072085552696, 1.299778419286, 0.928091823560119, 1.38748412250129,
1.36819787082074, 1.15905873112398, 1.29809789364762, 0.926943520063967,
1.38584135961045, 1.36656924605128, 1.15740294721963, 1.29642378984302,
0.925799488918871, 1.38420366800388, 1.36494650515312, 1.1557534747005,
1.29475606794014, 0.924659696437739, 1.3825710092937, 1.36332960750323,
1.1541102845236, 1.29309468837276, 0.923524109375764, 1.38094334555179,
1.36171851292342, 1.15247334771593, 1.29143961193603, 0.922392694923784,
1.37932063930372, 1.36011318167413, 1.15084263537411, 1.28979079978212,
0.921265420701735, 1.37770285352291, 1.35851357444833, 1.14921811866403,
1.28814821341586, 0.920142254752228, 1.37608995162472, 1.35691965236551,
1.14759976882058, 1.28651181469044, 0.919023165534215, 1.37448189746069,
1.35533137696578, 1.14598755714735, 1.28488156580319, 0.917908121916758,
1.37287865531286, 1.35374871020399, 1.14438145501648, 1.28325742929133,
0.916797093172902, 1.37128018988813, 1.35217161444404, 1.14278143386839,
1.28163936802786, 0.915690048973641, 1.3696864663127, 1.35060005245318,
1.14118746521174, 1.28002734521742, 0.914586959381977, 1.36809745012657,
1.34903398739645, 1.13959952062323, 1.27842132439223, 0.913487794847081,
1.36651310727812, 1.34747338283118, 1.13801757174757, 1.27682126940808,
0.912392526198532, 1.36493340411878, 1.34591820270153, 1.1364415902974,
1.27522714444033, 0.911301124640661, 1.36335830739771, 1.34436841133322,
1.13487154805333, 1.27363891397999, 0.910213561746968, 1.36178778425658,
1.34282397342822, 1.13330741686387, 1.27205654282983, 0.909129809454639,
1.36022180222443, 1.34128485405958, 1.13174916864554, 1.27047999610051
), dim = c(5L, 251L), dimnames = list(c("binom_0.1", "binom_0.4",
"binom_0.6", "binom_0.2", "binom_0.3"), c("0.5", "0.51", "0.52",
"0.53", "0.54", "0.55", "0.56", "0.57", "0.58", "0.59", "0.6",
"0.61", "0.62", "0.63", "0.64", "0.65", "0.66", "0.67", "0.68",
"0.69", "0.7", "0.71", "0.72", "0.73", "0.74", "0.75", "0.76",
"0.77", "0.78", "0.79", "0.8", "0.81", "0.82", "0.83", "0.84",
"0.85", "0.86", "0.87", "0.88", "0.89", "0.9", "0.91", "0.92",
"0.93", "0.94", "0.95", "0.96", "0.97", "0.98", "0.99", "1",
"1.01", "1.02", "1.03", "1.04", "1.05", "1.06", "1.07", "1.08",
"1.09", "1.1", "1.11", "1.12", "1.13", "1.14", "1.15", "1.16",
"1.17", "1.18", "1.19", "1.2", "1.21", "1.22", "1.23", "1.24",
"1.25", "1.26", "1.27", "1.28", "1.29", "1.3", "1.31", "1.32",
"1.33", "1.34", "1.35", "1.36", "1.37", "1.38", "1.39", "1.4",
"1.41", "1.42", "1.43", "1.44", "1.45", "1.46", "1.47", "1.48",
"1.49", "1.5", "1.51", "1.52", "1.53", "1.54", "1.55", "1.56",
"1.57", "1.58", "1.59", "1.6", "1.61", "1.62", "1.63", "1.64",
"1.65", "1.66", "1.67", "1.68", "1.69", "1.7", "1.71", "1.72",
"1.73", "1.74", "1.75", "1.76", "1.77", "1.78", "1.79", "1.8",
"1.81", "1.82", "1.83", "1.84", "1.85", "1.86", "1.87", "1.88",
"1.89", "1.9", "1.91", "1.92", "1.93", "1.94", "1.95", "1.96",
"1.97", "1.98", "1.99", "2", "2.01", "2.02", "2.03", "2.04",
"2.05", "2.06", "2.07", "2.08", "2.09", "2.1", "2.11", "2.12",
"2.13", "2.14", "2.15", "2.16", "2.17", "2.18", "2.19", "2.2",
"2.21", "2.22", "2.23", "2.24", "2.25", "2.26", "2.27", "2.28",
"2.29", "2.3", "2.31", "2.32", "2.33", "2.34", "2.35", "2.36",
"2.37", "2.38", "2.39", "2.4", "2.41", "2.42", "2.43", "2.44",
"2.45", "2.46", "2.47", "2.48", "2.49", "2.5", "2.51", "2.52",
"2.53", "2.54", "2.55", "2.56", "2.57", "2.58", "2.59", "2.6",
"2.61", "2.62", "2.63", "2.64", "2.65", "2.66", "2.67", "2.68",
"2.69", "2.7", "2.71", "2.72", "2.73", "2.74", "2.75", "2.76",
"2.77", "2.78", "2.79", "2.8", "2.81", "2.82", "2.83", "2.84",
"2.85", "2.86", "2.87", "2.88", "2.89", "2.9", "2.91", "2.92",
"2.93", "2.94", "2.95", "2.96", "2.97", "2.98", "2.99", "3")))

as.data.frame(df) |>
rownames_to_column() |>
pivot_longer(-rowname) |>
mutate(rowname = factor(rowname, rownames(df))) |>
ggplot(aes(factor(name, unique(name)), rowname, fill = value)) +
ggtitle(title) +
scale_x_discrete(labels = ~., breaks = ~ round(min(orders) + (diff(range(orders))/11)*(0.5:10.5), 2)) + theme(plot.title = element_text(hjust = 0.5, size = 25), text = element_text(size=25)) +
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))


Here is the plot:
[![How to add text under x-axis label values?][1]][1]
How can I add the text &quot;Orders&quot; under the x-axis labeled values, in the middle, approximately below the 1.75?
[1]: https://i.stack.imgur.com/oF65f.png
</details>
# 答案1
**得分**: 2
这与评论一致,但考虑到我已经处理过了,所以我会发帖出来:
```R
as.data.frame(df) |&gt;
rownames_to_column() |&gt;
pivot_longer(-rowname) |&gt;
mutate(rowname = factor(rowname, rownames(df)))  |&gt;
ggplot(aes(factor(name, unique(name)), rowname, fill = value)) + 
ggtitle("热力图") +
scale_x_discrete(labels = ~., breaks = ~ round(min(orders) + 
(diff(range(orders))/11)*(0.5:10.5), 2)) + 
theme(plot.title = element_text(hjust = 0.5, size = 25), 
text = element_text(size=25)) + 
geom_tile() +
scale_fill_gradientn(colours = c("blue4", "white", "red3")) +
scale_y_discrete(position = "right") +
xlab("订单") + 
theme(legend.position = "none", 
axis.ticks = element_blank(),
axis.title.y = element_blank(),
text = element_text(face = 2))

如何在这个ggplot中添加x轴下方的文本?

英文:

This is consistent with the comments, but thought I'd post it since I had already worked it up:

as.data.frame(df) |&gt;
rownames_to_column() |&gt;
pivot_longer(-rowname) |&gt;
mutate(rowname = factor(rowname, rownames(df)))  |&gt;
ggplot(aes(factor(name, unique(name)), rowname, fill = value)) + 
ggtitle(&quot;HeatMap&quot;) +
scale_x_discrete(labels = ~., breaks = ~ round(min(orders) + 
(diff(range(orders))/11)*(0.5:10.5), 2)) + 
theme(plot.title = element_text(hjust = 0.5, size = 25), 
text = element_text(size=25)) + 
geom_tile() +
scale_fill_gradientn(colours = c(&quot;blue4&quot;, &quot;white&quot;, &quot;red3&quot;)) +
scale_y_discrete(position = &quot;right&quot;) +
xlab(&quot;Orders&quot;) + 
theme(legend.position = &quot;none&quot;, 
axis.ticks = element_blank(),
axis.title.y = element_blank(),
text = element_text(face = 2))

如何在这个ggplot中添加x轴下方的文本?

huangapple
  • 本文由 发表于 2023年5月25日 03:03:30
  • 转载请务必保留本文链接:https://go.coder-hub.com/76326678.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定