r - 从 bayesplot R 包更改 mcmc_areas() 图中的 y 轴文本

标签 r ggplot2 data-visualization stan

我在更改 mcmc_areas 函数生成的图形中的 y 轴值时遇到了一些麻烦。我的目标是更改文本并更新 y 轴值以包括希腊语下标字母。在可以使用 R 中的 bayesplot 包创建的其他图形中,我可以很容易地做到这一点。

例如:

#I pull out my posterior draws
posterior<-as.matrix(fit.lv2)

#I grab just the parameters of interest for the moment
gamma.b0<-posterior[,c('gamma[1,1]',
                       'gamma[1,2]',
                       'gamma[1,3]',
                       'gamma[1,4]')]

#I rename the columns 
colnames(gamma.b0)<-c('Intercept~(gamma[0][0])',
                      'DN~(gamma[0][1])',
                      'Pos~Events~(gamma[0][2])', 
                      'Neg~Events~(gamma[0][4])')

#And finally I plot the posterior density for each parameter of interest
b0.g1<-mcmc_dens(gamma.b0, facet_args = list(labeller=ggplot2::label_parsed))

它产生:

enter image description here

到现在为止还挺好。但是我无法弄清楚如何使用 mcmc_areas() 函数使绘图重现相同的文本。我已经尝试过 yaxis_textyaxis_ticks ,这两个似乎都不是我想要更新 y 轴上的值的方式。我要么收到警告,要么收到列名完全复制的 mcmc_areas 图的某个版本(这与我想要的审美相去甚远):

enter image description here

任何想法或建议都非常感谢。

