如您所见,我的图例太大了,如果不覆盖实际图,就无法放置它。我已经缩小了字体大小。我希望在图例中添加换行符,以便看起来像这样:
02/01/08; 02/08/08
02/04/08; 02/11/08
02/05/08; 02/12/08
02/06/08; 02/13/08
02/07/08; 02/14/08
以下是 tikzplotlib 生成的代码:
% This file was created by tikzplotlib v0.9.2.
\begin{tikzpicture}
\definecolor{color0}{rgb}{0,0.75,0.75}
\begin{axis}[
axis line style={white!80!black},
height=250,
legend cell align={left},
legend style={fill opacity=0.8, draw opacity=1, text opacity=1, at={(0.97,0.03)}, anchor=south east, draw=none, font=\footnotesize},
tick align=outside,
tick pos=left,
width=383.69687,
x grid style={white!80!black},
xlabel={Time to Maturity in Days},
xmajorgrids,
xmin=-10, xmax=260,
xtick style={color=white!15!black},
y grid style={white!80!black},
ylabel={Interest Rates},
ymajorgrids,
ymin=-0.152018231009253, ymax=0.128738417906447,
ytick style={color=white!15!black},
ytick={-0.35,-0.3,-0.25,-0.2,-0.15,-0.1,-0.05,0,0.05,0.1,0.15},
yticklabels={−0.35,−0.30,−0.25,−0.20,−0.15,−0.10,−0.05,0.00,0.05,0.10,0.15}
]
\addplot [only marks, mark=o, draw=black, colormap/blackwhite]
table{%
x y
14 0.0137210894408035
14 0.0109288520715931
14 0.00704837479115305
14 0.0107904836180531
14 0.0123093541624417
14 0.00984002106743629
14 0.0132617068955713
14 0.0121610141911937
14 0.0118155552921216
14 0.0103915012330393
14 0.00758642487543226
14 0.00769481832497766
14 0.00997124637229361
14 0.0113094211296513
14 0.00939919165301169
48 0.0337101304126796
48 0.0332856787869166
48 0.0333505600734723
48 0.0318827199165808
48 0.0330450310724984
48 0.0322558551168201
48 0.0312935396126879
48 0.0320718064184453
48 0.0331996345790628
48 0.032583357737266
48 0.0317205947107256
48 0.0323638954664098
48 0.0327242387967672
48 0.0319010764844046
48 0.0328866134471117
48 0.0324107253616829
48 0.0324350646971547
77 0.0217807310981179
77 0.0219879496597338
77 0.0212243166398681
77 0.0214441188035296
77 0.0221899964554677
77 0.0208713509142476
140 -0.030858668114083
140 -0.0418287612283958
140 -0.0363924220137762
140 -0.0375311765556639
140 -0.0407810517943131
140 -0.0335245303566455
140 -0.035477903505249
140 -0.029183364178868
140 -0.0275244156599502
140 -0.0384960165950047
140 -0.0260532548376415
140 -0.0345859398371634
140 -0.0396922149627387
140 -0.0326145415438095
231 -0.0127759331625157
322 -0.00217857904281886
322 -0.00320971763326099
322 0.000272306639956942
322 -0.00377379633374709
322 -0.000695298524775345
322 -0.00271616931153243
322 -0.00491580884429343
322 -0.0101741044338815
322 -0.00614886577381889
322 -0.00165385558464088
504 -0.0224483091899071
504 -0.0123523054791817
504 -0.0111061709726516
686 -0.0110528747125295
686 0.000193864477039207
686 -0.00259534166334822
868 -0.00881377121720931
1050 -0.00348403656897434
1050 -0.00147380403107435
1414 -0.00480567226583495
1785 -0.00400120265642571
1785 1.73519679824097e-05
1785 -0.00760830760980281
2513 0.00101016343405089
3241 0.00198725571533959
};
\addlegendentry{IR on 02/01/08}
\addplot [only marks, mark=square, draw=red, colormap/blackwhite]
table{%
x y
11 0.00782074196830399
11 0.00567981101219131
11 0.00648082748710704
11 0.00485716551556713
11 0.00639665280536967
11 0.00707721310262872
11 0.0104930385205962
11 0.00914193943066978
11 0.00844169624457877
11 0.00716795637802111
11 0.00323320144804443
11 0.00854592810185749
45 0.0329036352830745
45 0.0338581792508533
45 0.0331078258109704
45 0.0334970630169385
45 0.033310696925052
45 0.0339880160702749
45 0.033828539239924
45 0.0338431828032519
45 0.0331145267047949
45 0.0324626748265784
45 0.0324587920254657
45 0.033485969955202
45 0.0326870497849932
45 0.0314250211527437
45 0.0333016823215926
74 0.0208168368768059
74 0.02144425966603
74 0.0226935318502737
74 0.0219121966462829
74 0.0224809881807469
74 0.0216812611749553
74 0.0222630731418938
137 -0.0301234137595977
137 -0.0519189526824219
137 -0.0491722603853324
137 -0.0318423719785866
137 -0.0406946609065207
137 -0.0396091163230254
137 -0.0355343910796541
137 -0.028481557591816
137 -0.038551343472451
137 -0.0374527436377718
137 -0.0418090855814953
228 -0.00840935480260763
319 -0.00357174179868151
319 -0.000535274276070646
319 -0.00253851238316985
319 -0.00474855597446069
319 -0.00726251781225182
683 -0.00240078906176454
683 -0.00342885761537241
1047 -0.0033158023302484
1782 6.00496720099665e-05
};
\addlegendentry{IR on 02/04/08}
\addplot [only marks, mark=pentagon, draw=blue, colormap/blackwhite]
table{%
x y
10 -0.000714835653361301
10 0.00102074567563072
10 0.00182939690090909
10 -0.00839634706540728
10 -0.00474857161683182
10 -0.00711098196202871
10 -0.000723660697638738
10 -0.00581621038817418
10 0.00103275461771234
10 0.00260212476519968
10 -0.0151100594961445
10 -0.00164767661148638
10 -0.006913473339844
10 -0.00361303069988589
10 -0.00259506111253902
10 -0.00262832993223295
10 0.000173606411740977
10 0.000175698060277621
10 0.00263136317314788
10 -0.00468526138094617
10 -0.0046236170986705
44 0.0306022551558512
44 0.0305637095373249
44 0.0319542657196389
44 0.0321860610255907
44 0.0324177974678948
44 0.0309018709758541
44 0.0314305661212422
44 0.0328196678202748
44 0.0314550362288093
44 0.0324070811702585
44 0.0311857274974459
44 0.0319196390499927
44 0.0326180604231787
44 0.0308684844316522
44 0.029216672351097
44 0.0321721657392433
44 0.0323961127387396
44 0.0319371661116744
44 0.027435547813034
44 0.0305240628017564
44 0.0311570149546782
44 0.029594535681857
44 0.0314788869092557
73 0.0184216023444508
73 0.0182671647487676
73 0.0178402561489673
73 0.0188301581506017
136 -0.0352271634851356
136 -0.0325224395924161
136 -0.0316617466785742
136 -0.0481444639230842
136 -0.0361720764624926
136 -0.0494300387567915
136 -0.0469674730288904
136 -0.0521902760627065
136 -0.0579715334752782
136 -0.0611790663523092
136 -0.0291929003049157
136 -0.0434101684491255
136 -0.0457497473885284
136 -0.0445644041472061
136 -0.0411902463259865
136 -0.0343044283068829
136 -0.0308203489294541
136 -0.0380653794091772
136 -0.0422858314966319
136 -0.0401223239032175
136 -0.0391481774804271
227 -0.0128393907105629
227 -0.0204523725356663
227 -0.0156987806158955
227 -0.0172422880119309
227 -0.00799786060332961
227 -0.0141920811884485
318 -0.0116801807442
318 -0.00106481994978654
318 0.00835815670056705
318 -0.00577907019235087
318 -0.0075898341489207
318 -0.00302218951087784
318 0.00317424441681439
318 -0.0184128372115965
318 -0.00153719612682391
318 -0.00464685106531441
318 -0.00520584201654607
318 0.0015823638792305
318 -0.000151725667727796
318 -0.00199326291372055
318 -0.00693996416694488
318 0.00595155596729646
318 -0.0102404786363387
318 -0.00884737897945365
318 -0.00410157336794007
318 -0.00639720710302733
318 0.000747056830049463
500 -0.00653733543474732
500 -0.00292630543511468
500 -0.00463189511430381
500 -0.0133212535195125
682 0.00172966445721909
682 -0.00676294171327189
682 -0.00452711317176547
682 0.000952016436745645
682 -0.000710576972017227
682 -0.00160057556328214
682 0.00517561127990313
682 -0.00404104392803875
682 -0.00349885026320383
682 -0.0151228863941521
682 0.0103592104317332
682 -0.00565176314933779
682 0.000556385624457466
682 0.000139406932721454
1046 -0.0105663845423541
1046 -0.00249455012074208
1046 -0.00347034048002549
1046 -0.00155633021213025
1046 0.000984929890387255
1046 -0.000670024715222342
1046 0.000192799207530437
1046 0.00138408933992296
1046 0.00253088349809061
1046 0.00179056115295174
1410 0.00256127065174039
1410 0.00328941182006974
1410 0.00100783091829495
1410 0.00180144934950054
1410 -0.00256096115226277
1410 -0.00161980402063054
1781 -0.00165250474576583
1781 0.002627076791482
1781 0.00337728779894552
1781 0.00408274850154402
1781 -0.0047522162384001
1781 0.00184900497392481
1781 -0.000714331490431584
2145 -0.00101704149636732
2509 0.0051601282356082
2509 0.00447608932543323
2509 0.000467764487790179
2873 0.0042393862832291
2873 0.000104350785904197
2873 0.00567003224223027
3237 0.00613919060589857
3237 0.0054517462350804
};
\addlegendentry{IR on 02/05/08}
\addplot [only marks, mark=diamond, draw=green!50!black, colormap/blackwhite]
table{%
x y
9 0.0451055505633164
9 0.04377418147123
9 0.044366267853128
9 0.0452355148018427
9 0.0431177182249171
9 0.044268150085363
9 0.0438468235381798
9 0.0449828069416397
9 0.0443690943903199
9 0.0447567012399299
9 0.0440028698985414
9 0.0437048043374142
9 0.0433367049949423
9 0.0445532071832386
9 0.0440868191375866
9 0.0448666984513006
9 0.0436084779803162
9 0.0444699136395687
43 0.0426218687631648
43 0.0425270048931812
43 0.042485845332956
43 0.0423378749389722
43 0.0427312888258755
43 0.0424259340259502
43 0.042736899944459
43 0.0450594587783314
43 0.0417808153170019
43 0.0428601362888359
43 0.0425005612624512
43 0.0424202446590423
43 0.0428547127445074
43 0.042513041880823
43 0.0426207656350751
43 0.0426183804937492
43 0.0425237605441487
43 0.0427330594451176
43 0.0424365541876866
43 0.0426196044477669
43 0.0425167912059655
72 0.023934023529251
72 0.0248566227791727
72 0.0242951401045801
72 0.02451235793668
135 -0.0488516860045501
135 -0.0427566768382227
135 -0.0416783145108086
135 -0.0373633126700585
135 -0.0334633824318098
135 -0.0283914960967466
135 -0.0299837346834408
135 -0.0440127428150731
135 -0.0404858507825355
135 -0.0464022385665871
135 -0.0394648951369009
135 -0.0353652992486614
135 -0.0383312318966557
226 -0.0134199795961423
226 -0.014865743300317
317 -0.00296259780822939
317 -0.00526783705048569
317 -0.00143024887978371
317 -0.00188045742297925
317 -0.00350939975282413
317 -0.0121741183596542
317 0.000961619020900178
317 -0.214857446560731
317 -0.00410059828441776
317 4.9450644374173e-05
317 -0.00467658355540114
317 -0.0156040297942899
317 0.00183299797908983
499 -0.0134996600745704
681 -0.00490558551519492
681 -0.00187532870339388
681 0.0108901530581598
863 -0.00889283585934299
1045 -0.00362686739069732
1409 -0.00273840365415771
1409 0.00401921506410618
1409 -0.00377321887037695
1780 -0.00100507398013182
1780 -0.00197002868049126
};
\addlegendentry{IR on 02/06/08}
\addplot [only marks, mark=None, draw=color0, colormap/blackwhite]
table{%
x y
8 0.041416476609293
8 0.040945537817464
8 0.0413865212181352
8 0.0410725668825453
8 0.0405389205263706
8 0.0406714187018807
8 0.0411930819626443
8 0.0403993561964818
8 0.0408114519647437
8 0.0409172597066841
8 0.0413075715827805
8 0.0415066901094974
42 0.0416822253271051
42 0.0416458939947301
42 0.0417190422900645
42 0.0417589275088041
42 0.0416164811372735
42 0.0415966839665266
42 0.0415112997327311
42 0.0416296395086009
42 0.0415595032406281
42 0.0415661399168651
42 0.0417699894139058
42 0.0415742115569374
42 0.0415132819484212
42 0.0414608544867393
42 0.0415842399686537
42 0.0416085382845583
42 0.0414254153653741
42 0.0414319400082946
71 0.0229905756504236
71 0.0234619267366171
71 0.0227454901172336
71 0.0244620912040126
71 0.0219694627928467
71 0.0212673343601604
71 0.0224937927790998
134 -0.0420747989305961
134 -0.04548333346951
134 -0.0409734620920738
134 -0.0546476483528862
134 -0.037966898829209
134 -0.0479635171869633
134 -0.051873794077114
134 -0.0324492337451637
134 -0.0467064832919963
134 -0.0442927157742781
134 -0.035109740960932
134 -0.0315819395351879
225 -0.0185061255824483
225 -0.011421870094154
316 -0.00754767208759057
316 -0.0146347559179499
316 -0.00310047308843886
316 -0.0115551184661191
316 -0.00634977946016252
316 -0.00692554378948706
316 -0.00881077167468031
680 -0.00762284716567124
680 -0.00540951659852056
680 -0.00340968569602929
680 -0.00648741204172
862 -0.0102982367453512
1044 -0.00512058718235106
1408 -0.0037829897955397
1408 -0.00482904365362359
1408 -0.00278808254726609
1779 -0.00276101925051842
2507 -0.000639594385338699
2871 0.000144738215497167
};
\addlegendentry{IR on 02/07/08}
\addplot [only marks, mark=o, draw=blue, colormap/blackwhite]
table{%
x y
7 0.0982818692648283
7 0.102168510268359
7 0.100748135170598
7 0.103629507767704
7 0.105139612667773
7 0.0916420100908775
7 0.0970206755299201
7 0.0959024894533619
7 0.0995082892265707
7 0.0936952098184544
7 0.094838871230906
7 0.0981977393404596
7 0.0994384569079532
7 0.100801941457513
41 0.0503054923113288
41 0.0489827441617703
41 0.0490836410321661
41 0.04888643457657
41 0.051561800349167
41 0.0499633570950593
41 0.0493551490861963
41 0.0505102607936662
41 0.0495249826416865
41 0.0501063384301189
41 0.0496991191357553
41 0.0496475516105842
41 0.0491894609263344
41 0.0498278054765634
41 0.0491381995301007
41 0.0507208847044975
41 0.0501551930704094
41 0.0508966740697238
41 0.0497765733959851
70 0.0279557167858013
70 0.0281426831983837
70 0.027763634968417
70 0.028324735866505
70 0.0285400534997869
70 0.0288432750399811
133 -0.0319647113111972
133 -0.0355913845955476
133 -0.0441103078570322
133 -0.0452603824066078
133 -0.0375422307791266
133 -0.0417555547223528
133 -0.0429170546643158
133 -0.039665642559353
224 -0.0085776465875803
224 -0.0142858047953261
224 -0.015676476332763
315 -0.00228469881720664
315 -0.00542074508730561
315 -0.00430296377346576
315 -0.00656655864024044
315 -0.00595532900980452
315 -0.00326904093945666
315 -0.00911660456034204
315 -0.00783892190664203
679 -0.0050784551648649
1043 -0.00405336907755687
1043 0.00115755569802963
1407 -0.00271440331471457
1407 0.00375647552716685
1407 -0.00368753405825634
};
\addlegendentry{IR on 02/08/08}
\addplot [only marks, mark=square, draw=green!50!black, colormap/blackwhite]
table{%
x y
4 0.0522330530620592
4 0.0519053655163989
4 0.0509946960905777
4 0.0508759731363049
4 0.0525976645274144
4 0.0500058697258502
4 0.0515455824262793
4 0.0525710101238221
4 0.052939109361832
4 0.0533492788285549
4 0.0518669343204272
4 0.0511562297171298
4 0.0512563666864871
4 0.0506233969531874
38 0.0412860603925624
38 0.0415650108234644
38 0.0415053135167608
38 0.0413978468522265
38 0.0415288902614925
38 0.0411599292196664
38 0.0413119117182407
38 0.0414372085905371
38 0.0412605547822247
38 0.04120132348063
38 0.0414676229910777
38 0.0413595636720171
38 0.0414308990309988
38 0.0413602058020519
38 0.0415492520420215
38 0.0413223153184053
38 0.041395104926177
38 0.0413607446008492
38 0.0413928093607816
67 0.022232214228524
67 0.0209030464475512
67 0.0219516734282009
67 0.0215144392430739
67 0.0225056665957101
67 0.0218080930028479
67 0.020257283298192
67 0.0246561710767938
67 0.0212128653257623
67 0.0207369560900496
130 -0.0485816854318479
130 -0.0438580817061378
130 -0.030713446345599
130 -0.0461570410250343
130 -0.0450294126745839
130 -0.0498833625492505
130 -0.039600051694675
130 -0.0417464087655491
130 -0.0473909404540906
221 -0.0196004059552443
221 -0.0171607695481125
221 -0.0180114319187672
312 -0.00879233465979138
312 -0.0107960725590609
312 -0.0100878901314555
312 -0.00946361839640596
312 -0.00820179427516037
312 -0.000842156689736867
312 -0.00173375676461303
312 -0.0122735469799214
312 -0.00697444158715031
494 -0.00827578699801031
676 -0.00417643459619546
676 -0.00728505864778278
1040 -0.00594044060844927
1404 -0.00462820137108771
2139 0.00129259840473443
};
\addlegendentry{IR on 02/11/08}
\addplot [only marks, mark=pentagon, draw=red, colormap/blackwhite]
table{%
x y
3 -0.0840484443625455
3 -0.100855927348084
3 -0.0913888559298092
3 -0.120462090455567
3 -0.0982028919056806
3 -0.0891331650699075
3 -0.0937616805243413
3 -0.102236936663845
3 -0.0880465673936355
3 -0.090246917644429
3 -0.103656291059587
3 -0.0995117299343472
3 -0.0925600635808077
3 -0.110099225382324
37 0.0323908874731446
37 0.0315460052969838
37 0.0318574560798765
37 0.0304206262765782
37 0.0312086113478093
37 0.0323002208102165
37 0.0313241559251306
37 0.031956018496869
37 0.0323265269694245
37 0.0326499396607431
37 0.0280903907836876
37 0.0316525531454955
37 0.0317563346207586
37 0.031089813400855
37 0.0314365789714753
37 0.032479343554929
37 0.0309676227152722
66 0.0155775554657109
66 0.012594535086854
66 0.0141664674538804
66 0.015943250774442
66 0.0162998269209524
66 0.0148173713394732
66 0.0153468217096264
66 0.013479485116406
66 0.0166476208054302
66 0.0144221167729336
66 0.0137515167431489
129 -0.0505854588494822
129 -0.0437511667183664
129 -0.0558345007129536
129 -0.0481648671674546
129 -0.0719581825528851
129 -0.0545069284547053
129 -0.0459380792541169
129 -0.0530609392971763
129 -0.051882837920492
220 -0.0191695728153528
220 -0.0207723456140084
220 -0.0169591429900614
220 -0.0183992708685353
311 -0.0132032850138689
311 0.0133808990933443
311 -0.0485082049670174
311 -0.0066079808440165
311 -0.00442923873386192
311 -0.230733104041828
311 -0.00494688547500736
311 -0.00898599636109583
311 -0.00782782956448243
311 -0.00547723718951327
493 -0.0152263580014344
675 -0.00612113145788136
675 -0.00723818736824228
1039 0.00239391802091665
1039 -0.00247320427236799
1039 -0.0989289375018438
1039 -0.0044151513843213
1403 -0.00110720997970848
1403 -0.00730036336341747
1774 -0.00176025019895188
1774 0.00170369682287564
1774 -0.00482740351396885
1774 -0.0027341359001478
};
\addlegendentry{IR on 02/12/08}
\addplot [only marks, mark=diamond, draw=color0, colormap/blackwhite]
table{%
x y
2 0.0532016358223879
2 0.0511551330369323
2 0.054452384709378
2 0.0537800342559268
2 0.052483943966954
2 0.0518590465717506
2 0.0525015138729127
2 0.0512488547038224
2 0.0517722189903787
2 0.0486594289055706
2 0.0500705589235847
2 0.0539206827747949
2 0.0532951530648881
2 0.0546594325862095
2 0.0503339040017051
2 0.0518195794842147
2 0.0505075103403363
36 0.0423761373599012
36 0.0422173044387575
36 0.0422540343312069
36 0.0419833719394108
36 0.0420308808746708
36 0.0420821907741121
36 0.0421377767907342
36 0.0423332940249343
36 0.0420146436186594
36 0.0421996033331564
36 0.0419252436617922
36 0.0423984394413377
36 0.0421774812743928
36 0.0421981967187256
36 0.041939256698314
36 0.042312707032094
65 0.0216608579920651
65 0.0210252938711008
65 0.021819460953963
65 0.0222677478082481
65 0.0211965818892308
65 0.0221189465709505
128 -0.0498482112058497
128 -0.0485551030001322
128 -0.0427960141948599
128 -0.040676958964024
128 -0.0450249033823903
128 -0.0438596333772303
128 -0.0349688846890906
128 -0.0524631750814314
128 -0.0472963821212797
128 -0.0462207534172474
219 -0.0183323140251687
219 -0.014025282469741
219 -0.0168513646034692
310 -0.00681868072019094
310 -0.0080487410961081
310 -0.00562038572310098
310 -0.00244588695178555
310 -0.00928067331057862
310 -0.00453968503034592
310 -0.00737874002639933
310 -0.0121293645294685
492 -0.0142525284237223
674 -0.00776780913490069
674 -0.00555923126506884
674 -0.00123585033458016
1038 -0.00399422400876512
1402 -0.00261830002328178
};
\addlegendentry{IR on 02/13/08}
\addplot [only marks, mark=None, draw=black, colormap/blackwhite]
table{%
x y
1 -0.255625214489039
1 -0.236898525044409
1 -0.265984634115427
1 -0.258987514402404
1 -0.242970830406479
1 -0.277219166230951
1 -0.20943451220774
1 -0.269626917464543
1 -0.239896258004274
1 -0.243005936835108
1 -0.214360940270046
1 -0.231122336204662
1 -0.252686309439891
35 0.0311886185449039
35 0.0314438201589095
35 0.0289821349069826
35 0.0304679553389326
35 0.031056294233976
35 0.0307816010103795
35 0.0296509703443714
35 0.0295281629585544
35 0.0291694166783701
35 0.0315635095054077
35 0.0309206635529939
35 0.028789266140685
35 0.031687157730833
35 0.0309078967753035
35 0.0281745206873141
35 0.0299913730018597
35 0.0304926457964992
35 0.0315669196346439
35 0.0298672632228827
35 0.0297465091760482
35 0.030618459536932
35 0.0313177559326289
64 0.0144079113965743
64 0.0161928222241833
64 0.0167006705578167
64 0.0139772518291702
64 0.0146742239979751
64 0.0159625227412803
64 0.0169163791428556
64 0.0135346632887415
64 0.0153350682686482
64 0.0150844292031448
64 0.0155792912579244
127 -0.0475790992706659
127 -0.0382748282785993
127 -0.0511753995295215
127 -0.0524129423579535
127 -0.0422077435539323
127 -0.0453070896592368
127 -0.0442485212345094
127 -0.0499703472695416
127 -0.0411552622791677
127 -0.0464651107682145
127 -0.0401951360294376
127 -0.0391903997020435
218 -0.0201120079863289
218 -0.0170422394933211
218 -0.0156621542968365
309 -0.00902188240806251
309 -0.00776388834122985
309 -0.00334839941819897
309 -0.00659937301933836
309 -0.00543307118793894
309 -0.00717421198152838
491 -0.0147956681194606
673 -0.00584711551331629
673 -0.00476141711495055
855 -0.00832387032354409
1037 -0.00618221164282274
1037 0.00278935327365806
1037 -0.0030364189580605
1037 -0.0987822427068041
1037 -0.00403286791263568
1401 -0.00253055521180351
1772 -0.00133226009315427
};
\addlegendentry{IR on 02/14/08}
\end{axis}
\end{tikzpicture}
答案1
你可以使用
legend style={
fill opacity=0.8,
legend pos=north east,% <- changed
legend columns=2,% <- added
draw=none,
font=\footnotesize
},
要得到
\documentclass[margin=5pt]{standalone}
\usepackage{pgfplots}
\pgfplotsset{compat=1.17}
\begin{document}
\begin{tikzpicture}
\definecolor{color0}{rgb}{0,0.75,0.75}
\begin{axis}[
axis line style={white!80!black},
height=250,
legend cell align={left},
legend style={
fill opacity=0.8,
legend pos=north east,% <- changed
legend columns=2,% <- added
draw=none,
font=\footnotesize
},
tick align=outside,
tick pos=left,
width=383.69687,
x grid style={white!80!black},
xlabel={Time to Maturity in Days},
xmajorgrids,
xmin=-10, xmax=260,
xtick style={color=white!15!black},
y grid style={white!80!black},
ylabel={Interest Rates},
ymajorgrids,
ymin=-0.152018231009253, ymax=0.128738417906447,
ytick style={color=white!15!black},
ytick={-0.35,-0.3,-0.25,-0.2,-0.15,-0.1,-0.05,0,0.05,0.1,0.15},
yticklabel style={/pgf/number format/precision=2,/pgf/number format/fixed}% <- changed
]
\addplot [only marks, mark=o, draw=black, colormap/blackwhite]
table{%
x y
14 0.0137210894408035
14 0.0109288520715931
14 0.00704837479115305
14 0.0107904836180531
14 0.0123093541624417
14 0.00984002106743629
14 0.0132617068955713
14 0.0121610141911937
14 0.0118155552921216
14 0.0103915012330393
14 0.00758642487543226
14 0.00769481832497766
14 0.00997124637229361
14 0.0113094211296513
14 0.00939919165301169
48 0.0337101304126796
48 0.0332856787869166
48 0.0333505600734723
48 0.0318827199165808
48 0.0330450310724984
48 0.0322558551168201
48 0.0312935396126879
48 0.0320718064184453
48 0.0331996345790628
48 0.032583357737266
48 0.0317205947107256
48 0.0323638954664098
48 0.0327242387967672
48 0.0319010764844046
48 0.0328866134471117
48 0.0324107253616829
48 0.0324350646971547
77 0.0217807310981179
77 0.0219879496597338
77 0.0212243166398681
77 0.0214441188035296
77 0.0221899964554677
77 0.0208713509142476
140 -0.030858668114083
140 -0.0418287612283958
140 -0.0363924220137762
140 -0.0375311765556639
140 -0.0407810517943131
140 -0.0335245303566455
140 -0.035477903505249
140 -0.029183364178868
140 -0.0275244156599502
140 -0.0384960165950047
140 -0.0260532548376415
140 -0.0345859398371634
140 -0.0396922149627387
140 -0.0326145415438095
231 -0.0127759331625157
322 -0.00217857904281886
322 -0.00320971763326099
322 0.000272306639956942
322 -0.00377379633374709
322 -0.000695298524775345
322 -0.00271616931153243
322 -0.00491580884429343
322 -0.0101741044338815
322 -0.00614886577381889
322 -0.00165385558464088
504 -0.0224483091899071
504 -0.0123523054791817
504 -0.0111061709726516
686 -0.0110528747125295
686 0.000193864477039207
686 -0.00259534166334822
868 -0.00881377121720931
1050 -0.00348403656897434
1050 -0.00147380403107435
1414 -0.00480567226583495
1785 -0.00400120265642571
1785 1.73519679824097e-05
1785 -0.00760830760980281
2513 0.00101016343405089
3241 0.00198725571533959
};
\addlegendentry{IR on 02/01/08}
\addplot [only marks, mark=square, draw=red, colormap/blackwhite]
table{%
x y
11 0.00782074196830399
11 0.00567981101219131
11 0.00648082748710704
11 0.00485716551556713
11 0.00639665280536967
11 0.00707721310262872
11 0.0104930385205962
11 0.00914193943066978
11 0.00844169624457877
11 0.00716795637802111
11 0.00323320144804443
11 0.00854592810185749
45 0.0329036352830745
45 0.0338581792508533
45 0.0331078258109704
45 0.0334970630169385
45 0.033310696925052
45 0.0339880160702749
45 0.033828539239924
45 0.0338431828032519
45 0.0331145267047949
45 0.0324626748265784
45 0.0324587920254657
45 0.033485969955202
45 0.0326870497849932
45 0.0314250211527437
45 0.0333016823215926
74 0.0208168368768059
74 0.02144425966603
74 0.0226935318502737
74 0.0219121966462829
74 0.0224809881807469
74 0.0216812611749553
74 0.0222630731418938
137 -0.0301234137595977
137 -0.0519189526824219
137 -0.0491722603853324
137 -0.0318423719785866
137 -0.0406946609065207
137 -0.0396091163230254
137 -0.0355343910796541
137 -0.028481557591816
137 -0.038551343472451
137 -0.0374527436377718
137 -0.0418090855814953
228 -0.00840935480260763
319 -0.00357174179868151
319 -0.000535274276070646
319 -0.00253851238316985
319 -0.00474855597446069
319 -0.00726251781225182
683 -0.00240078906176454
683 -0.00342885761537241
1047 -0.0033158023302484
1782 6.00496720099665e-05
};
\addlegendentry{IR on 02/04/08}
\addplot [only marks, mark=pentagon, draw=blue, colormap/blackwhite]
table{%
x y
10 -0.000714835653361301
10 0.00102074567563072
10 0.00182939690090909
10 -0.00839634706540728
10 -0.00474857161683182
10 -0.00711098196202871
10 -0.000723660697638738
10 -0.00581621038817418
10 0.00103275461771234
10 0.00260212476519968
10 -0.0151100594961445
10 -0.00164767661148638
10 -0.006913473339844
10 -0.00361303069988589
10 -0.00259506111253902
10 -0.00262832993223295
10 0.000173606411740977
10 0.000175698060277621
10 0.00263136317314788
10 -0.00468526138094617
10 -0.0046236170986705
44 0.0306022551558512
44 0.0305637095373249
44 0.0319542657196389
44 0.0321860610255907
44 0.0324177974678948
44 0.0309018709758541
44 0.0314305661212422
44 0.0328196678202748
44 0.0314550362288093
44 0.0324070811702585
44 0.0311857274974459
44 0.0319196390499927
44 0.0326180604231787
44 0.0308684844316522
44 0.029216672351097
44 0.0321721657392433
44 0.0323961127387396
44 0.0319371661116744
44 0.027435547813034
44 0.0305240628017564
44 0.0311570149546782
44 0.029594535681857
44 0.0314788869092557
73 0.0184216023444508
73 0.0182671647487676
73 0.0178402561489673
73 0.0188301581506017
136 -0.0352271634851356
136 -0.0325224395924161
136 -0.0316617466785742
136 -0.0481444639230842
136 -0.0361720764624926
136 -0.0494300387567915
136 -0.0469674730288904
136 -0.0521902760627065
136 -0.0579715334752782
136 -0.0611790663523092
136 -0.0291929003049157
136 -0.0434101684491255
136 -0.0457497473885284
136 -0.0445644041472061
136 -0.0411902463259865
136 -0.0343044283068829
136 -0.0308203489294541
136 -0.0380653794091772
136 -0.0422858314966319
136 -0.0401223239032175
136 -0.0391481774804271
227 -0.0128393907105629
227 -0.0204523725356663
227 -0.0156987806158955
227 -0.0172422880119309
227 -0.00799786060332961
227 -0.0141920811884485
318 -0.0116801807442
318 -0.00106481994978654
318 0.00835815670056705
318 -0.00577907019235087
318 -0.0075898341489207
318 -0.00302218951087784
318 0.00317424441681439
318 -0.0184128372115965
318 -0.00153719612682391
318 -0.00464685106531441
318 -0.00520584201654607
318 0.0015823638792305
318 -0.000151725667727796
318 -0.00199326291372055
318 -0.00693996416694488
318 0.00595155596729646
318 -0.0102404786363387
318 -0.00884737897945365
318 -0.00410157336794007
318 -0.00639720710302733
318 0.000747056830049463
500 -0.00653733543474732
500 -0.00292630543511468
500 -0.00463189511430381
500 -0.0133212535195125
682 0.00172966445721909
682 -0.00676294171327189
682 -0.00452711317176547
682 0.000952016436745645
682 -0.000710576972017227
682 -0.00160057556328214
682 0.00517561127990313
682 -0.00404104392803875
682 -0.00349885026320383
682 -0.0151228863941521
682 0.0103592104317332
682 -0.00565176314933779
682 0.000556385624457466
682 0.000139406932721454
1046 -0.0105663845423541
1046 -0.00249455012074208
1046 -0.00347034048002549
1046 -0.00155633021213025
1046 0.000984929890387255
1046 -0.000670024715222342
1046 0.000192799207530437
1046 0.00138408933992296
1046 0.00253088349809061
1046 0.00179056115295174
1410 0.00256127065174039
1410 0.00328941182006974
1410 0.00100783091829495
1410 0.00180144934950054
1410 -0.00256096115226277
1410 -0.00161980402063054
1781 -0.00165250474576583
1781 0.002627076791482
1781 0.00337728779894552
1781 0.00408274850154402
1781 -0.0047522162384001
1781 0.00184900497392481
1781 -0.000714331490431584
2145 -0.00101704149636732
2509 0.0051601282356082
2509 0.00447608932543323
2509 0.000467764487790179
2873 0.0042393862832291
2873 0.000104350785904197
2873 0.00567003224223027
3237 0.00613919060589857
3237 0.0054517462350804
};
\addlegendentry{IR on 02/05/08}
\addplot [only marks, mark=diamond, draw=green!50!black, colormap/blackwhite]
table{%
x y
9 0.0451055505633164
9 0.04377418147123
9 0.044366267853128
9 0.0452355148018427
9 0.0431177182249171
9 0.044268150085363
9 0.0438468235381798
9 0.0449828069416397
9 0.0443690943903199
9 0.0447567012399299
9 0.0440028698985414
9 0.0437048043374142
9 0.0433367049949423
9 0.0445532071832386
9 0.0440868191375866
9 0.0448666984513006
9 0.0436084779803162
9 0.0444699136395687
43 0.0426218687631648
43 0.0425270048931812
43 0.042485845332956
43 0.0423378749389722
43 0.0427312888258755
43 0.0424259340259502
43 0.042736899944459
43 0.0450594587783314
43 0.0417808153170019
43 0.0428601362888359
43 0.0425005612624512
43 0.0424202446590423
43 0.0428547127445074
43 0.042513041880823
43 0.0426207656350751
43 0.0426183804937492
43 0.0425237605441487
43 0.0427330594451176
43 0.0424365541876866
43 0.0426196044477669
43 0.0425167912059655
72 0.023934023529251
72 0.0248566227791727
72 0.0242951401045801
72 0.02451235793668
135 -0.0488516860045501
135 -0.0427566768382227
135 -0.0416783145108086
135 -0.0373633126700585
135 -0.0334633824318098
135 -0.0283914960967466
135 -0.0299837346834408
135 -0.0440127428150731
135 -0.0404858507825355
135 -0.0464022385665871
135 -0.0394648951369009
135 -0.0353652992486614
135 -0.0383312318966557
226 -0.0134199795961423
226 -0.014865743300317
317 -0.00296259780822939
317 -0.00526783705048569
317 -0.00143024887978371
317 -0.00188045742297925
317 -0.00350939975282413
317 -0.0121741183596542
317 0.000961619020900178
317 -0.214857446560731
317 -0.00410059828441776
317 4.9450644374173e-05
317 -0.00467658355540114
317 -0.0156040297942899
317 0.00183299797908983
499 -0.0134996600745704
681 -0.00490558551519492
681 -0.00187532870339388
681 0.0108901530581598
863 -0.00889283585934299
1045 -0.00362686739069732
1409 -0.00273840365415771
1409 0.00401921506410618
1409 -0.00377321887037695
1780 -0.00100507398013182
1780 -0.00197002868049126
};
\addlegendentry{IR on 02/06/08}
\addplot [only marks, mark=None, draw=color0, colormap/blackwhite]
table{%
x y
8 0.041416476609293
8 0.040945537817464
8 0.0413865212181352
8 0.0410725668825453
8 0.0405389205263706
8 0.0406714187018807
8 0.0411930819626443
8 0.0403993561964818
8 0.0408114519647437
8 0.0409172597066841
8 0.0413075715827805
8 0.0415066901094974
42 0.0416822253271051
42 0.0416458939947301
42 0.0417190422900645
42 0.0417589275088041
42 0.0416164811372735
42 0.0415966839665266
42 0.0415112997327311
42 0.0416296395086009
42 0.0415595032406281
42 0.0415661399168651
42 0.0417699894139058
42 0.0415742115569374
42 0.0415132819484212
42 0.0414608544867393
42 0.0415842399686537
42 0.0416085382845583
42 0.0414254153653741
42 0.0414319400082946
71 0.0229905756504236
71 0.0234619267366171
71 0.0227454901172336
71 0.0244620912040126
71 0.0219694627928467
71 0.0212673343601604
71 0.0224937927790998
134 -0.0420747989305961
134 -0.04548333346951
134 -0.0409734620920738
134 -0.0546476483528862
134 -0.037966898829209
134 -0.0479635171869633
134 -0.051873794077114
134 -0.0324492337451637
134 -0.0467064832919963
134 -0.0442927157742781
134 -0.035109740960932
134 -0.0315819395351879
225 -0.0185061255824483
225 -0.011421870094154
316 -0.00754767208759057
316 -0.0146347559179499
316 -0.00310047308843886
316 -0.0115551184661191
316 -0.00634977946016252
316 -0.00692554378948706
316 -0.00881077167468031
680 -0.00762284716567124
680 -0.00540951659852056
680 -0.00340968569602929
680 -0.00648741204172
862 -0.0102982367453512
1044 -0.00512058718235106
1408 -0.0037829897955397
1408 -0.00482904365362359
1408 -0.00278808254726609
1779 -0.00276101925051842
2507 -0.000639594385338699
2871 0.000144738215497167
};
\addlegendentry{IR on 02/07/08}
\addplot [only marks, mark=o, draw=blue, colormap/blackwhite]
table{%
x y
7 0.0982818692648283
7 0.102168510268359
7 0.100748135170598
7 0.103629507767704
7 0.105139612667773
7 0.0916420100908775
7 0.0970206755299201
7 0.0959024894533619
7 0.0995082892265707
7 0.0936952098184544
7 0.094838871230906
7 0.0981977393404596
7 0.0994384569079532
7 0.100801941457513
41 0.0503054923113288
41 0.0489827441617703
41 0.0490836410321661
41 0.04888643457657
41 0.051561800349167
41 0.0499633570950593
41 0.0493551490861963
41 0.0505102607936662
41 0.0495249826416865
41 0.0501063384301189
41 0.0496991191357553
41 0.0496475516105842
41 0.0491894609263344
41 0.0498278054765634
41 0.0491381995301007
41 0.0507208847044975
41 0.0501551930704094
41 0.0508966740697238
41 0.0497765733959851
70 0.0279557167858013
70 0.0281426831983837
70 0.027763634968417
70 0.028324735866505
70 0.0285400534997869
70 0.0288432750399811
133 -0.0319647113111972
133 -0.0355913845955476
133 -0.0441103078570322
133 -0.0452603824066078
133 -0.0375422307791266
133 -0.0417555547223528
133 -0.0429170546643158
133 -0.039665642559353
224 -0.0085776465875803
224 -0.0142858047953261
224 -0.015676476332763
315 -0.00228469881720664
315 -0.00542074508730561
315 -0.00430296377346576
315 -0.00656655864024044
315 -0.00595532900980452
315 -0.00326904093945666
315 -0.00911660456034204
315 -0.00783892190664203
679 -0.0050784551648649
1043 -0.00405336907755687
1043 0.00115755569802963
1407 -0.00271440331471457
1407 0.00375647552716685
1407 -0.00368753405825634
};
\addlegendentry{IR on 02/08/08}
\addplot [only marks, mark=square, draw=green!50!black, colormap/blackwhite]
table{%
x y
4 0.0522330530620592
4 0.0519053655163989
4 0.0509946960905777
4 0.0508759731363049
4 0.0525976645274144
4 0.0500058697258502
4 0.0515455824262793
4 0.0525710101238221
4 0.052939109361832
4 0.0533492788285549
4 0.0518669343204272
4 0.0511562297171298
4 0.0512563666864871
4 0.0506233969531874
38 0.0412860603925624
38 0.0415650108234644
38 0.0415053135167608
38 0.0413978468522265
38 0.0415288902614925
38 0.0411599292196664
38 0.0413119117182407
38 0.0414372085905371
38 0.0412605547822247
38 0.04120132348063
38 0.0414676229910777
38 0.0413595636720171
38 0.0414308990309988
38 0.0413602058020519
38 0.0415492520420215
38 0.0413223153184053
38 0.041395104926177
38 0.0413607446008492
38 0.0413928093607816
67 0.022232214228524
67 0.0209030464475512
67 0.0219516734282009
67 0.0215144392430739
67 0.0225056665957101
67 0.0218080930028479
67 0.020257283298192
67 0.0246561710767938
67 0.0212128653257623
67 0.0207369560900496
130 -0.0485816854318479
130 -0.0438580817061378
130 -0.030713446345599
130 -0.0461570410250343
130 -0.0450294126745839
130 -0.0498833625492505
130 -0.039600051694675
130 -0.0417464087655491
130 -0.0473909404540906
221 -0.0196004059552443
221 -0.0171607695481125
221 -0.0180114319187672
312 -0.00879233465979138
312 -0.0107960725590609
312 -0.0100878901314555
312 -0.00946361839640596
312 -0.00820179427516037
312 -0.000842156689736867
312 -0.00173375676461303
312 -0.0122735469799214
312 -0.00697444158715031
494 -0.00827578699801031
676 -0.00417643459619546
676 -0.00728505864778278
1040 -0.00594044060844927
1404 -0.00462820137108771
2139 0.00129259840473443
};
\addlegendentry{IR on 02/11/08}
\addplot [only marks, mark=pentagon, draw=red, colormap/blackwhite]
table{%
x y
3 -0.0840484443625455
3 -0.100855927348084
3 -0.0913888559298092
3 -0.120462090455567
3 -0.0982028919056806
3 -0.0891331650699075
3 -0.0937616805243413
3 -0.102236936663845
3 -0.0880465673936355
3 -0.090246917644429
3 -0.103656291059587
3 -0.0995117299343472
3 -0.0925600635808077
3 -0.110099225382324
37 0.0323908874731446
37 0.0315460052969838
37 0.0318574560798765
37 0.0304206262765782
37 0.0312086113478093
37 0.0323002208102165
37 0.0313241559251306
37 0.031956018496869
37 0.0323265269694245
37 0.0326499396607431
37 0.0280903907836876
37 0.0316525531454955
37 0.0317563346207586
37 0.031089813400855
37 0.0314365789714753
37 0.032479343554929
37 0.0309676227152722
66 0.0155775554657109
66 0.012594535086854
66 0.0141664674538804
66 0.015943250774442
66 0.0162998269209524
66 0.0148173713394732
66 0.0153468217096264
66 0.013479485116406
66 0.0166476208054302
66 0.0144221167729336
66 0.0137515167431489
129 -0.0505854588494822
129 -0.0437511667183664
129 -0.0558345007129536
129 -0.0481648671674546
129 -0.0719581825528851
129 -0.0545069284547053
129 -0.0459380792541169
129 -0.0530609392971763
129 -0.051882837920492
220 -0.0191695728153528
220 -0.0207723456140084
220 -0.0169591429900614
220 -0.0183992708685353
311 -0.0132032850138689
311 0.0133808990933443
311 -0.0485082049670174
311 -0.0066079808440165
311 -0.00442923873386192
311 -0.230733104041828
311 -0.00494688547500736
311 -0.00898599636109583
311 -0.00782782956448243
311 -0.00547723718951327
493 -0.0152263580014344
675 -0.00612113145788136
675 -0.00723818736824228
1039 0.00239391802091665
1039 -0.00247320427236799
1039 -0.0989289375018438
1039 -0.0044151513843213
1403 -0.00110720997970848
1403 -0.00730036336341747
1774 -0.00176025019895188
1774 0.00170369682287564
1774 -0.00482740351396885
1774 -0.0027341359001478
};
\addlegendentry{IR on 02/12/08}
\addplot [only marks, mark=diamond, draw=color0, colormap/blackwhite]
table{%
x y
2 0.0532016358223879
2 0.0511551330369323
2 0.054452384709378
2 0.0537800342559268
2 0.052483943966954
2 0.0518590465717506
2 0.0525015138729127
2 0.0512488547038224
2 0.0517722189903787
2 0.0486594289055706
2 0.0500705589235847
2 0.0539206827747949
2 0.0532951530648881
2 0.0546594325862095
2 0.0503339040017051
2 0.0518195794842147
2 0.0505075103403363
36 0.0423761373599012
36 0.0422173044387575
36 0.0422540343312069
36 0.0419833719394108
36 0.0420308808746708
36 0.0420821907741121
36 0.0421377767907342
36 0.0423332940249343
36 0.0420146436186594
36 0.0421996033331564
36 0.0419252436617922
36 0.0423984394413377
36 0.0421774812743928
36 0.0421981967187256
36 0.041939256698314
36 0.042312707032094
65 0.0216608579920651
65 0.0210252938711008
65 0.021819460953963
65 0.0222677478082481
65 0.0211965818892308
65 0.0221189465709505
128 -0.0498482112058497
128 -0.0485551030001322
128 -0.0427960141948599
128 -0.040676958964024
128 -0.0450249033823903
128 -0.0438596333772303
128 -0.0349688846890906
128 -0.0524631750814314
128 -0.0472963821212797
128 -0.0462207534172474
219 -0.0183323140251687
219 -0.014025282469741
219 -0.0168513646034692
310 -0.00681868072019094
310 -0.0080487410961081
310 -0.00562038572310098
310 -0.00244588695178555
310 -0.00928067331057862
310 -0.00453968503034592
310 -0.00737874002639933
310 -0.0121293645294685
492 -0.0142525284237223
674 -0.00776780913490069
674 -0.00555923126506884
674 -0.00123585033458016
1038 -0.00399422400876512
1402 -0.00261830002328178
};
\addlegendentry{IR on 02/13/08}
\addplot [only marks, mark=None, draw=black, colormap/blackwhite]
table{%
x y
1 -0.255625214489039
1 -0.236898525044409
1 -0.265984634115427
1 -0.258987514402404
1 -0.242970830406479
1 -0.277219166230951
1 -0.20943451220774
1 -0.269626917464543
1 -0.239896258004274
1 -0.243005936835108
1 -0.214360940270046
1 -0.231122336204662
1 -0.252686309439891
35 0.0311886185449039
35 0.0314438201589095
35 0.0289821349069826
35 0.0304679553389326
35 0.031056294233976
35 0.0307816010103795
35 0.0296509703443714
35 0.0295281629585544
35 0.0291694166783701
35 0.0315635095054077
35 0.0309206635529939
35 0.028789266140685
35 0.031687157730833
35 0.0309078967753035
35 0.0281745206873141
35 0.0299913730018597
35 0.0304926457964992
35 0.0315669196346439
35 0.0298672632228827
35 0.0297465091760482
35 0.030618459536932
35 0.0313177559326289
64 0.0144079113965743
64 0.0161928222241833
64 0.0167006705578167
64 0.0139772518291702
64 0.0146742239979751
64 0.0159625227412803
64 0.0169163791428556
64 0.0135346632887415
64 0.0153350682686482
64 0.0150844292031448
64 0.0155792912579244
127 -0.0475790992706659
127 -0.0382748282785993
127 -0.0511753995295215
127 -0.0524129423579535
127 -0.0422077435539323
127 -0.0453070896592368
127 -0.0442485212345094
127 -0.0499703472695416
127 -0.0411552622791677
127 -0.0464651107682145
127 -0.0401951360294376
127 -0.0391903997020435
218 -0.0201120079863289
218 -0.0170422394933211
218 -0.0156621542968365
309 -0.00902188240806251
309 -0.00776388834122985
309 -0.00334839941819897
309 -0.00659937301933836
309 -0.00543307118793894
309 -0.00717421198152838
491 -0.0147956681194606
673 -0.00584711551331629
673 -0.00476141711495055
855 -0.00832387032354409
1037 -0.00618221164282274
1037 0.00278935327365806
1037 -0.0030364189580605
1037 -0.0987822427068041
1037 -0.00403286791263568
1401 -0.00253055521180351
1772 -0.00133226009315427
};
\addlegendentry{IR on 02/14/08}
\end{axis}
\end{tikzpicture}
\end{document}
补充说明:您有两个图(02/07/08 和 02/14/08)正在使用only marks, mark=None
- 因此它们隐藏在轴中!它们只出现在图例中而没有标记。