R绘制ggplot中两个箱图中的一个

时间:2014-07-31 09:40:29

标签: r ggplot2 boxplot

我有一个数据框,其中一列代表模拟的每一步,我想绘制模拟的每两步......

示例:

a=structure(list(X.step. = c(0L, 0L, 0L, 0L, 0L, 0L, 0L, 0L, 1L, 
1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 3L, 
3L, 3L, 3L, 3L, 3L, 3L, 4L, 3L, 4L, 4L, 4L, 4L, 4L, 5L, 4L, 5L, 
5L, 4L, 5L, 5L, 6L, 5L, 5L, 6L, 6L, 6L, 7L, 6L, 5L, 6L, 6L, 7L, 
7L, 7L, 8L, 7L, 6L, 7L, 7L, 8L, 8L, 9L, 8L, 8L, 7L, 8L, 9L, 8L, 
9L, 9L, 9L, 8L, 9L, 9L, 9L, 0L, 1L, 0L, 2L, 0L, 3L, 1L, 0L, 4L, 
1L, 2L, 1L, 5L, 2L, 3L, 2L, 6L, 3L, 4L, 3L, 7L, 4L, 8L, 5L, 4L, 
9L, 5L, 0L, 6L, 5L, 6L, 6L, 7L, 1L, 7L, 7L, 8L, 2L, 8L, 8L, 9L, 
3L, 9L, 9L, 0L, 4L, 1L, 5L, 2L, 6L, 3L, 7L, 4L, 8L, 9L, 5L, 0L, 
6L, 1L, 7L, 2L, 8L, 3L, 9L, 4L, 5L, 0L, 6L, 1L, 7L, 2L, 8L, 3L, 
9L, 4L, 5L, 6L, 7L, 8L, 9L, 0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 
9L, 0L, 1L, 0L, 2L, 1L, 3L, 4L, 2L, 5L, 0L, 3L, 6L, 4L, 1L, 7L, 
5L, 2L, 8L, 6L, 3L, 9L, 7L, 4L, 8L, 5L, 9L, 6L, 7L, 8L, 9L, 0L, 
1L, 2L, 3L, 4L, 5L, 6L, 7L, 0L, 8L, 9L, 1L, 2L, 3L, 4L, 0L, 5L, 
1L, 6L, 2L, 7L, 3L, 8L, 4L, 9L, 5L, 6L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, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 0L, 1L, 2L, 3L, 4L, 
5L, 6L, 7L, 8L, 9L, 0L, 1L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 0L, 
1L, 0L, 2L, 1L, 3L, 2L, 3L, 4L, 4L, 5L, 5L, 6L, 6L, 7L, 7L, 8L, 
8L, 9L, 9L, 0L, 1L, 2L, 3L, 0L, 4L, 1L, 5L, 2L, 6L, 3L, 7L, 4L, 
8L, 5L, 9L, 6L, 7L, 8L, 9L), Capital_Hill = c(5000, 5000, 5000, 
5000, 5000, 5000, 5000, 5000, 20489.7098255422, 18647.9871601902, 
19322.3348318008, 19093.4975515191, 19964.7906013619, 18138.334932914, 
18798.2155161531, 19520.6592243171, 16189.1005720184, 7217.42311821296, 
10385.8517392027, 11587.4833706148, 8745.17771118928, 6364.6857034054, 
8960.36024556284, 10453.9730516154, 11279.5311553941, -1555.43893635276, 
5027.83508494888, -2683.23117756096, 1393.62412797987, 3950.66476922022, 
1177.9334196972, 9668.230146051, 4143.50230043012, -3428.49115061733, 
3872.28690850704, -4812.94494623542, -98.9684645837859, 1883.84198073663, 
11374.5541242187, 714.876295181919, 6221.52489447769, -151.630448506746, 
2888.96694320404, -1781.5636351967, 2106.10431875055, 15491.7176947478, 
4193.02022649885, 4024.29810085155, 5716.76355923053, 11450.8687665758, 
3655.45444702831, 20512.0032927283, 8105.64482179299, 5888.5563712437, 
8418.93101598735, 10166.9785794628, 13118.3548047528, 16715.3090616135, 
10388.5632777236, 26763.0262802347, 14014.2143953517, 10988.773662856, 
15568.4992097975, 17501.7723139078, 22016.7485548592, 23991.3958923051, 
35046.9986075527, 19215.4208912491, 23077.385542937, 18349.4581718549, 
22656.536484305, 29860.9195839098, 23441.0509825286, 32443.7854869624, 
27667.6776201081, 30759.139301094, 25395.7864401077, 31391.1613441541, 
31121.6329421095, 29918.393785456, 5000, 19516.6065775793, 5000, 
9419.32063654092, 5000, 2009.90741864572, 19555.8133004356, 5000, 
-654.02965741475, 19122.9111101632, 11184.8631976067, 17996.6740524179, 
1138.00811312575, 8495.38945039064, 5377.40673624512, 5798.37755337888, 
6508.39137319272, 2309.80804949953, 5453.31413281241, -2711.7378571935, 
13274.8481753427, 2512.54353681405, 20111.5278064519, 9502.77143878391, 
-5462.67280197028, 32565.500094441, 6393.00096339746, 5000, 14973.9608679735, 
-2543.16695364618, 12103.9409020041, 3311.37833549452, 20528.760260385, 
20773.7003425286, 16624.2861222331, 11126.45838254, 28608.1066784694, 
14995.9092263089, 20665.8793669486, 22356.2002525479, 34927.6906707312, 
9537.01445855963, 27949.3379086433, 29962.2664783985, 5000, 8500.45122044844, 
18461.6163874056, 11218.6215583133, 5755.75472677829, 17253.3643660214, 
-4184.18748661031, 24264.2528463904, -7303.94320803012, 31156.3108977128, 
36435.9814961802, -4524.19749453666, 5000, 1688.70739941494, 
20904.9967718526, 9521.71949378518, 17904.6695008067, 17902.2228871932, 
13609.3652797451, 28357.7085338908, 12707.1132235877, 14360.4841173028, 
5000, 18852.9443087615, 20509.6196388613, 24473.7959188055, 13665.3321023317, 
30446.0474400949, 8407.52096769587, 39122.0642115205, 9017.3276434745, 
12697.1620138356, 17646.7303301337, 22996.5955520881, 29146.5762917183, 
35634.6876170914, 5000, 20256.6563305109, 14002.5606956847, 7706.78971502452, 
7650.85410493198, 10585.5481304756, 15247.9120169065, 21228.0529500457, 
28067.5273136216, 33595.2410151807, 5000, 19771.90576498, 5000, 
11519.7862728797, 19287.2014227327, 5230.73409320381, 4098.65791804344, 
8860.11961674494, 6453.46467477849, 5000, 2815.88731781052, 11830.9940041421, 
1481.79046273321, 19719.5523891005, 17195.9681093997, 3493.6477870963, 
11904.4731232913, 24698.6417588021, 8303.69297814839, 4349.86800587358, 
33836.3219241388, 14450.3503670852, 2434.4539017217, 20670.5918746441, 
4588.70618802343, 28728.2181039865, 10165.9327278812, 17056.4749319925, 
23103.1740791684, 30191.0308235334, 5000, 17404.1622061253, 7844.82742537156, 
74.6251748716197, -2727.76784769199, -640.530575222837, 4693.89842856531, 
12065.0155109766, 5000, 21127.7345450589, 28075.0507306847, 16962.739743341, 
5674.35728893149, -4727.61808719137, -8457.81381625247, 5000, 
-6841.64259882885, 17308.5480856169, -460.354477345629, 6594.6017504895, 
7926.86615194192, -1536.84025803668, 17401.9649868518, -2911.75912386691, 
27335.0312567315, -483.614553655837, 4681.33507929712, 12338.2897168989, 
21893.3887182219, 5000, 28450.265783698, 17426.9268383773, 6132.91810130035, 
-1657.60327379152, -3145.89208808826, -677.764904032483, 5168.9071774366, 
12338.1054792169, 18357.5031623822, 26702.189691676, 5000, 17272.5985042244, 
6529.36007349031, -1483.18038982317, -3194.02246725017, -864.539225372793, 
4880.81380433676, 11503.0801744938, 18890.6443464088, 27380.1038151267, 
5000, 16566.4259172581, 4192.05365987776, -4147.32026509126, 
-6180.26521985924, -4328.90716305576, 2617.72939525306, 9810.50240434987, 
16146.8068923361, 24952.044957239, 5000, 16936.1791126631, 4620.54259091373, 
-5395.19541828241, -9160.14511554726, -7094.66028253679, 5000, 
-389.373479395586, 16709.9158206452, 9605.89586577239, 17698.1503683425, 
3392.49550994562, 29003.4431848308, -4975.25418720535, -7081.848544121, 
-5155.30766151213, 833.35566062533, 7825.317981083, 15649.5875640682, 
27510.5345766661, 5000, 17674.2304090849, 8362.60586718016, 1244.14138873582, 
-412.877365183411, 1593.70298089344, 6504.06893348446, 14139.3208140798, 
21158.4294479189, 31069.6504185086, 5000, 18118.8004619832, 5000, 
10335.4457087842, 17084.9827023801, 3611.71013801494, 6929.9946716569, 
2184.41908049661, -1536.15484963268, 4191.81308757483, -5155.56455029937, 
9267.92273531495, -3909.23691911105, 16068.8024043549, 1343.70607136169, 
21939.0298347732, 7629.67857173291, 30850.4636324382, 16888.1276401152, 
26850.8528990615, 5000, 18422.8617842306, 5000, 11607.1131114823, 
16628.9405255433, 5676.03414113105, 4814.00843290827, 3421.2056777451, 
6991.1111390283, -6190.83433612888, 11775.1207182955, -8778.54790419679, 
16763.5123210592, 22848.6440740326, -6489.45689126298, 30800.6637732523, 
-551.847581456661, 7279.45757506074, 16553.5581036666, 24409.386796622, 
5000, 17034.95391905, 5911.25895762224, -3398.72060945524, -5768.19233706395, 
-4229.26594477481, 950.591089955921, 7113.20257251212, 15169.824261434, 
22845.3082603497, 5000, 17891.8984213341, 8496.55048880409, 1825.0696233992, 
810.028458075569, 3664.46564696929, 9709.21329815228, 17181.6765053446, 
22541.7047456193, 30057.7224595685, 5000, 16700.9168772748, 5593.03555882925, 
-2028.86483622101, -3646.32279645239, -1390.78650754587, 3577.56347915891, 
10603.9041039838, 17054.8291388964, 26773.7977012179, 5000, 16911.2865317119, 
4351.23637322548, -4015.73034866028, -6232.44446398637, -3712.84274506375, 
5000, 2359.01911895682, 16271.017845393, 4051.80942790909, 8039.18908838504, 
-3610.89152153722, 16884.5029036251, -5676.15773655211, 25712.2367099925, 
-4665.32703289247, 412.058636915032, 6496.08536117356, 12056.8192481081, 
25196.0924424919, 5000, 5000, 17454.1772703328, 8784.9903045364, 
16988.3805436717, 1335.40690314268, 5602.61993021557, 33.5055585529097, 
-2752.26594141369, 2520.04689099037, -4055.48284139309, 7495.51047961483, 
-1815.14909163591, 13534.6185065575, 3103.40704263755, 20137.3308304375, 
8718.30106806019, 28860.9163843801, 13226.1318243537, 24435.473414727, 
5000, 14986.7334079756, 1963.39221417673, -6940.3422302652, -9813.92833778304, 
-7880.89152429566, -2511.70627165876, 4625.27308695974, 13963.5897385531, 
25573.7792637622, 5000, 14544.0594029155, 1288.5755470104, -8084.93019036526, 
-11010.6902443854, -10229.4751821274, -5698.06964960847, 313.772270393078, 
9143.73659148442, 5000, 20302.391059426, 15742.8926221643, 4785.77974475384, 
-3227.05858371389, -5963.33972439362, -3794.38377216149, 1743.03069812496, 
8236.30553623782, 18026.036903884, 28860.5795376896, 5000, 14063.4086450927, 
-100.982715766215, -10590.0647932601, -15364.77439809, -14794.3472963714, 
-10015.1083148604, -3488.57992395531, 8161.55971721804, 5000, 
18291.7427906892, 16016.2517314456, 7153.29022517982, -412.365245692974, 
-3676.77133255859, -2554.9191987889, 1686.46778305379, 7036.49053148479, 
15770.8403030132, 26816.3192030426, 5000, 15906.2432400211, 7051.67441999044, 
-331.3307031639, -3754.84464355008, -1842.66807512373, 3227.05908236969, 
9139.62986841704, 19304.0598981924, 27256.8698709522, 5000, 15029.5843404416, 
2072.10802012564, -7304.22739544598, -10871.623560221, -9351.91079687121, 
5000, -5171.31622384352, 15159.683395421, 3331.5498754522, 13170.5005332417, 
3439.19465496068, 24198.2911262617, -5110.78422514425, -7804.4774428497, 
-5286.78032597168, 598.077862841574, 8436.96826228419, 17198.7098708175, 
24298.5553779913, 5000, 14309.8331053745, 1187.21043394015, -9952.57083904184, 
-14619.5327439154, -13199.0421104398, -8319.63907272906, -1304.4230914884, 
5000, 7830.70031170482, 14202.2194212579, 17903.384502826, 1081.76102495543, 
-7991.80925287105, -10526.8865875028, -9045.63162101956, -3279.39975586326, 
5501.88648798074, 5000, 12875.6885153624, 22221.2837723756, 15576.9803361784, 
4068.25688407986, -4708.99256150513, -8143.14199133205, -6896.55918399797, 
-2126.50851131449, 5000, 5240.64004517348, 14270.8200003207, 
13852.1401402282, -43.0325928681349, 24717.1050645578, -9438.40619357209, 
-13048.8094569982, -12138.7875588, -7659.79060929531, -1865.33889993808, 
5697.82327541651, 18086.4511779268, 5000, 15597.3988001253, 5561.58301979492, 
-2869.06709333548, -6558.886699838, -5169.73695267938, -609.782078563235, 
5898.56506874382, 14533.9561760599, 25482.7350976753, 5000, 15478.4673313563, 
3977.87968483323, 5000, -5985.95325671427, 15928.4015865356, 
-10319.6145358865, -9649.23736134543, 5383.60374279049, -4647.06609976334, 
-2999.475898658, 2068.47353878321, -6359.12927662916, 10311.2253685776, 
-4693.84008808353, 25624.3550621041, 866.127801082878, 6646.1046514394, 
15431.0247384072, 24474.9603730814, 5000, 13788.5168543132, -1731.13227111806, 
-13000.2021399356, -17201.8194814945, -14884.8997553708, 5000, 
-8667.01989469544, 15377.1237562577, 681.163334032681, 3385.79944090265, 
11611.196820045, -4774.05117801588, 23388.6483093974, -6372.24086221351, 
-4842.14991237637, -743.021710592532, 5833.73755214678, 12121.1598384927, 
21003.4686145283, 5000, 15183.2494510295, 3030.07907708138, -5345.64249061941, 
5000, -9638.05284666594, 16259.0530459828, -7503.92337904484, 
-2226.27356766879, 7183.80537659084, 6455.8638736604, -727.603893341901, 
15671.3254651653, 24194.9838410333, -3835.34577700104, -2098.79256988853, 
3090.29391478019, 8349.55950088762, 5000, 15758.2877450559, 14831.1008157696, 
25658.9962972256, 1619.69881835626, -7338.88491608739, -9591.47146367816, 
-8056.12113669679, -3537.64482128395, 3608.27743432899, 12650.7747287784, 
22233.8478781338, 5000, 13656.7228400099, 2767.80445934938, -6464.6064825382, 
-11618.44866774, -10686.8447765554, -6408.30193258191, -656.056692611712, 
7422.09138358902, 18758.5390231977, 5000, 12045.3182515538, -3238.06323662127, 
-14529.8018209528, -19907.4191089837, 5000, -19596.7129005575, 
14036.9100757928, 5000, -14721.8012791421, 12262.9676244423, 
1531.66737285799, -7901.79936280156, -3377.97620455655, 3642.25418333018, 
-7688.5762733587, -15703.9233053286, 17896.7314709099, -12086.2394306819, 
-21366.6861860903, -19550.5471658072, -10930.6598354357, -14335.785648655, 
-6953.79895440406, -5638.00453480549, 5000, -1022.23761208204, 
5742.81522591873, 19206.177851139, 12966.6328737482, 8406.89466120168, 
22992.1412638757, -890.590811647627, 5000, -10209.6954754654, 
14198.0363268739, -13408.9055093147, 3311.06607469565, -11240.5141564193, 
-4982.80509003836, -5677.65928846774, -8537.90872063919, 239.368339089975, 
-7662.81690858933, 10870.7617155271, -3759.30275900418, 2137.10949487681, 
21894.9525188053, 10230.5461944614, 21411.337237788, 5000, 14444.0350550273, 
4085.90069428105, -3956.95641227277, -7228.09255993674, -6408.05443330535, 
-1662.86950264845, 3677.15684754642, 10987.2293560531, 26201.061383872, 
5000, 14132.1623660416, 2452.11969479981, 5000, -6419.34884964518, 
13339.037416801, -9679.11323286981, 1701.08965209899, -7688.63040563892, 
-6668.2112876282, -2637.90495826064, -10255.5272055761, 4121.53046989451, 
-8953.31028526848, 11672.7530526242, -4161.10828333163, 22633.811911816, 
3899.19850653915, 15007.7744059724, 24734.1406065828, 5000, 12957.3115035238, 
963.37530458605, -8748.01332933451, -14070.4311109678, -13305.5153397646, 
-9370.54481768519, -2713.52819026998, 4700.45264800112, 18989.7782208074, 
5000, 13831.1366196626, 3100.62419650784, -5560.28627457043, 
-10659.3847737832, -10115.9483516372, -6719.73751646479, 210.907035545652, 
8766.64371047473, 22728.7122095054, 5000, 14068.7516556478, 5000, 
4248.05972179484, 13730.5311825625, -4651.10047543076, 2352.68146532249, 
-8864.37239235438, -6894.9434564091, -7914.96987260992, -10216.8673509, 
-4265.65281819671, -8775.06152341994, 1692.25460254636, -4864.01572396864, 
8308.54713764326, 2162.2700849006, 5000, 12550.1422521467, 20252.8345828119, 
22046.5143486693, 13076.10079209, 937.911249849849, -9214.77667227172, 
-13891.5116708039, -14136.7244345747, -9172.12250534603, -1989.74817887114, 
8432.46290922688, 18198.1439142516, 5000, 13529.3507529325, 2310.18240608432, 
-6587.85467295302, -12818.269206701, -13793.0733730659, -11039.6671601434, 
-6094.42722393382, 2363.21004375095, 19099.9588641697, 5000, 
14641.6455314441, 4356.86495579032, -1857.30379616527, -4244.93149818869, 
-1658.49424482194, 2038.62751396238, 7829.64215748805, 15612.6406037798, 
27242.3414197319, 5000, 12162.7507375623, 5000, -4148.91498711172, 
13878.2672609748, -15627.579139639, 3208.45729652955, -4802.01693732884, 
-20847.4443779113, -9512.96458243355, -19903.2544900721, -8968.19456605297, 
-14406.5410093107, -5485.47742038541, -5045.37019118937, -68.4578150428043, 
7356.83893632626, 6383.03787944455, 21847.3638112322, 19870.7035779682, 
5000, 13736.5911223728, 2869.92185252125, -5771.37528666368, 
5000, -10918.2475177203, 13472.3453265585, -10400.0650356682, 
2002.98623683971, -5981.51750003995, -5909.22408630736, 1847.38058899047, 
-10532.5364262191, 11578.8235254648, -9519.73017000659, 23892.4653461474, 
-5204.62655234631, 941.854354261729, 9086.57931837106, 21854.0378117816
)), .Names = c("X.step.", "Capital_Hill"), row.names = c(1L, 
2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 12L, 13L, 14L, 15L, 
16L, 17L, 18L, 19L, 20L, 21L, 22L, 23L, 24L, 25L, 26L, 27L, 28L, 
29L, 30L, 31L, 32L, 33L, 34L, 35L, 36L, 37L, 38L, 39L, 40L, 41L, 
42L, 43L, 44L, 45L, 46L, 47L, 48L, 49L, 50L, 51L, 52L, 53L, 54L, 
55L, 56L, 57L, 58L, 59L, 60L, 61L, 62L, 63L, 64L, 65L, 66L, 67L, 
68L, 69L, 70L, 71L, 72L, 73L, 74L, 76L, 77L, 79L, 80L, 82L, 89L, 
741L, 748L, 752L, 757L, 761L, 765L, 766L, 769L, 770L, 773L, 775L, 
777L, 778L, 780L, 784L, 785L, 786L, 789L, 790L, 793L, 794L, 797L, 
798L, 799L, 800L, 804L, 806L, 807L, 808L, 809L, 814L, 815L, 816L, 
817L, 822L, 823L, 824L, 825L, 829L, 830L, 832L, 834L, 837L, 838L, 
840L, 843L, 850L, 852L, 858L, 861L, 867L, 869L, 876L, 877L, 885L, 
886L, 891L, 895L, 900L, 903L, 909L, 911L, 917L, 919L, 925L, 933L, 
936L, 942L, 946L, 950L, 955L, 959L, 964L, 968L, 974L, 983L, 990L, 
999L, 1006L, 1015L, 1415L, 1423L, 1431L, 1439L, 1443L, 1449L, 
1456L, 1463L, 1468L, 1476L, 1512L, 1520L, 1526L, 1529L, 1536L, 
1537L, 1542L, 1545L, 1549L, 1552L, 1553L, 1558L, 1560L, 1564L, 
1566L, 1568L, 1572L, 1574L, 1576L, 1579L, 1583L, 1584L, 1586L, 
1592L, 1595L, 1600L, 1602L, 1610L, 1618L, 1626L, 1663L, 1671L, 
1680L, 1689L, 1697L, 1704L, 1713L, 1721L, 1728L, 1730L, 1736L, 
1738L, 1748L, 1756L, 1766L, 1768L, 1775L, 1777L, 1784L, 1785L, 
1792L, 1794L, 1801L, 1802L, 1809L, 1811L, 1820L, 1828L, 1837L, 
1841L, 1846L, 1852L, 1862L, 1871L, 1880L, 1889L, 1897L, 1906L, 
1914L, 1921L, 2077L, 2085L, 2091L, 2097L, 2104L, 2112L, 2119L, 
2123L, 2130L, 2138L, 2260L, 2268L, 2277L, 2286L, 2293L, 2300L, 
2309L, 2317L, 2324L, 2330L, 2336L, 2344L, 2352L, 2361L, 2369L, 
2377L, 2383L, 2385L, 2391L, 2393L, 2399L, 2401L, 2407L, 2410L, 
2418L, 2426L, 2434L, 2442L, 2449L, 2457L, 2500L, 2509L, 2518L, 
2526L, 2536L, 2544L, 2553L, 2562L, 2570L, 2578L, 2610L, 2620L, 
2627L, 2630L, 2636L, 2640L, 2646L, 2648L, 2655L, 2657L, 2664L, 
2665L, 2672L, 2673L, 2680L, 2684L, 2688L, 2692L, 2696L, 2705L, 
2729L, 2734L, 2738L, 2743L, 2749L, 2751L, 2757L, 2758L, 2764L, 
2766L, 2771L, 2774L, 2778L, 2783L, 2785L, 2789L, 2792L, 2801L, 
2809L, 2818L, 3020L, 3028L, 3037L, 3046L, 3054L, 3062L, 3069L, 
3077L, 3084L, 3091L, 3098L, 3107L, 3116L, 3124L, 3132L, 3138L, 
3146L, 3152L, 3159L, 3168L, 3172L, 3180L, 3189L, 3197L, 3205L, 
3213L, 3221L, 3229L, 3236L, 3243L, 3371L, 3379L, 3390L, 3398L, 
3406L, 3414L, 3416L, 3423L, 3424L, 3431L, 3432L, 3438L, 3440L, 
3445L, 3447L, 3450L, 3458L, 3464L, 3471L, 3476L, 3497L, 3507L, 
3508L, 3516L, 3517L, 3525L, 3526L, 3533L, 3536L, 3542L, 3544L, 
3549L, 3553L, 3557L, 3562L, 3565L, 3571L, 3573L, 3579L, 3587L, 
3634L, 3644L, 3654L, 3662L, 3672L, 3681L, 3690L, 3699L, 3706L, 
3715L, 3817L, 3827L, 3835L, 3843L, 3852L, 3858L, 3866L, 3874L, 
3879L, 3885L, 3889L, 3893L, 3902L, 3910L, 3919L, 3928L, 3935L, 
3940L, 3947L, 3955L, 3981L, 3990L, 3999L, 4008L, 4018L, 4027L, 
4034L, 4042L, 4050L, 4052L, 4057L, 4060L, 4066L, 4072L, 4080L, 
4086L, 4092L, 4099L, 4105L, 4111L, 4223L, 4231L, 4241L, 4249L, 
4257L, 4268L, 4276L, 4284L, 4292L, 4301L, 4343L, 4355L, 4363L, 
4371L, 4380L, 4387L, 4395L, 4396L, 4403L, 4405L, 4413L, 4414L, 
4421L, 4424L, 4433L, 4441L, 4449L, 4458L, 4467L, 4475L, 4525L, 
4536L, 4548L, 4556L, 4565L, 4573L, 4583L, 4593L, 4599L, 4602L, 
4609L, 4610L, 4617L, 4624L, 4632L, 4641L, 4649L, 4656L, 4660L, 
4663L, 4669L, 4670L, 4678L, 4687L, 4695L, 4703L, 4711L, 4715L, 
4719L, 4723L, 4726L, 4730L, 4733L, 4736L, 4744L, 4750L, 4756L, 
4762L, 4769L, 4777L, 4805L, 4813L, 4821L, 4831L, 4840L, 4848L, 
4856L, 4862L, 4869L, 4877L, 5129L, 5139L, 5149L, 5157L, 5159L, 
5167L, 5168L, 5175L, 5177L, 5184L, 5187L, 5193L, 5195L, 5201L, 
5203L, 5209L, 5213L, 5221L, 5229L, 5237L, 5267L, 5278L, 5289L, 
5298L, 5307L, 5314L, 5317L, 5323L, 5327L, 5331L, 5335L, 5340L, 
5343L, 5347L, 5352L, 5360L, 5368L, 5375L, 5381L, 5389L, 5393L, 
5400L, 5408L, 5415L, 5417L, 5420L, 5426L, 5427L, 5434L, 5435L, 
5440L, 5446L, 5447L, 5453L, 5455L, 5464L, 5474L, 5483L, 5491L, 
5493L, 5500L, 5502L, 5508L, 5516L, 5524L, 5531L, 5540L, 5547L, 
5554L, 5562L, 5597L, 5608L, 5617L, 5626L, 5634L, 5641L, 5649L, 
5657L, 5665L, 5673L, 5989L, 6000L, 6010L, 6018L, 6026L, 6030L, 
6035L, 6040L, 6043L, 6044L, 6050L, 6051L, 6052L, 6057L, 6059L, 
6060L, 6062L, 6067L, 6068L, 6070L, 6077L, 6078L, 6083L, 6086L, 
6089L, 6092L, 6095L, 6096L, 6101L, 6102L, 6103L, 6110L, 6111L, 
6115L, 6121L, 6125L, 6131L, 6134L, 6141L, 6142L, 6149L, 6150L, 
6157L, 6159L, 6166L, 6167L, 6174L, 6175L, 6181L, 6187L, 6273L, 
6282L, 6291L, 6299L, 6307L, 6314L, 6323L, 6331L, 6337L, 6345L, 
6384L, 6394L, 6405L, 6414L, 6415L, 6423L, 6425L, 6432L, 6434L, 
6441L, 6444L, 6450L, 6452L, 6459L, 6461L, 6466L, 6470L, 6474L, 
6481L, 6489L, 6669L, 6676L, 6684L, 6692L, 6699L, 6706L, 6711L, 
6717L, 6723L, 6731L, 6792L, 6801L, 6812L, 6821L, 6829L, 6837L, 
6845L, 6853L, 6861L, 6869L, 6891L, 6901L, 6906L, 6912L, 6915L, 
6921L, 6923L, 6929L, 6931L, 6937L, 6938L, 6945L, 6947L, 6953L, 
6956L, 6962L, 6963L, 6968L, 6970L, 6972L, 6976L, 6981L, 6990L, 
6999L, 7010L, 7018L, 7025L, 7034L, 7041L, 7049L, 7096L, 7104L, 
7113L, 7121L, 7130L, 7138L, 7144L, 7153L, 7161L, 7167L, 7190L, 
7199L, 7208L, 7217L, 7226L, 7234L, 7242L, 7251L, 7257L, 7265L, 
7318L, 7328L, 7335L, 7339L, 7342L, 7348L, 7350L, 7356L, 7357L, 
7363L, 7365L, 7371L, 7373L, 7377L, 7382L, 7383L, 7388L, 7392L, 
7395L, 7398L, 7641L, 7650L, 7660L, 7669L, 7670L, 7677L, 7680L, 
7686L, 7688L, 7694L, 7696L, 7702L, 7704L, 7710L, 7712L, 7718L, 
7720L, 7728L, 7735L, 7743L), class = "data.frame")

如果我描绘:

library(ggplot2)
bp_capital_lt<-ggplot(data=a)+
  geom_boxplot(aes(as.factor(X.step.),Capital_Hill))+
  labs(list(x = "itérations", y = "capital"))
bp_capital_lt

我可以这样:

enter image description here

但我想在x轴上只有0 2 4 6 8 ...

我尝试了类似

的内容
sel<-a$X.step.==seq(2,10,by=2)
bp_capital_lt<-ggplot(data=a[sel,])+
  geom_boxplot(aes(as.factor(X.step.),Capital_Hill))+
  labs(list(x = "itérations", y = "capital"))
bp_capital_lt

但它不像我期望的那样工作!怎么了?我该怎么办?

谢谢

电子

1 个答案:

答案 0 :(得分:2)

您可以创建数据的子集,其中X.step.的所有值都可以被2整除。

a2 <- subset(a, ! X.step. %% 2)

此子集可用于绘图。

library(ggplot2)
ggplot(data = a2) +
  geom_boxplot(aes(as.factor(X.step.), Capital_Hill)) +
  labs(list(x = "itérations", y = "capital"))

enter image description here