数据如下:
structure(c(0.271109294696503, 0.267826231211207, 0.276818479035676, 
0.264567088328544, 0.263318490852988, 0.244328414463077, 0.261401603509913, 
0.31998604457435, 0.297972361965154, 0.307242311884835, 0.289448742194069, 
0.289478523521796, 0.280506176470295, 0.283732773311205, 0.283542642259331, 
0.28751022425982, 0.309919796699706, 0.301688008706922, 0.284887521748371, 
0.272273473449619, 0.301496194738251, 0.305855974380777, 0.32966407600527, 
0.325692578632648, 0.32496777821901, 0.30677438742436, 0.325759689643361, 
0.316510607286926, 0.314584644788873, 0.278859936533532, 0.27112245984675, 
0.263211395625464, 0.279820781650672, 0.275629866850165, 0.283052804371872, 
0.302376295355857, 0.281533519273034, 0.286741433069106, 0.302147758236136, 
0.303226818844686, 0.279380949512308, 0.287837720083551, 0.280723258479773, 
0.281707336927169, 0.28538828769749, 0.289909495002207, 0.290495330506002, 
0.291562160290579, 0.262421717916298, 0.277407483335038, 0.291226361365008, 
0.289026239091985, 0.292704670127705, 0.297237797518275, 0.297680331405638, 
0.321832635638788, 0.313667124077643, 0.310722033441304, 0.312921160443473, 
0.300848378284091, 0.279632556345866, 0.275354841364652, 0.257028576988156, 
0.290367302689463, 0.285420506469868, 0.286548346514888, 0.285633793186379, 
0.303185513364717, 0.304978726093145, 0.301256742214926, 0.29768444039327, 
0.280551969819775, 0.28139468405782, 0.276034047667092, 0.272437507921596, 
0.280093266131369, 0.264375705366393, 0.283568614241949, 0.291276782033727, 
0.29922820046716, 0.288457889878093, 0.281567912874447, 0.306132198508674, 
0.293051583677747, 0.30804412135885, 0.286058058024959, 0.298658544423635, 
0.303123756923253, 0.296026386395089, 0.301948410544605, 0.303389388539046, 
0.2515244515422, 0.25751713000544, 0.256080957074386, 0.264264945316572, 
0.252308294429816, 0.27878637736137, 0.262069621407748, 0.297474337295177, 
0.29107902289293, 0.310635503838107, 0.312470043823321, 0.31062735355912, 
0.31159745680159, 0.277191616101696, 0.267206015695863, 0.260469219168423, 
0.285872627358975, 0.279703353492286, 0.27315573277275, 0.279636541383599, 
0.272208086788542, 0.281592331095237, 0.248316984997536, 0.256727666759716, 
0.291556414854853, 0.292055253470273, 0.289025449902626, 0.294726895163952, 
0.300242265853135, 0.293207806215382, 0.295918561900926, 0.305613368856382, 
0.29787623667386, 0.30300961790576, 0.291666593909164, 0.277471909195375, 
0.280597140423469, 0.299006434050922, 0.303379394010607, 0.307634175416726, 
0.298382885802435, 0.295427697074958, 0.294745500132756, 0.289942543763291, 
0.294703037578946, 0.3102597384204, 0.329752997445571, 0.30058224909225, 
0.296135106392872, 0.29715725672601, 0.340111274283522, 0.31653057764101, 
0.311609590800635, 0.310007972297689, 0.312940652953799, 0.308066535935202, 
0.309721739801133, 0.315226078292485, 0.319691820732328, 0.307763409376689, 
0.324850795470424, 0.296910131610694, 0.275716713073134, 0.277785500333236, 
0.28005641397621, 0.285539794745009, 0.277298371067622, 0.283287308591866, 
0.271914532975245, 0.282837586726604, 0.26998402341113, 0.274048335038126, 
0.278676180085379, 0.280651941506042, 0.277538989328217, 0.273255805841492, 
0.278625796493812, 0.278949902232157, 0.267785766575337, 0.260981198954307, 
0.262198771211714, 0.256572557511804, 0.268299041248781, 0.268527156178666, 
0.267041545759954, 0.278316600200361, 0.290728285728766, 0.273069846690404, 
0.29490004883551, 0.27591348730031, 0.25842657256169, 0.261836834738016, 
0.255357821272979, 0.287312031679534, 0.308447975580102, 0.314299992918047, 
0.313164474550676, 0.294927463636144, 0.281247188653733, 0.274658928193482, 
0.274203965182321, 0.2803416651459, 0.289425658663382, 0.268587015948453, 
0.278442379268056, 0.282237043785985, 0.236644412298898, 0.251720173589422, 
0.242395679748647, 0.24938410265949, 0.295508887916275, 0.278950255259894, 
0.293666588131497, 0.292188590391678, 0.278726161275717, 0.284374911049966, 
0.287565256445791, 0.283974059909715, 0.289688636396001, 0.272920597125778, 
0.275755718332182, 0.255404297960136, 0.273985074229535, 0.266033197112051, 
0.261428467000866, 0.278526095883114, 0.294460497723324, 0.283447394492457, 
0.28119537897849, 0.279698175101185, 0.268818659034743, 0.279112229866771, 
0.289520153337675, 0.286612617854246, 0.279087587948068, 0.261711974079026, 
0.266587280339746, 0.266418465755808, 0.294346686781895, 0.291839305305777, 
0.306356528508974, 0.310404190167519, 0.321911143418055, 0.332923985811377, 
0.309653765848373, 0.325139721058963, 0.303561097945598, 0.306654556837685, 
0.292831890072667, 0.304887526755578, 0.298327294546768, 0.300633992292781, 
0.280971332177303, 0.299313815363465, 0.308254009168039, 0.298487729221126, 
0.286394730189864, 0.299321526050098, 0.293591705338823, -0.0574296434207897, 
-0.0862593961603305, -0.0837075291001533, -0.059842133362563, 
-0.0689808495158624, -0.069061850709401, -0.0676644193575753, 
-0.0928413021344294, -0.0704629658483119, -0.0983439950777258, 
-0.0690851840232413, -0.0902411819796782, -0.0676407847504969, 
-0.0794767218228423, -0.0694392228212659, -0.0647056200811343, 
-0.0920893219201121, -0.0850184017914822, -0.0769567628285751, 
-0.080285286423829, -0.0662180685802679, -0.0959828178367751, 
-0.09699440514945, -0.0827297761475372, -0.0939974972887752, 
-0.0793796066737181, -0.105846995525745, -0.0756936799457347, 
-0.0768032358479105, -0.0683023130830397, -0.0763185397470085, 
-0.0637816818513169, -0.066490799244348, -0.0788277032447909, 
-0.0731145235066232, -0.0735965675058257, -0.0819994268745288, 
-0.0945271559939327, -0.0682122951226105, -0.0857528367313488, 
-0.0692574461193296, -0.0770589461296702, -0.0619697635005598, 
-0.0804250213236426, -0.0698067641413048, -0.0740925499848968, 
-0.0980249649373093, -0.0709501124636946, -0.0622245317122322, 
-0.0721169101138992, -0.0812079938684413, -0.0803036949735808, 
-0.0760148518288933, -0.0825265385651468, -0.0803758556780202, 
-0.0954070076161891, -0.0878482949734511, -0.0825906696687526, 
-0.0868840362347425, -0.0758060818450795, -0.0702356550461873, 
-0.0659676785780801, -0.0802738795311971, -0.0865889135004062, 
-0.0851291433849611, -0.052302035744972, -0.0524976681796916, 
-0.0883934471593463, -0.0802642498256589, -0.0832280655563911, 
-0.0814478559446828, -0.063347359328879, -0.0737001041468491, 
-0.074379452555094, -0.0708706631799833, -0.0772154803168839, 
-0.0638576640759795, -0.0981665234260098, -0.0801478087233525, 
-0.0817769534399892, -0.0758238568437766, -0.0883658784558205, 
-0.0732255602659232, -0.0715683302510073, -0.100120012156604, 
-0.0587861591757893, -0.0843787288267599, -0.0593844128645743, 
-0.0838845587386164, -0.0682701288278825, -0.0843376569099514, 
-0.0760683586708736, -0.0792761742598028, -0.0772076776635033, 
-0.0634749361307475, -0.0811282082936321, -0.0840045237353755, 
-0.0641855173093928, -0.0780479666266152, -0.0686029192942738, 
-0.085216676026621, -0.0811087443251253, -0.0693573064367706, 
-0.0965417190201147, -0.0729692673590129, -0.0612828570381474, 
-0.0650771879440829, -0.0667753357461016, -0.087696378308422, 
-0.0699498101997635, -0.0843957873442322, -0.0729610178697001, 
-0.0834498111021654, -0.0556222873571455, -0.0690573488816346, 
-0.0800208176503317, -0.0743594562299299, -0.0895941455053293, 
-0.0672271762363427, -0.0872079033248901, -0.0775789235722078, 
-0.0862393196393492, -0.0902171478342783, -0.0660464978550118, 
-0.0871702351550575, -0.0633271610855284, -0.0950355447056175, 
-0.0700813723302481, -0.0670517234737163, -0.0911832900678043, 
-0.0791575786598923, -0.0662801602499689, -0.0829727330280137, 
-0.0822625532266516, -0.0742414503915699, -0.0911983750243297, 
-0.0665289320923049, -0.102835319581752, -0.0700060314951391, 
-0.0914786730002066, -0.0758549572078334, -0.113181420870764, 
-0.0746894531182684, -0.0847366545506086, -0.0814699214841849, 
-0.0815069722528738, -0.0800463846667039, -0.0771282228004433, 
-0.0791048710138359, -0.0952471404264263, -0.0928073182611418, 
-0.0922995965750659, -0.0804864310038686, -0.058457939426213, 
-0.0824680581980647, -0.0746550897697086, -0.0784177544948941, 
-0.0677496275725006, -0.0870950843693691, -0.0582869916632054, 
-0.0603405052463752, -0.0769449978865898, -0.0700276553345545, 
-0.062916622472398, -0.0778518667598928, -0.0623617515803898, 
-0.0667463495261039, -0.0820435180667848, -0.0651265061181564, 
-0.0728096302807671, -0.0674088395216193, -0.067994579997612, 
-0.0488489021032286, -0.0838615316757511, -0.0660295042234757, 
-0.0704286768881419, -0.0613266496077249, -0.085856450501362, 
-0.0704828927014034, -0.0773533079075482, -0.07454075108371, 
-0.0733723373486092, -0.0646075916745445, -0.0590422507736366, 
-0.0918496083260501, -0.0683408295817429, -0.0978681288695512, 
-0.0716668004997032, -0.081697771337204, -0.0692302320923627, 
-0.0745068965726097, -0.0618588175146283, -0.061616680726007, 
-0.0875690950499199, -0.0589463129288997, -0.0822319542531593, 
-0.0762929190490337, -0.0616728080074403, -0.0634715448098344, 
-0.0692264747477478, -0.0484087077210873, -0.092936032424626, 
-0.0659679589051971, -0.0889103783415073, -0.0929233100891377, 
-0.0603138591002306, -0.0691213497269944, -0.0597453344072717, 
-0.0758675902130765, -0.0727718338688328, -0.079833739511331, 
-0.0779979067015308, -0.0729731371283455, -0.0684832995534389, 
-0.0567382188675036, -0.0500265993394037, -0.0688119875683019, 
-0.0810266274202628, -0.0786602707436067, -0.0791803927840944, 
-0.0746860696679345, -0.0706035130127162, -0.0937969874483166, 
-0.0712653316545241, -0.0914770781703968, -0.0619638659745362, 
-0.0689849850850139, -0.0537793606893735, -0.0741173734648115, 
-0.0854644629508754, -0.0740728002020681, -0.0871281235361737, 
-0.089180444400782, -0.067162002165006, -0.106460290852079, -0.0802744378255398, 
-0.0914828702620109, -0.0683334443725914, -0.101388118339061, 
-0.0574540016899809, -0.100701077262759, -0.100400999981857, 
-0.091670781405322, -0.070188454370112, -0.0816125220046459, 
-0.0853863926939034, -0.0874801240422578, -0.0686188045657976, 
-0.095371513477671, -0.0981456281940276, 0.154186813355457, 0.18899701315725, 
0.180083429715821, 0.187291687447256, 0.222392222251446, 0.167308085518571, 
0.206034973646627, 0.164709335735351, 0.196305259749993, 0.20748042299524, 
0.199737275245922, 0.220755555858926, 0.171369719535326, 0.203052590484807, 
0.153495503828318, 0.166734064713117, 0.194186686222535, 0.186904501913073, 
0.170914386719961, 0.210842166994201, 0.188972822007377, 0.184102423258484, 
0.178494838053613, 0.157234700018222, 0.15344816416235, 0.2559461343113, 
0.16653059363224, 0.163254399890768, 0.190677518091196, 0.208211288807981, 
0.21939076667633, 0.231901057369081, 0.218600687387306, 0.215244659718573, 
0.184239217935302, 0.164252405774983, 0.217115584232719, 0.226320607540375, 
0.17827971958983, 0.187910204016057, 0.182114393904838, 0.170519843102145, 
0.211388715997132, 0.211612559065601, 0.16564823725931, 0.192994917330407, 
0.176666988049238, 0.189751308954096, 0.172661440435165, 0.205600156532004, 
0.185779894157741, 0.195413642323603, 0.177207085615424, 0.220206442116885, 
0.219151823105558, 0.125857409612894, 0.167860074665809, 0.150819980100458, 
0.161536244453623, 0.178879750838751, 0.210606552407989, 0.192773090044958, 
0.198475743591708, 0.194878567118132, 0.199343306164364, 0.170618831073396, 
0.172328381395191, 0.176506008223312, 0.187035498187786, 0.194001331954152, 
0.22557373796066, 0.191917012203866, 0.189699271637787, 0.211052525212202, 
0.182654772332162, 0.184071270402047, 0.198381003478053, 0.157830362878146, 
0.156519829204417, 0.185186963731243, 0.184312521168318, 0.206275881290825, 
0.195808686442229, 0.189301176944747, 0.172998047784921, 0.193025243537148, 
0.179694346131849, 0.189454509256962, 0.17367426534308, 0.192686453140403, 
0.209156058138634, 0.186769791392033, 0.177147841960402, 0.193375903528826, 
0.203472859057324, 0.18016341052291, 0.216208893758415, 0.204410849834646, 
0.189475052208254, 0.179035053393311, 0.181488286262983, 0.200859742526911, 
0.172968793264912, 0.182249223143308, 0.209933081984948, 0.186525085667455, 
0.205759305846396, 0.174958991341316, 0.200953896699015, 0.256476278146055, 
0.187734598712475, 0.169481120364693, 0.195231390374118, 0.17913719483474, 
0.179582026710851, 0.167315872072721, 0.186405020736422, 0.180130593555577, 
0.210253531293131, 0.198581373726378, 0.199017885328497, 0.189121136605345, 
0.190082921700606, 0.175872662454008, 0.17240487875737, 0.155988841512893, 
0.187060020375417, 0.176978192824815, 0.200298287932364, 0.184204320852437, 
0.187881014866253, 0.221978068451297, 0.191620774201945, 0.214243820862819, 
0.213623425246877, 0.20209926688287, 0.189555906778925, 0.17937756737498, 
0.231019608445527, 0.170535238724747, 0.231701023425612, 0.179175047211541, 
0.209386460460358, 0.196949546639942, 0.188639858725866, 0.189817166660568, 
0.168024379017356, 0.16402037329534, 0.184503288082106, 0.14328629620915, 
0.135389515035359, 0.206460601822623, 0.145882098355576, 0.184766119164823, 
0.195776769679461, 0.174490060897358, 0.178217268128389, 0.190779488581324, 
0.2182292724801, 0.161164438502027, 0.169595216859076, 0.154948893525308, 
0.236612693404771, 0.189720011315963, 0.173708059063995, 0.248678420178146, 
0.211340818351864, 0.199194719487771, 0.202902947969892, 0.179445455792873, 
0.213505273449834, 0.184139819183219, 0.194533214359231, 0.205102444116005, 
0.191920666507715, 0.193100581756562, 0.24495947317806, 0.183326130418448, 
0.175788160046272, 0.227322387910274, 0.196599192240031, 0.209140397280671, 
0.174005154274662, 0.183628335077612, 0.195760109713017, 0.209345345179995, 
0.152829663210413, 0.213680407215374, 0.158714508090083, 0.211813790671599, 
0.173232160366095, 0.165748516045299, 0.193573154240567, 0.18948176177586, 
0.183394065836346, 0.198230380494924, 0.177602312103783, 0.221550613831703, 
0.213300060556925, 0.203780176338487, 0.21170650201512, 0.209807882620897, 
0.170779223193737, 0.1833250364181, 0.192356685906387, 0.174507100784991, 
0.187906126879143, 0.169054300606444, 0.172719909073304, 0.200529016013761, 
0.205513644912351, 0.237685777139755, 0.196233466608052, 0.164934320169555, 
0.173225961237862, 0.168134152926385, 0.153259860063508, 0.202116970341257, 
0.209701683071106, 0.183188069085184, 0.176926712772745, 0.17189242230031, 
0.190108585343754, 0.165456715687814, 0.214088823195661, 0.151696443604594, 
0.198111374760864, 0.202512934290567, 0.199153347894263, 0.193221159663204, 
0.168849439425342, 0.174487316331203, 0.178635273871889, 0.194046345314683, 
0.158325153012658, 0.194198126429532, 0.178997863185808, 0.202869875780121, 
0.166135508552706, 0.19061976394495, 0.124801726452832, 0.156123264714805, 
0.180210677183991, 0.154422630121704, 0.204564077664105, 0.174286436579514, 
0.163450293616505, 0.161301766563077, 0.210803953643276, 0.207684216070712, 
0.0799125152958054, 0.0914850616263355, 0.0958705821533917, 0.0962389359530904, 
0.099736795112069, 0.0926440317335611, 0.131775068961328, 0.0681731842707179, 
0.104811351955479, 0.0880331733198655, 0.0668713250023829, 0.0959455686839442, 
0.0812859954137417, 0.0897296637649808, 0.137458389849369, 0.127627642455393, 
0.0678156761390073, 0.0448480701415323, 0.0834088733504273, 0.0586619247885339, 
0.0970684763863061, 0.0428611546225891, 0.0898327509159766, 0.0767399534362586, 
0.0492396235902714, 0.0683654436270213, 0.0562145730026033, 0.0926153356075204, 
0.110293282304387, 0.0856528638666211, 0.0842989541834336, 0.0747862505282133, 
0.105574609910203, 0.0924902611772528, 0.124589272031421, 0.092150194258717, 
0.061768764836968, 0.0853041329170292, 0.107203008060613, 0.0782656170140565, 
0.0729556756918593, 0.0874061182047656, 0.121459036511638, 0.137976741401583, 
0.143399208147268, 0.137258604817964, 0.0550426225647213, 0.129295999689608, 
0.0388493241486159, 0.163557752900173, 0.19116110127912, 0.130869481429905, 
0.0659081376532552, 0.0902066170783655, 0.0791237037890356, 0.0744507553737748, 
0.0853725072790463, 0.07188821810221, 0.0947121529657676, 0.125861716265774, 
0.0482011170250896, 0.0881621822996518, 0.0488830554175836, 0.0551037625289163, 
0.0538383532321945, 0.0820571475175068, 0.0816694285003712, 0.0873429419076208, 
0.0883790299093763, 0.100331994616115, 0.0283412021393484, 0.122086619247343, 
0.11187737632883, 0.105487868425822, 0.0483360977919863, 0.114245137630767, 
0.0441835275608155, 0.10980914174558, 0.0537126541234762, 0.139466020224151, 
0.0468443330362266, 0.113373802495391, 0.0852461932566995, 0.0466773167800348, 
0.0750794877556901, 0.0722458160301901, 0.106134569392546, 0.081983296481043, 
0.0618243944946849, 0.0908800136367105, 0.0838990993846343, 0.0840191124394179, 
0.0640040294047483, 0.119529181782851, 0.108856445712673, 0.107776376774407, 
0.0942287276862906, 0.0494918182735569, 0.0862749974272399, 0.0665233133751195, 
0.0694028827213834, 0.110624280809982, 0.110672387988357, 0.048709209175474, 
0.0660882908627408, 0.130038216992209, 0.104404404768605, 0.124017276918961, 
0.097051155288779, 0.169525569623289, 0.0637032769961071, 0.120644583102728, 
0.0638050386673268, 0.132653573266813, 0.140847200744329, 0.0299748829783575, 
0.0646962136302683, 0.100221039398841, 0.0426639135493251, 0.0919407045385186, 
0.0670078169122677, 0.0419543992635157, 0.118848283617884, 0.0828827315973567, 
0.133467826982409, 0.0404721448733172, 0.0897313775702313, 0.0842558184154073, 
0.108083902527943, 0.0942594803371196, 0.108221895444548, 0.0627578827638131, 
0.104485421779637, 0.0717027991416081, 0.0749488778041066, 0.0509105592241336, 
0.096051965658668, 0.0779004503727607, 0.102320642951416, 0.155869405130222, 
0.0659815480626322, 0.12669091671597, 0.0495514810513353, 0.0934293111882404, 
0.062883945242455, 0.12662417256048, 0.029782349133727, 0.0925485106271035, 
0.0900495933492626, 0.0580150944561706, 0.0981073099281784, 0.109018213686349, 
0.068055911795909, 0.111854569331333, 0.100894252165806, 0.094199167830212, 
0.112149591478889, 0.12475130685525, 0.0652965324009762, 0.095172149054471, 
0.112971637687725, 0.0849298867018108, 0.0814700561481614, 0.0905321661560875, 
0.106611654179665, 0.10136973869103, 0.0794008324409053, 0.147234203389867, 
0.126573504803409, 0.0581206339361909, 0.120204729510787, 0.0266455018198334, 
0.135595981297231, 0.0733038669618825, 0.0643002582903073, 0.077268532431012, 
0.104485158906042, 0.0617805513154392, 0.104061370483454, 0.0686504840878594, 
0.0612079678655142, 0.167814643250138, 0.0731444766778462, 0.05039280290471, 
0.113560108944194, 0.0647793626661283, 0.076958098250633, 0.1084443838649, 
0.0175487577894098, 0.102828792937124, 0.156604426973419, 0.125221139561564, 
0.0839784134758895, 0.0914668907296804, 0.159458350694922, 0.129421185497138, 
0.0779201402942523, 0.188189131876897, 0.102045854072169, 0.106741161031894, 
0.125842572879072, 0.096867156282309, 0.101257188738647, 0.0299239808427873, 
0.00974518613368454, 0.121633901363351, 0.103359189921288, 0.0914958965582719, 
0.0882498192907018, 0.0657792981519642, 0.131184408717395, 0.0891382877705378, 
0.0979583467836294, 0.0847178511775841, 0.0816396722945378, 0.0846678139129247, 
0.0975826525943872, 0.0864422731544332, 0.0813930735147506, 0.0870185608810453, 
0.080433518694674, 0.126739674083638, 0.0685756289395081, 0.149302526156506, 
0.0787250104601254, 0.15868082301227, 0.0900121978821821, 0.0860702042515594, 
0.116069935583159, 0.0988536574558483, 0.093253040431871, 0.0644751059947461, 
0.069658108575839, 0.0576665773181552, 0.0948633976502699, 0.0869707639012815, 
0.102288224586323, 0.0851587374765648, 0.0664248129591915, 0.0500657635582781, 
0.0925767087778066, 0.0565634915234292, 0.103913392318839, 0.0984442531362363, 
0.0884559566210226, 0.135414860370937, 0.0965798368098573, 0.0634718942563408, 
0.113504166406202, 0.0691274320090004), .Dim = c(250L, 4L), .Dimnames = structure(list(
    iterations = NULL, parameters = c("Intercept~gamma[0][0]", 
    "DN~gamma[0][1]", "Pos~Events~gamma[0][2]", "Neg~Events~gamma[0][4]"
    )), .Names = c("iterations", "parameters")))

