Home > Enterprise >  Different Column Colors for BarPlot
Different Column Colors for BarPlot

Time:06-19

I'm trying to plot a bar plot for a dataset, and for every different column, I want a different color and different space (starting point) on the X-Axis.

My data which I'm trying to plot is:

MEs_interest<-structure(c(-0.167883113654055, -0.0109845487812259, -0.246272322275879, 
-0.155118397135028, -0.187094786264526, -0.208897816323153, 0.00918849047141923, 
0.0660987731811726, -0.179682091342798, 0.0361927428937938, -0.168337427405039, 
-0.0872997940891031, 0.0487147246178567, -0.104997421215032, 
-0.166612765418889, -0.27972731849213, -0.269614736192796, -0.218686589132102, 
0.0186266000013494, -0.115752853428279, -0.234180322169165, -0.234468472122879, 
0.0853896953163215, -0.119401273395233, -0.233526198026173, -0.144933683751518, 
-0.0333872077870683, -0.126075081839166, 0.0234495180825954, 
-0.00281266281371647, 0.0445651510989791, 0.0630320836892592, 
0.0436234416845773, -0.0886151219175411, 0.0298035200365961, 
0.0349886112765651, 0.0517249448636533, 0.0517072886417856, 0.00174466699335717, 
0.0733810433264405, 0.0410509459270766, 0.0676557513817245, -0.0269596623935842, 
-0.00820936337881583, 0.02522810021815, 0.00267203913812894, 
0.0404411696230505, 0.00778308464809111, 0.0710350653753223, 
0.0197690169067339, 0.0751746632072388, 0.0426872422402503, 0.0340506853594921, 
0.0570951395009317, -0.063904515361206, 0.0301134757558089, 0.037721725722185, 
0.0379028470477037, -0.0501512877980435, 0.0146458018254246, 
0.0169104778681714, 0.0166020210546553, 0.0335133220130473, 0.0799952315650975, 
0.0597261261615782, 0.0502931924476911, 0.0660898397511455, 0.0623527359020107, 
0.0612670838013991, 0.0485127009937002, 0.0296422363306305, 0.0226549968931128, 
0.0421866386276217, 0.033689420608973, 0.0143707938725627, 0.0323944782266678, 
-0.0561065303680797, 0.0159055854831309, 0.029253749717009, -0.0188670612502005, 
0.0112972253615203, -0.06431052412551, 0.0250462802314866, 0.0107992194569716, 
0.0299356337755449, -0.0193161442678109, 0.0233907157277332, 
-0.000479152834915138, -0.0275571300272356, 0.0071482643104301, 
0.0155501629833139, 0.0549486042057134, -0.0295269190699637, 
0.0147591225770697, 0.048859572538863, 0.0462742967694186, 0.0401945677460769, 
0.0582644826473239, 0.0529058823007485, 0.0396103453773642, -0.0365450591770336, 
0.0231450330174636, 0.0219066032428664, 0.0165028195038822, 0.00555260221650196, 
0.0255220214117011, 0.05972511552943, -0.00293890153218165, 0.011531281677417, 
0.00472094891522337, 0.0388412770430323, -0.00848060907412595, 
0.058765716401801, 0.0224064334838153, 0.0465432843798102, 0.0732501647564376, 
-0.0425524349691691, -0.0518826407283709, 0.0158806561591187, 
-0.0286128903565543, -0.0329442996876906, 0.0464066108874249, 
0.01520737475578, 0.0330900155692634, -0.00191481252863317, 0.0340515712165811, 
0.0415944015575292, 0.0749587114290293, 0.0425781723420161, -0.0131167918368139, 
0.0231381066250714, 0.0394491706644696, 0.0372707556665713, 0.0323661968818813, 
0.0517911455540302, 0.053642562448806, 0.0439292833520655, 0.0730670438716113, 
0.0668073402456916, 0.0522203703833991, 0.00668465079574304, 
0.0427141845252473, 0.0495655293001473, 0.017824914580245, 0.00200659539964028, 
0.0690866441367867, -0.0641030056751768, 0.0534056980949714, 
0.0290577604811227, 0.0501364340213389, 0.00914202669090587, 
0.0336902664324295, 0.071225154924611, -0.0136941200949208, -0.0905757581741776, 
0.0213335707173911, 0.0390943141984785, 0.0691204593738523, 0.00632451878190229, 
0.0416548662739056, 0.0591526594907932, 0.0447283941459729, 0.0180087273178382, 
-0.0463838936951452, 0.0115655451783892, 0.0520568642113286, 
0.0653710224456479, -0.00716286684528034, 0.0471983662611778, 
0.0042252235615105, 0.00881814031121959, -0.100329095271737, 
-0.0784894235648148, -0.0879486442773462, -0.0995049018784005, 
-0.0714818317916746, -0.0976149187829668, 0.159506068630208, 
-0.0078547447048395, -0.0919187341851776, -0.0183352208123751, 
-0.0802716031327569, -0.0921892597579533, 0.122475915845315, 
-0.105142453664124, -0.107464669408259, -0.0838230654624859, 
-0.0643026477240475, -0.0991970944971272, -0.0299497021490766, 
-0.0925869123215248, -0.0801263954108516, -0.0801822804978344, 
0.0483614999202892, -0.113020942570186, -0.086222455739712, -0.0955321732050414, 
-0.0862950652844206, -0.105901883188655, -0.0691227020495421, 
0.122855757900366, -0.00775327369477913, 0.123100527228534, -0.0669809123427486, 
-0.0585739561136604, 0.100304653646559, 0.0349694887360746, 0.0469806844923322, 
-0.0576157350561252, 0.0520135948784879, 0.00315603482506785, 
-0.0198951438165247, -0.00246034797944162, 0.0969092084918055, 
-0.0902834865641707, -0.0551735757541441, -0.0613498834032341, 
-0.0267710162398181, 0.0787154451005951, 0.0197522841477128, 
-0.00167191675572842, -0.00465558318290105, 0.121344888884004, 
-0.0360115067148308, 0.0030315551432746, -0.0768549536747807, 
-0.0340239896899978, 0.0581896098611151, 0.0740814844944048, 
-0.00317558544404492, -0.0255827720456927, 0.0311763786580515, 
0.118904699429595, 0.145098411471553, 0.00559952790871642, -0.00924213046996065, 
0.148973924015989, 0.0733341558913802, 0.132164118610878, 0.108161877817613, 
-0.00167126279561422, -0.0301657074833563, -0.0656702081245102, 
-0.00408631708560696, 0.00160420194073306, 0.0644345000940215, 
0.13899618496975, -0.0951596031875526, 0.0559242402383481, 0.00565219843692423, 
-0.0139308747729803, 0.0170771594811669, -0.0848253978791843, 
0.0125132100557799, -0.0505524419818989, 0.112363124350471, -0.0693670769355527, 
-0.0539609911452939, -0.0524392683491411, -0.0456416511618137, 
-0.0592997416126156, 0.0438177824171634, 0.198077913663882, -0.0199031910961955, 
-0.0643787771622208, 0.0801655887182166, 0.191116104423863, 0.0385780808096827, 
0.027258542378176, 0.121938886393089, -0.0247056562502751, -0.0723464875996639, 
0.121788171636144, 0.0266794711033146, -0.0176285396513365, -0.0487205835140447, 
-0.0148172758131183, -0.0384219000997534, -0.0667233747109581, 
-0.0408576022214058, -0.0509782485121241, 0.0789265992192412, 
-0.0907075331630156, 0.0351793779847248, -0.0463322118080475, 
-0.0274833085774418, 0.0347139023608301, -0.021691394476451, 
0.0371346238421278, 0.0157641919665901, 0.0616388129664385, 0.0798063651564864, 
0.116269039156931, -0.062345920994601, -0.0515430495048524, -0.0724405344680037, 
0.0745017150317672, -0.0551471456736422, 0.167112553076889, 0.112750615077756, 
-0.0983223236116504, -0.0259255255068899, 0.0428782248339586, 
0.135047754312987, 0.0768231021276516, -0.0454575002999197, 0.188700976644269, 
-0.0336785650729425, 0.060965573682007, 0.121340255772015, 0.0248294125090954, 
0.0577568978280966, -0.0265425286477317, 0.033140417837738, -0.0608324006332568, 
-0.0588606162553071, 0.0027898001540083, -0.0421852170887785, 
0.0958999214978047, -0.0541823253783314, 0.00719081314613352, 
-0.0263976668064388, 0.112461170990086, 0.0240746567692194, -0.0532656243569445, 
-0.102519644919785, -0.0451299515114229, -0.0762568282743948, 
-0.0162619363221024, -0.0649350217653177, -0.0320334238148746, 
0.0635537933702103, -0.0613386861509133, -0.0223686671084059, 
-0.0966106844112729, 0.14218847410662, -0.0309222329576275, -0.0255923876623323, 
0.0354052509421006, 0.135611451649035, -0.0478888102724466, -0.0372664642365923, 
0.0496191101107336, 0.130845431420586, 0.0520264149008036, 0.0854617949112739, 
0.0153143285568461, 0.0138577418822467, -0.146526829901649, -0.0388445912643835, 
0.16637132352514, -0.036790968426816, 0.136179898679897, 0.0325362917451082, 
-0.0862509925988111, 0.134280378238923, 0.0481757419670939, -0.0678217105237136, 
-0.0980229321521949, 0.0660774319688092, 0.0686963951231444, 
0.127712350792151, -0.0437788600734283, 0.0878538693816119, -0.0370044484031624, 
0.0774977578587763, -0.031750256452673, 0.07455464047382, 0.0685914700173678, 
0.130307663936271, 0.117628655470305, -0.117732656310375, 0.0331758294320734, 
-0.0168075373142076, 0.116745312262541, -0.0650488711498882, 
-0.133881676012451, -0.0402081006142152, 0.0427977836384676, 
0.119461150129943, -0.116397057227036, 0.0609065752787114, 0.0612710535377532, 
0.0356327414012827, -0.17531437543433, 0.0965961031608144, 0.108059295745081, 
0.0737883120835439, 0.0281610532504119, -0.0913740799268087, 
0.0426319081111112, -0.0597427762415466, -0.026807119623025, 
-0.0710152842368466, 0.00501360841222618, -0.00963546856658823, 
-0.0730477585293709, -0.022861507476196, 0.00866138357683608, 
-0.0528769253546922, -0.0869070840237108, -0.0508059053885246, 
0.0418259766108774, -0.0716107059345796, -0.136415795985498, 
0.0549118968935104, 0.0148443818291551, -0.132977193136412, -0.027739819461597, 
-0.0371322164493943, 0.0377855650337557, 0.0238826637593811, 
0.0571905858143821, 0.0822231676708165, -0.00580138153633446, 
-0.0547717725448658, -0.0869439016084927, -0.0825202436834532, 
0.103258746586886, -0.0147135022062199, -0.053764094204407, -0.0515759007541629, 
-0.0458207551811548, 0.0864730496273459, 0.0253546917521453, 
0.0062534964242107, -0.112340980780985, 0.0966403398237166, 0.0385022951132014, 
-0.0134436889512487, -0.0679288346530651, 0.057158093192632, 
-0.0215778024871715, -0.126263363748998, -0.0521636930858451, 
0.0983936901773389, 0.0170932772090801, -0.128401055214024, -0.0326099714636749, 
0.0208206285522447, -0.0491088965486627, 0.0609681104908991, 
0.0924273590037427, -0.0460357440438447, -0.00890582843953654, 
-0.0153458816354349, 0.0271389401314143, -0.0307066731514891, 
0.0463029136069294, 0.0658537984294339, 0.0863926536769721, 0.0807069821765551, 
-0.077928790219639, 0.0983346698006099, -0.0285246130178103, 
0.0564754790804444, 0.0110164425804472, 0.0260872449826066, -0.107242341239473, 
-0.13585985504707, -0.0708006991526667, -0.150738729954756, -0.176219784739155, 
-0.0516338130337919, 0.106003582900141, 0.027173630616992, 0.0455798655535007, 
-0.0282070815680859, 0.0753731572842278, -0.0384218801311019, 
-0.0441204932184695, 0.13635885137742, 0.0452103591772969, -0.00851243601537849, 
-0.0920737106133899, -0.0622149584817104, 0.030972072787279, 
-0.162003761651321, 0.0866308543672005, 0.000120981755954922, 
-0.0350998171742878, -0.0295692479651371, -0.0900113038506451, 
0.0654365038994144, -0.0234530383932615, -0.00169818794406625, 
-0.05923646149627, 0.00177145777991906, -0.151873775524508, -0.0481232446601981, 
0.0804016713238165, -0.0358767334256667, -0.0279537970500169, 
-0.11595320505811, 0.00770751564012494, 0.0156268844148726, 0.0956570203823143, 
0.0842134663760589, 0.0921605598296696, 0.041625747142584, 0.108858578417909, 
0.0461398835370116, 0.0144443551522171, 0.0278864529344629, -0.02185140072081, 
0.131367770526474, -0.0988121361490595, 0.0154450873401162, 0.0184482069444927, 
-0.0929294066709593, -0.110733860113803, 0.0374670944842707, 
0.0126644814396289, 0.13722224885649, 0.348756408712165, -0.0800936623582766, 
0.197824913378728, -0.0205788858009016, -0.126818727577524, -0.0865505994454585, 
-0.0596441543425443, -0.0197970499720824, -0.0463019712805513, 
-0.0334182781567987, 0.122694391378806, -0.0578620147308185, 
0.136041922205044, 0.0626293391953756, 0.0316228992508401, 0.051048170154005, 
-0.0938622475936843, -0.0136841309266074, 0.29538347151955, 0.0672243499977651, 
-0.081023944076598, -0.0707293257868871, 0.0650574935030528, 
-0.0126799698551899, 0.199173297089332, 0.0723671047220706, 0.188819134158534, 
0.137388827585352, 0.0665620204383291, 0.0129985536708578, -0.00641295161781279, 
0.092162548951836, -0.0275499416469347, -0.0654242292652975, 
-0.0439815204389968, 0.164585912466781, 0.0284316286538745, -0.0821275496096236, 
0.0112554785630342, 0.141861795271304, 0.0262755361992625, -0.077335692826846, 
0.0707632587037343, 0.157601193886791, 0.0322042310715407, -0.0332289273879258, 
-0.0749556683218935, -0.00886424112513145, -0.0347319961204218, 
-0.0230123662949283, -0.043459540751382, -0.0106278319145244, 
0.00206628867364292, -0.028603628355587, -0.0157905674369288, 
-0.00972470915238633, -0.0436982676677246, 0.00598495672648273, 
-0.058607938384562, 0.088124582684614, -0.0587116873963446, -0.0671103455233492, 
-0.00986157740620069, -0.0278595342996001, -0.107403763081458, 
-0.0512118638172837, -0.0577744127737658, -0.00165239552214914, 
-0.0419644937033105, 0.00924277177997976, 0.0569063295244213, 
-0.0023264906624604, -0.0500993825203407, -0.0320670359451045, 
-0.0877744341272892, 0.20774576301069, -0.00340620840656097, 
-0.0549382806230902, -0.0197015795483457, -0.0073027728817034, 
0.120905905462916, 0.0149354088924531, -0.0209031432758516, -0.0430871839560803, 
0.127834351279799, 0.0231638031919547, -0.0239634577517907, -0.0402033903996689, 
0.048245206634543, -0.00800798397808804, -0.0682079686532836, 
-0.089333334251344, 0.113464332388214, -0.00530189502779892, 
-0.0495790765108138, -0.02156862694303, 0.0140115082937416, -0.0309391830436008, 
-0.0170500142193456, 0.123714013031494, -0.00374545393382729, 
0.00728156484430139, -0.0412022992644703, -0.0142117550673772, 
-0.0565766604893908, -0.00438687735133072, 0.13698107239167, 
0.121430133137964, 0.0285769014860504, -0.0882157972559028, -0.00513682092413234, 
-0.0494577187190989, -0.00760576775894098, -0.00815904042639174, 
-0.0184714004117234, -0.0761528319969632, -0.0919551493955804, 
-0.0534307291253574, -0.0766210026965363, -0.0911326291990061, 
-0.0426964389128384, -0.019842760274535, -0.00575817706726655, 
0.0292571569928331, -0.0502994539618534, 0.017200757626911, -0.0223268402195274, 
-0.0549332644853393, 0.172122720570476, 0.0351667467225326, -0.0292453657822691, 
-0.0758382946510589, -0.0324762805721025, -0.0335626220210316, 
-0.0603354634307705, 0.0267971436399351, -0.0282121288634499, 
-0.0416915895357366, -0.0468162780048794, -0.0515652928779877, 
0.0156883174162056, -0.0153250392090075, -0.062930378903254, 
-0.0169185230305848, -0.0336279774460591, -0.0728101673178451, 
-0.0388633188492992, 0.0278859460679174, -0.065184370713105, 
-0.0396033966466122, -0.0700290602679974, -0.019575133721855, 
-0.0442664102306734, -0.0110269851749267, 0.0276991428158124, 
-0.0159790059869293, 0.013812187392401, 0.0996211523912304, -0.00381110447054286, 
-0.035881640779901, -0.00862233524223178, -0.0201630772152444, 
0.107972561214749, -0.0511333070222857, -0.0229334475343165, 
-0.0526654359687691, -0.0573072992754393, -0.0877393682004004, 
0.0104322754738509, -0.033274116988406, 0.0669111171346558, 0.0837057669788319, 
-0.164559526573629, 0.014702020473466, -0.123047193449949, -0.0291251094597731, 
-0.156231277020043, -0.0447495590042895, -0.137596515322486, 
-0.0266068779713139, -0.130298868117392, 0.0501740645662331, 
-0.0848560252717673, 0.162625652137377, 0.0936054374640849, -0.0220460671613258, 
-0.0311431986113967, -0.174860138606855, 0.0508889727241686, 
0.013307684883397, -0.0389735225998367, -0.146220072707352, -0.072458305736215, 
-0.0163412223207896, -0.0634155967712594, -0.0183488342572776, 
0.0638755133054009, 0.130406298038576, 0.126337970878561, -0.118248068307865, 
0.00115631432668049, -0.00753510527054958, 0.0809102497951375, 
-0.0149410178388208, -0.0931814122391129, 0.0625916577577435, 
0.0708522492160012, 0.106552325938192, -0.0177749581712995, 0.0800333105875302, 
0.0461256419759588, -0.0255985072800693, -0.143885889495124, 
0.0276664231410563, 0.153715149951464, 0.102278814047285, -0.0108263113481667, 
-0.102577473888366, 0.0433304874745488, -0.12637824608344, -0.0910563972785921, 
-0.130627536852313, 0.0103710450718133, -0.0533501274900668, 
-0.0846536468052487, -0.102054789696852, -0.0217710754825245, 
-0.0570260391934781, -0.0536735499104174, -0.101441196634244, 
0.0755427252542611, -0.117178149290176, -0.14559920612317, 0.0133703436075249, 
-0.0123643945229038, -0.069181980220248, 0.0058378958743652, 
-0.0142554307334034, 0.0692450688725357, 0.100377908254435, 0.0540464334796487, 
0.0760243505852598, -0.0592150393864935, -0.040343455113455, 
0.00490908202615914, 0.00992546806509967, 0.142952284912983, 
0.110281990965637, 0.0333006228956315, -0.0746458038722342, 0.0328513001239849, 
0.204773906387843, 0.0481256375116919, 3.79998163219732e-06, 
-0.0460189271630351, 0.18156471981966, -0.0375513819095483, 0.0121301875516741, 
-0.0205907956201169, 0.0337531291880589, 0.0201587565421749, 
-0.0543910245326075, 0.0387230288289342, 0.101993049608964, 0.0179528255720091, 
-0.0468636510335127, 0.0285362628287438, 0.0254655616133399, 
-0.0523384135789692, 0.0395806097332656, 0.0452239927643388, 
-0.0234452591958666, 0.0792269293490691, -0.00348738115362428, 
0.0767377928643016, -0.0112954967928255, 0.0328582530909039, 
0.0774575750622573, 0.0839085198563492, 0.103333842344126, -0.00793340199656104, 
0.116874178479336, 0.00100123420132239, 0.0575984043797305, -0.00341520711324931, 
0.0765115758520828, -0.046131109643809, -0.0212910860261767, 
-0.0138388100631703, -0.055927482654182, -0.0560435437147868, 
-0.037793030213075, 0.0344534118807337, -0.0148555435505139, 
0.114424025491706, -0.0414441707952157, 0.0752514571234178, -0.066161306513014, 
-0.0308162471433, 0.0595630123128004, 0.114743030582505, 0.0376334228194248, 
-0.079161617932789, -0.0656637963120806, 0.0337967939229907, 
-0.138721803728736, 0.0901787912421233, 0.0151730264815294, -0.00135037951266996, 
0.0152279255603309, -0.0429269198299115, 0.0403423870407095, 
-0.0485620422489051, -0.00985450869228741, -0.0166909200083385, 
-0.0115969642546492, -0.146569831688796, 0.00771071284969688, 
0.120986036671833, -0.0728563583357328, 0.0704535914967137, -0.0836727284841048, 
-0.0328764249071281, 0.0556187178862716, -0.0286427177369668, 
0.143506918205138, 0.0886998654012563, 0.00669396149469512, 0.0907256659282244, 
0.0114292998130599, -0.0499431560985662, -0.0272376229047596, 
-0.0199809229333815, 0.0831234977548861, -0.138957915626701, 
-0.0102282011777627, -0.0214091481191839, -0.0528122889090426, 
-0.0981119922964294, 0.0412533746052338, 0.0344519088748895, 
0.0981791947286194, 0.138464419108534, -0.138443536660989, 0.0735849457821136, 
-0.0989132475093273, 0.208435014282372, -0.196962446030651, -0.0187764726316799, 
0.0279066357560171, 0.107299478700084, -0.0836441885372265, 0.0346409967849602, 
-0.0962524864123106, 0.142618931084639, 0.0750906041071312, 0.0800820894150817, 
-0.0388956049610418, -0.0862962942007109, 0.125617514770139, 
0.109800363695881, -0.0603003835784385, 0.00858662657497652, 
0.0529975055493171, 0.0427784887634529, 0.0211453409000538, 0.120674268709711, 
0.0159687712842468, 0.105741665390662, 0.0927072807270043, -0.146260512544239, 
0.0131939813117718, -0.0822139599772856, 0.00820558194336659, 
0.036778067484079, -0.130585757297907, 0.00746198750244054, 0.0280046034554625, 
0.0061267643576199, -0.0808820126420119, 0.0799115027474254, 
0.00918158334276879, -0.000656123790165103, -0.118190532973418, 
0.103825657172967, 0.06904583686173, 0.0341237593667419, 0.0359057299318852, 
-0.093686581698146, 0.174446190991789, -0.0859474360032168, -0.0174623444499266, 
-0.137856673858655, 0.00536685227515415, 0.00982281464427894, 
-0.0908458944872732, -0.0449311328254791, -0.0264707522576398, 
-0.0746924786938118, -0.106171627596702, -0.076529373168232, 
0.0100628910170241, -0.0303331652086482, -0.0235064506026337, 
0.0558637462689082, 0.0567469549802437, -0.124817547120179, -0.0514207595427712, 
-0.0029616470767134, 0.0421003203253678, 0.103328391455061, 0.141472825578556, 
-0.00999035012268753, -0.0936816774609254, -0.0100152205322539, 
-0.0217289809095008, 0.116602494985724, 0.15779836255024, 0.00021220008588888, 
0.126242252188535, -0.0973110532486401, -0.0285879316880335, 
0.0699758562361675, 0.015523423274104, 0.11050602239254, -0.0931063435038657, 
0.153291995365998, -0.0546049125018993, 0.103526658221259, -0.0269708861431449, 
0.0106904708186148, -0.0245311333410209, -0.141479988709078, 
0.0491789414092554, 0.0254146296267271, -0.0731708199888338, 
-0.114406025991903, -0.0178484202342452, -0.0564007930597582, 
-0.09285504308617, -0.0647704268290086, 0.00210440785567035, 
-0.0327970708152813, 0.0255450590469822, 0.158430704654842, 0.0166078258069268, 
0.0079762039100297, 0.113578647933633, 0.00841533668920821, -0.0029258670850414, 
0.00446488577684447, 0.0271755818163446, 0.07555831493223, -0.0177731019902273, 
-0.0410538639590101, -0.0514484084423735, 0.0639079152803222, 
-0.00115327990765407, -0.0206360923907938, 0.0350991002740231, 
-0.0294393038865667, -0.0131864692675914, -0.0790837215220605, 
-0.0405123858656559, 0.0284188907136545, 0.00980287235932678, 
0.0090293989641109, 0.043906525200066, -0.122746749765074, -0.109684081091931, 
0.00766108092871445, 0.0430916046322408, 0.0331172019157214, 
-0.059144674678392, 0.0599153796918249, 0.18147574972633, -0.128917820425481, 
0.0109386715050253, -0.00780975782644406, -0.0504304990620786, 
0.0762085640002715, 0.0107678817248912, 0.0748055583713357, 0.0226390049297619, 
-0.00560098643195065, 0.043908613877986, -0.0464294372889363, 
-0.104594958809986, -0.0238852710774054, 0.0324615312186495, 
-0.0400485956926298, -0.0143776861793077, -0.117836175708554, 
-0.0132517752520252, -0.0201281148375888, -0.0052601312826322, 
0.0748084283951894, -0.00907728901689874, 0.0713404691063987, 
0.0377676709266211, -0.0532934039161137, 0.00678850390454828, 
-0.0452509528840745, -0.0423786405305516, -0.00186197646292528, 
-0.131865293864393, 0.0290390349608956, -0.0425750217635509, 
-0.0119895852799472, -0.133982476804786, 0.0187935703551011, 
-0.0590113249161026), .Dim = c(171L, 6L), .Dimnames = list(c("TCGA.02.0003.01", 
"TCGA.02.0004.01", "TCGA.02.0007.01", "TCGA.02.0009.01", "TCGA.02.0010.01", 
"TCGA.02.0011.01", "TCGA.02.0014.01", "TCGA.02.0016.01", "TCGA.02.0021.01", 
"TCGA.02.0023.01", "TCGA.02.0024.01", "TCGA.02.0025.01", "TCGA.02.0026.01", 
"TCGA.02.0027.01", "TCGA.02.0028.01", "TCGA.02.0033.01", "TCGA.02.0034.01", 
"TCGA.02.0038.01", "TCGA.02.0039.01", "TCGA.02.0043.01", "TCGA.02.0046.01", 
"TCGA.02.0047.01", "TCGA.02.0048.01", "TCGA.02.0051.01", "TCGA.02.0054.01", 
"TCGA.02.0057.01", "TCGA.02.0059.01", "TCGA.02.0060.01", "TCGA.02.0064.01", 
"TCGA.02.0069.01", "TCGA.02.0070.01", "TCGA.02.0074.01", "TCGA.02.0075.01", 
"TCGA.02.0079.01", "TCGA.02.0080.01", "TCGA.02.0084.01", "TCGA.02.0085.01", 
"TCGA.02.0086.01", "TCGA.02.0087.01", "TCGA.02.0089.01", "TCGA.02.0099.01", 
"TCGA.02.0102.01", "TCGA.02.0104.01", "TCGA.02.0106.01", "TCGA.02.0107.01", 
"TCGA.02.0111.01", "TCGA.02.0113.01", "TCGA.02.0114.01", "TCGA.02.0115.01", 
"TCGA.02.0260.01", "TCGA.02.0269.01", "TCGA.02.0281.01", "TCGA.02.0285.01", 
"TCGA.02.0289.01", "TCGA.02.0290.01", "TCGA.02.0317.01", "TCGA.02.0321.01", 
"TCGA.02.0325.01", "TCGA.02.0326.01", "TCGA.02.0333.01", "TCGA.02.0337.01", 
"TCGA.02.0338.01", "TCGA.02.0339.01", "TCGA.02.0422.01", "TCGA.02.0430.01", 
"TCGA.02.0432.01", "TCGA.02.0439.01", "TCGA.02.0440.01", "TCGA.02.0446.01", 
"TCGA.02.0451.01", "TCGA.06.0122.01", "TCGA.06.0124.01", "TCGA.06.0125.01", 
"TCGA.06.0126.01", "TCGA.06.0128.01", "TCGA.06.0129.01", "TCGA.06.0130.01", 
"TCGA.06.0132.01", "TCGA.06.0133.01", "TCGA.06.0137.01", "TCGA.06.0138.01", 
"TCGA.06.0139.01", "TCGA.06.0143.01", "TCGA.06.0145.01", "TCGA.06.0146.01", 
"TCGA.06.0147.01", "TCGA.06.0148.01", "TCGA.06.0149.01", "TCGA.06.0152.01", 
"TCGA.06.0154.01", "TCGA.06.0156.01", "TCGA.06.0160.01", "TCGA.06.0162.01", 
"TCGA.06.0164.01", "TCGA.06.0166.01", "TCGA.06.0167.01", "TCGA.06.0171.01", 
"TCGA.06.0173.01", "TCGA.06.0174.01", "TCGA.06.0175.01", "TCGA.06.0176.01", 
"TCGA.06.0177.01", "TCGA.06.0179.01", "TCGA.06.0182.01", "TCGA.06.0184.01", 
"TCGA.06.0185.01", "TCGA.06.0187.01", "TCGA.06.0189.01", "TCGA.06.0190.01", 
"TCGA.06.0194.01", "TCGA.06.0195.01", "TCGA.06.0197.01", "TCGA.06.0208.01", 
"TCGA.06.0210.01", "TCGA.06.0211.01", "TCGA.06.0214.01", "TCGA.06.0219.01", 
"TCGA.06.0221.01", "TCGA.06.0237.01", "TCGA.06.0238.01", "TCGA.06.0240.01", 
"TCGA.06.0241.01", "TCGA.06.0397.01", "TCGA.06.0402.01", "TCGA.06.0409.01", 
"TCGA.06.0410.01", "TCGA.06.0412.01", "TCGA.06.0413.01", "TCGA.06.0414.01", 
"TCGA.06.0644.01", "TCGA.06.0645.01", "TCGA.06.0646.01", "TCGA.06.0648.01", 
"TCGA.08.0245.01", "TCGA.08.0246.01", "TCGA.08.0344.01", "TCGA.08.0346.01", 
"TCGA.08.0347.01", "TCGA.08.0348.01", "TCGA.08.0349.01", "TCGA.08.0350.01", 
"TCGA.08.0352.01", "TCGA.08.0353.01", "TCGA.08.0354.01", "TCGA.08.0355.01", 
"TCGA.08.0357.01", "TCGA.08.0358.01", "TCGA.08.0359.01", "TCGA.08.0360.01", 
"TCGA.08.0375.01", "TCGA.08.0380.01", "TCGA.08.0385.01", "TCGA.08.0386.01", 
"TCGA.08.0390.01", "TCGA.08.0392.01", "TCGA.08.0509.01", "TCGA.08.0510.01", 
"TCGA.08.0511.01", "TCGA.08.0512.01", "TCGA.08.0514.01", "TCGA.08.0517.01", 
"TCGA.08.0518.01", "TCGA.08.0520.01", "TCGA.08.0522.01", "TCGA.08.0524.01", 
"TCGA.08.0529.01", "TCGA.08.0531.01", "TCGA.12.0616.01", "TCGA.12.0618.01", 
"TCGA.12.0619.01", "TCGA.12.0620.01"), c("tan", "darkgrey", "lightcyan", 
"orange", "black", "darkmagenta")))

