python matplotlib给出峰值位置值

时间:2013-05-16 13:26:31

标签: python matplotlib

我有两个来自脚本的数组。下面给出了两个数组 -

x = array([ 0.35970013,  0.36476619,  0.36983225,  0.3748983 ,  0.37996435,
    0.38503039,  0.39009642,  0.39516245,  0.40022847,  0.40529448,
    0.41036049,  0.4154265 ,  0.42049249,  0.42555848,  0.43062447,
    0.43569044,  0.44075641,  0.44582237,  0.45088833,  0.45595428,
    0.46102022,  0.46608615,  0.47115208,  0.476218  ,  0.48128391,
    0.48634982,  0.49141572,  0.49648161,  0.50154749,  0.50661336,
    0.51167923,  0.51674509,  0.52181094,  0.52687678,  0.53194261,
    0.53700844,  0.54207425,  0.54714006,  0.55220586,  0.55727165,
    0.56233744,  0.56740321,  0.57246897,  0.57753473,  0.58260048,
    0.58766622,  0.59273194,  0.59779766,  0.60286337,  0.60792907,
    0.61299477,  0.61806045,  0.62312612,  0.62819178,  0.63325743,
    0.63832308,  0.64338871,  0.64845433,  0.65351995,  0.65858555,
    0.66365114,  0.66871672,  0.67378229,  0.67884785,  0.6839134 ,
    0.68897894,  0.69404447,  0.69910999,  0.7041755 ,  0.70924099,
    0.71430648,  0.71937195,  0.72443741,  0.72950287,  0.73456831,
    0.73963373,  0.74469915,  0.74976456,  0.75482995,  0.75989533,
    0.7649607 ,  0.77002606,  0.77509141,  0.78015674,  0.78522206,
    0.79028737,  0.79535267,  0.80041795,  0.80548322,  0.81054848,
    0.81561373,  0.82067897,  0.82574419,  0.8308094 ,  0.83587459,
    0.84093977,  0.84600494,  0.8510701 ,  0.85613524,  0.86120037,
    0.86626549,  0.87133059,  0.87639568,  0.88146075,  0.88652582,
    0.89159086,  0.8966559 ,  0.90172092,  0.90678592,  0.91185092,
    0.91691589,  0.92198086,  0.9270458 ,  0.93211074,  0.93717566,
    0.94224056,  0.94730545,  0.95237033,  0.95743519,  0.96250004,
    0.96756487,  0.97262968,  0.97769448,  0.98275927,  0.98782404,
    0.99288879,  0.99795353,  1.00301826,  1.00808296,  1.01314766,
    1.01821233,  1.02327699,  1.02834164,  1.03340627,  1.03847088,
    1.04353547,  1.04860005,  1.05366462,  1.05872916,  1.06379369,
    1.06885821,  1.07392271,  1.07898719,  1.08405165,  1.0891161 ,
    1.09418053,  1.09924494,  1.10430933,  1.10937371,  1.11443807,
    1.11950242,  1.12456674,  1.12963105,  1.13469534,  1.13975962,
    1.14482387,  1.14988811,  1.15495233,  1.16001653,  1.16508071,
    1.17014488,  1.17520903,  1.18027315,  1.18533727,  1.19040136,
    1.19546543,  1.20052949,  1.20559352,  1.21065754,  1.21572154,
    1.22078552,  1.22584948,  1.23091342,  1.23597734,  1.24104124,
    1.24610512,  1.25116899,  1.25623283,  1.26129666,  1.26636046,
    1.27142425,  1.27648801,  1.28155176,  1.28661548,  1.29167919,
    1.29674288,  1.30180654,  1.30687019,  1.31193381,  1.31699741,
    1.322061  ,  1.32712456,  1.3321881 ,  1.33725162,  1.34231512,
    1.3473786 ,  1.35244206,  1.3575055 ,  1.36256892,  1.36763231,
    1.37269568,  1.37775904,  1.38282237,  1.38788568,  1.39294896,
    1.39801223,  1.40307547,  1.4081387 ,  1.4132019 ,  1.41826508,
    1.42332823,  1.42839137,  1.43345448,  1.43851757,  1.44358063,
    1.44864368,  1.4537067 ,  1.4587697 ,  1.46383267,  1.46889563,
    1.47395856,  1.47902147,  1.48408435,  1.48914721,  1.49421005,
    1.49927286,  1.50433566,  1.50939842,  1.51446117,  1.51952389,
    1.52458659,  1.52964926,  1.53471191,  1.53977454,  1.54483714,
    1.54989971,  1.55496227,  1.5600248 ,  1.5650873 ,  1.57014978,
    1.57521224,  1.58027467,  1.58533708,  1.59039946,  1.59546182,
    1.60052415,  1.60558646,  1.61064874,  1.61571099,  1.62077323,
    1.62583543,  1.63089761,  1.63595977,  1.6410219 ,  1.64608401,
    1.65114609,  1.65620814,  1.66127017,  1.66633217,  1.67139414,
    1.67645609,  1.68151802,  1.68657992,  1.69164179,  1.69670363,
    1.70176545,  1.70682724,  1.71188901,  1.71695074,  1.72201246,
    1.72707414,  1.7321358 ,  1.73719743,  1.74225903,  1.74732061,
    1.75238216,  1.75744368,  1.76250518,  1.76756664,  1.77262808,
    1.7776895 ,  1.78275088,  1.78781224,  1.79287357,  1.79793487,
    1.80299614,  1.80805738,  1.8131186 ,  1.81817979,  1.82324095,
    1.82830208,  1.83336318,  1.83842426,  1.8434853 ,  1.84854632,
    1.85360731,  1.85866827,  1.8637292 ,  1.8687901 ,  1.87385097,
    1.87891182,  1.88397263,  1.88903341,  1.89409417,  1.89915489,
    1.90421559,  1.90927626,  1.91433689,  1.9193975 ,  1.92445808,
    1.92951862,  1.93457914,  1.93963963,  1.94470008,  1.94976051,
    1.9548209 ,  1.95988127,  1.9649416 ,  1.97000191,  1.97506218,
    1.98012242,  1.98518264,  1.99024282,  1.99530297,  2.00036308,
    2.00542317,  2.01048323,  2.01554325,  2.02060325,  2.02566321,
    2.03072314,  2.03578304,  2.0408429 ,  2.04590274,  2.05096254,
    2.05602232,  2.06108205,  2.06614176,  2.07120144,  2.07626108,
    2.08132069,  2.08638027,  2.09143981,  2.09649933,  2.10155881,
    2.10661826,  2.11167767,  2.11673705,  2.1217964 ,  2.12685572,
    2.131915  ,  2.13697425,  2.14203347,  2.14709265,  2.1521518 ,
    2.15721091,  2.16227   ,  2.16732905,  2.17238806,  2.17744704,
    2.18250599,  2.1875649 ,  2.19262378,  2.19768263,  2.20274144,
    2.20780021,  2.21285896,  2.21791766,  2.22297634,  2.22803498,
    2.23309358,  2.23815215,  2.24321068,  2.24826918,  2.25332765,
    2.25838607,  2.26344447,  2.26850283,  2.27356115,  2.27861944,
    2.28367769,  2.28873591,  2.29379409,  2.29885224,  2.30391035,
    2.30896842,  2.31402646,  2.31908446,  2.32414242,  2.32920035,
    2.33425825,  2.3393161 ,  2.34437393,  2.34943171,  2.35448946,
    2.35954717,  2.36460484,  2.36966248,  2.37472008,  2.37977764,
    2.38483517,  2.38989266,  2.39495011,  2.40000753,  2.4050649 ,
    2.41012224,  2.41517955,  2.42023681,  2.42529404,  2.43035123,
    2.43540838,  2.44046549,  2.44552257,  2.45057961,  2.45563661,
    2.46069357,  2.46575049,  2.47080738,  2.47586422,  2.48092103,
    2.4859778 ,  2.49103453,  2.49609122,  2.50114787,  2.50620449,
    2.51126106,  2.5163176 ,  2.52137409,  2.52643055,  2.53148697,
    2.53654335,  2.54159969,  2.54665599,  2.55171225,  2.55676847,
    2.56182465,  2.56688079,  2.57193689,  2.57699295,  2.58204897,
    2.58710495,  2.59216089,  2.59721679,  2.60227265,  2.60732847,
    2.61238425,  2.61743999,  2.62249568,  2.62755134,  2.63260695,
    2.63766253,  2.64271806,  2.64777355,  2.65282901,  2.65788441,
    2.66293978,  2.66799511,  2.6730504 ,  2.67810564,  2.68316084,
    2.688216  ,  2.69327112,  2.6983262 ,  2.70338123,  2.70843623,
    2.71349118,  2.71854608,  2.72360095,  2.72865577,  2.73371056,
    2.73876529,  2.74381999,  2.74887464,  2.75392925,  2.75898382,
    2.76403835,  2.76909283,  2.77414727,  2.77920166,  2.78425602,
    2.78931033,  2.79436459,  2.79941881,  2.80447299,  2.80952713,
    2.81458122,  2.81963527,  2.82468927,  2.82974323,  2.83479715,
    2.83985102,  2.84490485,  2.84995863,  2.85501237,  2.86006607,
    2.86511972,  2.87017332,  2.87522688,  2.8802804 ,  2.88533387,
    2.8903873 ,  2.89544068,  2.90049402,  2.90554731,  2.91060056,
    2.91565376,  2.92070691,  2.92576002,  2.93081309,  2.93586611,
    2.94091908,  2.94597201,  2.95102489,  2.95607773,  2.96113052,
    2.96618327,  2.97123596,  2.97628862,  2.98134122,  2.98639378,
    2.9914463 ,  2.99649876,  3.00155118,  3.00660356,  3.01165588,
    3.01670816,  3.0217604 ,  3.02681258,  3.03186472,  3.03691681,
    3.04196886,  3.04702086,  3.05207281,  3.05712471,  3.06217657,
    3.06722837,  3.07228013,  3.07733185,  3.08238351,  3.08743513,
    3.0924867 ,  3.09753822,  3.10258969,  3.10764111,  3.11269249,
    3.11774382,  3.1227951 ,  3.12784633,  3.13289751,  3.13794864,
    3.14299973,  3.14805076,  3.15310175,  3.15815269,  3.16320358,
    3.16825442,  3.17330521,  3.17835595,  3.18340664,  3.18845728,
    3.19350787,  3.19855842,  3.20360891,  3.20865936,  3.21370975,
    3.21876009,  3.22381039,  3.22886063,  3.23391082,  3.23896097,
    3.24401106,  3.2490611 ,  3.2541111 ,  3.25916104,  3.26421093,
    3.26926077,  3.27431056,  3.2793603 ,  3.28440999,  3.28945962,
    3.29450921,  3.29955875,  3.30460823,  3.30965766,  3.31470704,
    3.31975637,  3.32480565,  3.32985488,  3.33490405,  3.33995317,
    3.34500224,  3.35005126,  3.35510023,  3.36014914,  3.36519801,
    3.37024682,  3.37529558,  3.38034428,  3.38539293,  3.39044154,
    3.39549008,  3.40053858,  3.40558702,  3.41063541,  3.41568375,
    3.42073203,  3.42578026,  3.43082844,  3.43587656,  3.44092463,
    3.44597265,  3.45102062,  3.45606853,  3.46111638,  3.46616419,
    3.47121194,  3.47625963,  3.48130727,  3.48635486,  3.49140239,
    3.49644987,  3.5014973 ,  3.50654467,  3.51159198,  3.51663925,
    3.52168645,  3.5267336 ,  3.5317807 ,  3.53682775,  3.54187473,
    3.54692167,  3.55196854,  3.55701537,  3.56206213,  3.56710885,
    3.5721555 ,  3.57720211,  3.58224865,  3.58729514,  3.59234158,
    3.59738796,  3.60243428,  3.60748055,  3.61252676,  3.61757292,
    3.62261901,  3.62766506,  3.63271104,  3.63775698,  3.64280285,
    3.64784867,  3.65289443,  3.65794013,  3.66298578,  3.66803137,
    3.67307691,  3.67812238,  3.6831678 ,  3.68821317,  3.69325847,
    3.69830372,  3.70334891,  3.70839404,  3.71343912,  3.71848414,
    3.7235291 ,  3.728574  ,  3.73361885,  3.73866364,  3.74370837,
    3.74875304,  3.75379765,  3.75884221,  3.7638867 ,  3.76893114,
    3.77397552,  3.77901984,  3.78406411,  3.78910831,  3.79415246,
    3.79919654,  3.80424057,  3.80928454,  3.81432845,  3.8193723 ,
    3.82441609,  3.82945982,  3.8345035 ,  3.83954711,  3.84459066,
    3.84963416,  3.85467759,  3.85972097,  3.86476428,  3.86980754,
    3.87485073,  3.87989387,  3.88493694,  3.88997996,  3.89502291,
    3.90006581,  3.90510864,  3.91015141,  3.91519413,  3.92023678,
    3.92527937,  3.9303219 ,  3.93536437,  3.94040678,  3.94544912,
    3.95049141,  3.95553364,  3.9605758 ,  3.9656179 ,  3.97065994,
    3.97570192,  3.98074384,  3.9857857 ,  3.99082749,  3.99586923,
    4.0009109 ,  4.0059525 ,  4.01099405,  4.01603554,  4.02107696,
    4.02611832,  4.03115962,  4.03620085,  4.04124203,  4.04628314,
    4.05132418,  4.05636517,  4.06140609,  4.06644695,  4.07148775,
    4.07652848,  4.08156915,  4.08660976,  4.0916503 ,  4.09669078,
    4.1017312 ,  4.10677155,  4.11181184,  4.11685207,  4.12189223,
    4.12693233,  4.13197236,  4.13701233,  4.14205224,  4.14709208,
    4.15213186,  4.15717157,  4.16221122,  4.16725081,  4.17229033,
    4.17732978,  4.18236917,  4.1874085 ,  4.19244776,  4.19748696,
    4.20252609,  4.20756516,  4.21260416,  4.2176431 ,  4.22268197,
    4.22772077,  4.23275952,  4.23779819,  4.2428368 ,  4.24787534,
    4.25291382,  4.25795223,  4.26299058,  4.26802886,  4.27306707,
    4.27810522,  4.2831433 ,  4.28818132,  4.29321927,  4.29825715,
    4.30329497,  4.30833272,  4.3133704 ,  4.31840802,  4.32344557,
    4.32848305,  4.33352047,  4.33855782,  4.3435951 ,  4.34863231,
    4.35366946,  4.35870654,  4.36374355,  4.3687805 ,  4.37381737,
    4.37885418,  4.38389093,  4.3889276 ,  4.39396421,  4.39900075,
    4.40403722,  4.40907362,  4.41410995,  4.41914622,  4.42418242,
    4.42921854,  4.43425461,  4.4392906 ,  4.44432652,  4.44936238,
    4.45439816,  4.45943388,  4.46446953,  4.4695051 ,  4.47454061,
    4.47957606,  4.48461143,  4.48964673,  4.49468196,  4.49971713,
    4.50475222,  4.50978724,  4.5148222 ,  4.51985708,  4.5248919 ,
    4.52992664,  4.53496132,  4.53999592,  4.54503046,  4.55006492,
    4.55509931,  4.56013364,  4.56516789,  4.57020207,  4.57523618,
    4.58027023,  4.5853042 ,  4.5903381 ,  4.59537192,  4.60040568,
    4.60543937,  4.61047298,  4.61550653,  4.62054   ,  4.6255734 ,
    4.63060673,  4.63563999,  4.64067318,  4.64570629,  4.65073934])