最佳答案

您需要添加 scale_y_discrete在那里你将现有的标签映射到表达式,这些标签只是“Intercept~gamma[0][0]”。有点努力,但它有效。
对于上述示例,它的工作方式如下:

library("ggplot2")
library("bayesplot")

mcmc_areas(gamma.b0) +  scale_y_discrete(labels=c(
  "Intercept~gamma[0][0]" = expression(paste("Intercept~",gamma[0][0])), 
  "DN~gamma[0][1]" =  expression(paste("DN~",gamma[0][1])),
  "Pos~Events~gamma[0][2]" = expression(paste("Pos~Events~",gamma[0][2])), 
  "Neg~Events~gamma[0][4]" = expression(paste("Neg~Events~",gamma[0][4]))
  ))
gamma.b0取自 dput的问题启动器。
然后看起来像这样:
enter image description here
只需忽略 Scale for 'y' is already present警告。它只是通知您,您正在覆盖比例。但是,这就是我们想要的。如果我们拥有完全控制权,我们当然只会替换对 scale_y 的第一次调用,但由于它隐藏在包中的某个地方,我们必须覆盖它。

关于r - 从 bayesplot R 包更改 mcmc_areas() 图中的 y 轴文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48631486/

相关文章:

python - 将分类变量绘制为堆积条形图

python - 如何使用 python 3 让数据沿线显示?

r - 在(R,ggplot2)中围绕条形图和类别绘制一个矩形

r - 使用 ggplot2 绘制 "sequence logo"?

R 预订 : different output depending on operating system

r - 控制ggplot2中点的顺序?

r - 无法使用 labeller = label_parsed 将分面标签设置为斜体

python - 在 (X,Y,Z) 坐标图上包括时间标签

r - 将具有相同值的两列与第三列合并

r - 数据框中分组数据中每个观察值的标准误差