It has six columns so I'm expecting 6 different sets of column colors.

An example of what I'm expecting can be found in the below image: enter image description here

Similarly, I want every column to begin at different points on the X-axis. The above example just has two columns, but mine has six so I shall be getting six bar-plot colours.

CodePudding user response:

You have far too many values in each group for an effective bar graph. The example image has 44 distinct bars and is already a little crowded. Your data has over 1000 values, meaning you have to fit over 1,000 columns across your plot, so they will only get 1 or 2 pixels each even at a large resolution.

In case you still find this useful, you could do:

MEs_interest %>%
  as.data.frame() %>%
  rownames_to_column(var = "x") %>%
  pivot_longer(-1) %>%
  ggplot(aes(name, value, group = x, fill = name))  
  geom_col(position = "dodge")  
  scale_fill_identity()

enter image description here

A better way to represent such dense data would be with some kind of summary plot, such as a boxplot, or violin plot, or both:

MEs_interest %>%
  as.data.frame() %>%
  rownames_to_column(var = "x") %>%
  pivot_longer(-1) %>%
  ggplot(aes(name, value, fill = name))  
  geom_boxplot(fill = NA)  
  geom_violin(alpha = 0.5)  
  scale_fill_identity()  
  theme_light(base_size = 20)

enter image description here

  • Related