y = array([  1235.125     ,   1279.        ,   1226.42307692,   1243.38461538,
     1231.88461538,   1212.26923077,   1246.77777778,   1265.66666667,
     1233.07142857,   1212.89655172,   1222.28571429,   1230.78571429,
     1218.53571429,   1250.        ,   1270.86666667,   1240.7       ,
     1232.53333333,   1237.06666667,   1280.16129032,   1284.84848485,
     1259.71875   ,   1260.21875   ,   1254.93939394,   1292.90625   ,
     1320.87878788,   1338.94117647,   1359.91176471,   1401.61764706,
     1473.55882353,   1609.79411765,   1867.97142857,   2350.55555556,
     2672.69444444,   2859.51351351,   3121.08333333,   3142.51351351,
     3167.        ,   3371.28947368,   3591.10526316,   3850.71052632,
     4146.84210526,   4479.94871795,   4849.325     ,   5370.425     ,
     5960.4       ,   6383.4       ,   6526.525     ,   6826.53658537,
     7286.1627907 ,   6057.73809524,   4495.4047619 ,   3057.51162791,
     2650.34883721,   2122.31818182,   1865.72727273,   1697.47727273,
     1619.68181818,   1532.79545455,   1550.17777778,   1482.15217391,
     1443.97826087,   1402.52173913,   1381.7173913 ,   1345.41304348,
     1348.95744681,   1362.68085106,   1319.8125    ,   1326.8       ,
     1285.39583333,   1271.12244898,   1295.06122449,   1279.44897959,
     1253.98      ,   1241.08      ,   1224.78      ,   1206.6       ,
     1245.33333333,   1219.61538462,   1205.53846154,   1213.73584906,
     1176.86538462,   1175.74074074,   1190.58490566,   1167.31481481,
     1145.6       ,   1144.48148148,   1133.14814815,   1151.78181818,
     1143.90909091,   1125.30357143,   1113.05357143,   1124.07017544,
     1102.875     ,   1106.07017544,   1081.3220339 ,   1093.01724138,
     1086.96551724,   1084.46551724,   1070.43103448,   1086.33333333,
     1074.6       ,   1064.23333333,   1061.2295082 ,   1067.88333333,
     1081.77419355,   1076.95081967,   1058.85483871,   1058.77777778,
     1066.12903226,   1058.22580645,   1076.82539683,   1076.921875  ,
     1070.75      ,   1071.15625   ,   1082.765625  ,   1089.28125   ,
     1103.29230769,   1098.10606061,   1131.60294118,   1131.10606061,
     1134.25373134,   1179.25373134,   1197.94117647,   1211.63235294,
     1239.52941176,   1279.39705882,   1333.76470588,   1394.72058824,
     1485.38571429,   1597.81428571,   1772.87323944,   1990.07142857,
     2297.14084507,   2739.32857143,   3701.05555556,   5263.45833333,
     7445.34722222,   9988.61111111,  12308.80821918,  14355.02702703,
    16645.01369863,  18399.08108108,  20258.56578947,  22983.22972973,
    26834.24324324,  31780.61333333,  37120.09090909,  43428.60526316,
    47800.81578947,  49052.61038961,  52014.39473684,  56239.26923077,
    51390.08974359,  40128.32051282,  25536.18987342,  15170.30769231,
    10301.01265823,   6747.6835443 ,   4820.75308642,   3776.2625    ,
     3125.5       ,   2713.        ,   2433.37037037,   2166.93975904,
     2024.03571429,   1839.37804878,   1711.27710843,   1640.62195122,
     1578.01204819,   1514.45238095,   1448.39285714,   1390.6547619 ,
     1351.6547619 ,   1324.17647059,   1285.95294118,   1255.18604651,
     1246.51136364,   1195.45348837,   1163.70930233,   1149.65909091,
     1115.42222222,   1095.30681818,   1076.60227273,   1055.93181818,
     1033.80681818,   1017.75555556,    996.35555556,    983.48888889,
      962.28888889,    944.23076923,    930.14285714,    912.24175824,
      892.25531915,    875.55434783,    868.31521739,    846.58695652,
      836.47311828,    824.6344086 ,    814.75531915,    813.41489362,
      799.88421053,    726.39588198,    713.8469267 ,    703.04992072,
      691.98457674,    680.10919913,    673.6326038 ,    666.42559083,
      659.16221837,    661.85486338,    653.15733337,    645.55865728,
      648.8569043 ,    641.87927682,    648.47109253,    645.49435181,
      636.09032841,    656.00820221,    661.94923401,    674.25558834,
      685.32096893,    693.38880767,    711.46529833,    733.47792831,
      751.31502664,    777.92629564,    818.99787176,    890.85957613,
      954.53641627,   1096.29125105,   1203.90469099,   1309.64514509,
     1438.80368812,   1628.98611365,   1863.78800302,   2181.8515625 ,
     2658.4014402 ,   3359.96094663,   4368.18610749,   5403.19278598,
     6303.16474971,   7222.71911169,   8050.91538267,   8703.3873402 ,
     9446.67687218,  10525.85152699,  11531.13483665,  12512.6875    ,
    14126.15315315,  14916.11504425,  15388.52678571,  14986.30088496,
    13977.69911504,  12017.03571429,   9857.92035398,   7075.38596491,
     4684.64035088,   3138.87826087,   2247.16666667,   1746.45217391,
     1395.4122807 ,   1247.01694915,   1060.04273504,    978.88034188,
      907.17948718,    868.41025641,    843.41025641,    810.25423729,
      792.52542373,    774.05932203,    758.88983051,    748.16101695,
      741.33613445,    722.66942149,    721.47540984,    704.36363636,
      700.63333333,    682.10655738,    679.54918033,    668.86065574,
      658.8699187 ,    651.26229508,    639.87704918,    630.736     ,
      624.6       ,    622.04032258,    616.74193548,    618.02380952,
      619.21774194,    622.53174603,    626.61417323,    633.69047619,
      640.07086614,    657.88095238,    671.69047619,    692.07874016,
      714.29457364,    745.046875  ,    782.8984375 ,    823.52307692,
      875.48837209,    940.13740458,   1019.7480916 ,   1118.71538462,
     1243.89312977,   1480.76515152,   1660.48091603,   1695.22727273,
     1846.6641791 ,   2087.43939394,   2386.59398496,   2577.81203008,
     2857.45112782,   3624.42537313,   3940.57462687,   4091.42222222,
     4647.88059701,   5379.68382353,   6455.26277372,   8253.20588235,
     8841.60294118,   8340.16666667,   7807.29927007,   7560.83333333,
     6567.56115108,   4923.86956522,   2556.96376812,   1537.65942029,
     1235.5       ,   1102.69064748,   1031.68345324,    978.17730496,
      961.39285714,    963.1048951 ,    985.18571429,   1050.04964539,
     1203.77777778,   1395.11888112,   1681.47916667,   2046.16197183,
     2441.22535211,   2926.66666667,   3267.68275862,   3292.49655172,
     3821.75694444,   4163.2137931 ,   4583.14383562,   5125.49315068,
     5615.02739726,   5812.05442177,   5754.93835616,   5446.11643836,
     5050.37414966,   4514.35135135,   3932.95302013,   3077.58108108,
     2323.08108108,   1760.21192053,   1332.33333333,   1056.38815789,
      872.26490066,    759.80666667,    681.78289474,    619.74834437,
      582.33774834,    547.39473684,    518.51315789,    502.19078947,
      481.92156863,    470.70779221,    459.84415584,    446.56410256,
      438.44230769,    431.72727273,    424.01935484,    421.17197452,
      414.59615385,    413.41025641,    405.68589744,    404.17834395,
      402.03205128,    397.62658228,    396.2721519 ,    391.47169811,
      389.9245283 ,    384.48734177,    385.375     ,    382.38509317,
      379.05555556,    376.93125   ,    379.30434783,    373.94375   ,
      373.88888889,    372.2962963 ,    366.63190184,    368.59259259,
      367.19018405,    364.91411043,    368.43558282,    364.34146341,
      361.01219512,    361.51515152,    360.28313253,    361.78658537,
      361.47272727,    359.98809524,    357.23668639,    354.78313253,
      355.66666667,    356.54491018,    356.56886228,    357.388738  ,
      355.24436351,    354.40135906,    353.66823396,    352.09695108,
      351.51668935,    351.08681448,    352.57701235,    353.66455006,
      349.3038687 ,    350.86788447,    348.06043292,    349.94521442,
      347.63506569,    346.30903555,    348.14707308,    347.57515717,
      351.41311084,    348.30222355,    348.99481062,    350.67152379,
      347.70514143,    350.62315351,    351.39704145,    352.3644189 ,
      355.43859725,    362.61229607,    367.29164684,    370.6738583 ,
      373.11415854,    378.01654477,    382.76888578,    388.13758147,
      391.55278535,    392.5140042 ,    395.12058001,    397.95043996,
      399.14833696,    396.52425422,    392.97060336,    384.73643879,
      377.236749  ,    365.52103806,    353.71274354,    341.00996407,
      335.20592981,    330.47475704,    327.5923913 ,    326.69189189,
      321.7027027 ,    323.96236559,    322.39459459,    320.91397849,
      322.49197861,    324.22580645,    321.40425532,    320.1657754 ,
      323.59259259,    320.90526316,    320.94708995,    320.71428571,
      321.20744681,    321.85416667,    318.17460317,    319.84736842,
      318.93684211,    316.66842105,    318.84895833,    319.2617801 ,
      321.07253886,    318.37113402,    317.36787565,    317.58031088,
      317.86010363,    319.58461538,    316.44845361,    319.19387755,
      319.42564103,    322.29381443,    320.34693878,    318.7755102 ,
      315.60606061,    316.89340102,    317.94416244,    316.56122449,
      316.5959596 ,    317.2979798 ,    317.        ,    314.53      ,
      320.66834171,    318.        ,    317.01492537,    316.04926108,
      316.71641791,    315.485     ,    318.51741294,    318.92537313,
      316.39303483,    319.6039604 ,    317.45049505,    318.7970297 ,
      318.96551724,    319.46305419,    322.24271845,    322.31707317,
      326.78846154,    324.7254902 ,    323.17073171,    333.76442308,
      341.42995169,    358.11111111,    370.5776699 ,    387.68599034,
      401.94174757,    414.        ,    430.48803828,    435.21052632,
      427.17061611,    443.53588517,    469.05263158,    472.78571429,
      459.26066351,    455.56398104,    456.43127962,    459.0047619 ,
      462.12380952,    476.79245283,    502.09859155,    545.91588785,
      602.42990654,    661.64485981,    715.20560748,    769.06976744,
      815.        ,    863.53240741,    904.49302326,    956.31775701,
      988.21860465,    987.06451613,    968.70833333,    934.77625571,
      871.22222222,    793.8440367 ,    725.11415525,    641.88073394,
      562.09090909,    498.11415525,    455.25570776,    422.22727273,
      395.456621  ,    377.14545455,    363.16216216,    351.17488789,
      342.92272727,    337.87946429,    331.31390135,    329.61711712,
      325.2690583 ,    323.29464286,    318.5470852 ,    317.13839286,
      316.0619469 ,    314.24107143,    314.29777778,    313.92857143,
      311.39380531,    312.61504425,    309.71491228,    308.94273128,
      308.34070796,    308.39647577,    309.13656388,    305.80869565,
      307.31441048,    308.42358079,    309.45021645,    306.67982456,
      307.30434783,    305.81304348,    308.375     ,    307.74568966,
      308.17748918,    306.94347826,    309.05172414,    309.46753247,
      311.35470085,    310.44206009,    311.32905983,    312.50854701,
      310.25957447,    311.94092827,    312.2893617 ,    313.85470085,
      314.15677966,    312.18723404,    312.31914894,    314.88559322,
      313.91139241,    313.1440678 ,    312.65546218,    314.59414226,
      312.62869198,    315.27385892,    313.11618257,    313.21848739,
      311.78333333,    315.15      ,    314.9125    ,    313.93333333,
      315.56666667,    310.85833333,    314.95454545,    304.45901639,
      315.37084999,    315.96143404,    316.7021944 ,    318.50014328,
      319.95321505,    322.50028579,    323.87105554,    324.15103237,
      327.74601758,    334.20550962,    339.27812176,    348.02340083,
      358.41264695,    375.11453321,    397.47052334,    424.41021431,
      455.92610187,    486.79992737,    516.14219059,    543.36431231,
      569.13242656,    594.38432404,    614.36852574,    630.20933358,
      641.99241487,    644.60920454,    635.55871716,    594.48700851,
      585.04244486,    555.02574357,    520.70931512,    481.38397844,
      449.48096018,    421.1867297 ,    397.98770009,    380.57327294,
      368.66721086,    357.72837258,    350.69768042,    347.84715247,
      343.38971007,    343.59681541,    342.86784685,    339.71095223,
      344.41369021,    344.9653407 ,    348.93129771,    354.39382239,
      360.92664093,    368.03846154,    377.82239382,    389.13740458,
      401.83908046,    422.16153846,    438.65648855,    443.20769231,
      446.5210728 ,    467.62121212,    502.19847328,    523.64638783,
      548.12781955,    585.51526718,    600.7518797 ,    602.21969697,
      658.50566038,    739.70943396,    827.08679245,    782.89015152,
      678.06766917,    623.33458647,    555.67790262,    456.20074349,
      399.38059701,    355.60299625,    331.23333333,    321.27941176,
      315.21268657,    313.76492537,    312.79925651,    308.48708487,
      308.35555556,    305.49259259,    302.47426471,    304.97785978,
      302.01107011,    301.36764706,    297.55797101,    299.68978102,
      297.79487179,    298.72893773,    299.28832117,    296.36727273,
      298.44727273,    299.51824818,    298.49635036,    298.2173913 ,
      299.08727273,    300.06545455,    299.39928058,    301.36785714,
      300.82310469,    299.38129496,    299.74910394,    300.24548736,
      302.84587814,    304.41577061,    305.82733813,    306.38434164,
      306.67625899,    311.67730496,    315.25886525,    321.82978723,
      329.70714286,    340.27402135,    354.68439716,    370.36491228,
      391.04240283,    408.6819788 ,    428.64084507,    441.25704225,
      456.8415493 ,    469.90526316,    482.45296167,    490.74736842,
      494.48070175,    497.74385965,    493.03508772,    478.18466899,
      462.22569444,    448.04895105,    422.16955017,    401.84083045,
      379.0790378 ,    359.21799308,    342.94827586,    331.20819113,
      321.03472222,    314.32989691,    309.52758621,    306.03092784,
      300.93793103,    297.79037801,    294.71821306,    291.34246575,
      282.16271186,    278.19795222,    274.65306122,    273.87414966,
      271.00677966,    269.77210884,    267.56610169,    266.71283784,
      264.18707483,    263.3707483 ,    266.49491525,    267.66666667,
      269.97674419,    268.77027027,    268.09731544,    268.41471572,
      269.62541806,    270.00333333,    270.56856187,    268.39666667,
      268.23745819,    268.73      ,    270.6722408 ,    268.10631229,
      270.6986755 ,    268.71523179,    267.91089109,    268.08278146,
      269.78877888,    269.01315789,    266.45364238,    267.1986755 ,
      268.12171053,    268.13907285,    269.45874587,    272.16393443,
      273.61237785,    273.85294118,    274.41558442,    276.77124183,
      279.15533981,    282.10032362,    284.02922078,    286.44771242,
      285.5487013 ,    285.04220779,    287.81493506,    287.34415584,
      288.61165049,    291.19417476,    291.84565916,    293.24437299,
      293.66237942,    293.42307692,    297.39871383,    296.93910256,
      300.13694268,    302.68589744,    304.4778481 ,    308.38977636,
      316.17142857,    318.31948882,    324.2133758 ,    335.13607595,
      348.27707006,    363.88924051,    383.17515924,    394.2943038 ,
      419.5015873 ,    453.50314465,    499.46540881,    551.90851735,
      613.18181818,    679.85534591,    733.91900312,    786.64596273,
      846.70846395,    876.10031348,    803.84012539,    668.19375   ,
      499.56386293,    190.10280374])

然而,我还计算了每个峰的峰位置,这也是由两个阵列给出的 -

a =array([[ 0.39516245,  0.60286337,  1.12456674,  1.62583543,  1.98012242,
     2.12685572,  2.62755134,  3.13289751,  3.64280285,  3.84963416,
     4.14709208]])

b=array([[  1265.66666667,   7286.1627907 ,  56239.26923077,  15388.52678571,
      8841.60294118,   5812.05442177,    399.14833696,    988.21860465,
       644.60920454,    827.08679245,    497.74385965]])

现在我可以使用几行命令 -

简单地将标记放在每个峰的顶部
import numpy as np
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111)
ax.plot(x,y)
ax.plot(a, b,'D')
fig.show()

但我也计算了每个峰值位置应该从某个公式中显示的值。这就是以下数组 -

peak_position_value = array([[ 15.90025912,  10.42223758,   5.58720534,   3.86458874,
      3.17312972,   2.95421323,   2.39127023,   2.00555086,
      1.72482167,   1.63215128,   1.51508218]])

所以我想要的是将这个peak_position_values放在每个峰顶而不是钻石标记上。如果我使用注释,那么对所有峰值来说都会非常累人。有没有更简单的方法呢?

1 个答案:

答案 0 :(得分:0)

如果您想提供peak_position_value的视觉线索,可以用`ax.scatter'替换ax.plot(a, b,'D'),这样就可以为每个点提供颜色和/或大小。
/> 示例:

ax.scatter(a, b, s=3*peak_position_value)

每个点都是一个圆圈,其大小以像素值peak_position_value的3倍为单位。你可以用点颜色做类似的事情。

如果您想在图上显示值,我认为您必须使用ax.annotateax.text。以下是您可以在一行中执行的操作(但您必须摆脱[]ab中的peak_position_value之一

import itertools as it
texts = [ax.annotate('{0:.2f}'.format(s), [x,y], xytext=[x-0.2,y+1000]) 
    for x,y,s in it.izip(a,b,peak_position_value)]