MATLAB plotyy y grid不显示?

时间:2014-12-29 06:01:58

标签: matlab

y网格未显示。

我很抱歉在这里粘贴我的数据,但随机生成的数据不会重现错误。

MWE

x = 1:188;
y1 = [2.28625413745400e-06  2.75754117520236e-06    7.28685404437484e-06    0.000162724777360761    0.000221525521386474    0.00513896494125896 0.00604630901473093 0.0239972210208572  0.0299094578291452  0.0379598701078280  0.0407471655008175  0.0424981277377004  0.0593685291574623  0.0720049840827008  0.0764805090392905  0.0784745326633472  0.0860462823212269  0.0872332599512308  0.0975548852352724  0.109523883880442   0.110064605012806   0.113809401352047   0.124266280105196   0.127737254184620   0.131994354266289   0.136382231740752   0.140780372613597   0.148025152077524   0.153450613217859   0.160350058677122   0.162287760596164   0.167560245835870   0.172287619094450   0.179483652830590   0.182889254147371   0.186973131314099   0.191625297613997   0.196138973204891   0.207290820972041   0.228336575919158   0.230665358213673   0.235638857454267   0.235734235774472   0.238705757714335   0.239622986776577   0.242413675960620   0.246310296615708   0.253736977688068   0.263526753327344   0.267765132710984   0.278657792038674   0.279655691920331   0.288031520555191   0.293324147563905   0.296311756729307   0.299954886375481   0.321017342659284   0.326834183424333   0.330097266880667   0.335595881759988   0.336496847040177   0.340794306395668   0.341629365670475   0.346388406232711   0.349275143228649   0.354280512324743   0.354379434267694   0.358138289571028   0.362194170593214   0.362900354379436   0.369051901571130   0.377532832423029   0.378473844107997   0.381395220201511   0.382513829911048   0.384054832987647   0.386163845331814   0.392189611831563   0.394741141959399   0.397482463354943   0.405159848615709   0.405380894697897   0.407164071630765   0.409960356496890   0.410899112960204   0.412540848976194   0.413785128363002   0.416497765056847   0.416620870255991   0.423339554321434   0.432715687900691   0.433645605363207   0.438315853796267   0.440811877583745   0.442254706117630   0.444715767486113   0.446534290546266   0.453869137753388   0.460480289492812   0.462635871995806   0.469200485794422   0.477953684933473   0.480327971284933   0.483328013787908   0.485165999667700   0.488810058710477   0.492434498347716   0.495633702966921   0.496950612281433   0.499449682429962   0.500216965521911   0.500846991265055   0.500928755463801   0.509072082345426   0.510390618618367   0.513193477753814   0.516094965483328   0.519766464957800   0.526453403933161   0.531012377098381   0.537398002662492   0.549302962968306   0.551182949653050   0.552379404338828   0.556210298953147   0.556753658102025   0.559775602234047   0.565600556439014   0.575345977188816   0.582325671082393   0.583274992838168   0.590277452190722   0.600455666337237   0.602008898724798   0.603153938447889   0.613158002706088   0.613885424973209   0.616753470151396   0.628020233091089   0.628074985975907   0.628789310134612   0.630860799827951   0.636442699017899   0.636900946176369   0.637731827970055   0.645063295538950   0.651395391970488   0.661823925726547   0.667492404940707   0.668956876509558   0.669721721712489   0.671361974997858   0.671885436140652   0.680929118840636   0.682908071014682   0.686054230901812   0.686999320186044   0.694779340677743   0.696700705717762   0.703712091209040   0.703869695474697   0.709425231090181   0.724246955883888   0.726713348504891   0.728662080945891   0.732212616777790   0.733176807633189   0.763720671816572   0.765840614187905   0.770399497782647   0.770434651768652   0.792235782237051   0.807184100825349   0.810885623037136   0.811134923493633   0.815243002846112   0.841422843749966   0.861314574636162   0.878517027205137   0.892431499196981   0.942320011798269   0.964745715565426   0.977151781479271   0.988013718634144   0.999972717897711   0.999990949120295   0.999997802101236   0.999997876591522];
y2 = [3294.33837529196  2729.78695657567    2310.42151540182    3261.53933401261    3665.60437426496    2581.47975105179    3286.49864759154    2978.24371790368    4481.99722565735    2800.21030230662    2301.25805253203    2863.33415937793    1958.80234681204    2487.66423766389    3829.37164321518    2868.93021805668    2669.26931138609    2653.62428904136    3222.63130681970    2318.46261983033    2338.28118053869    3420.09701187000    2619.37694067421    3639.34394329064    2542.70875166783    2702.39831536651    2510.69621735271    2267.65044087156    2467.31789304366    2062.46609266725    3373.03272133488    2197.75665691969    2826.13630193704    2236.19499536199    2323.13168705560    3066.53020217878    3068.54949312690    3426.80837351058    3314.30473826970    2536.37810854444    2884.52696903199    2276.44108414871    2395.79431323859    2455.23706941821    2556.54900792254    3287.41337734157    3049.78318859226    2137.34736327310    2734.56065425968    2092.28587548994    2220.94669832315    2576.25273881808    2936.79720507286    3252.22901487077    2354.99925954856    3118.56428955851    2739.08882274580    3037.83300416419    2767.32993139568    2651.17282634850    2126.70682501162    2208.11204840368    2463.12421246333    2788.29925791802    2931.86717632459    1672.90126196404    2200.27471694257    2629.79309139237    2871.88047431798    2771.11497975924    3306.15504624950    2615.51614159686    2104.52375632588    2522.81762261438    2553.64540775560    2664.61027658776    3214.62846184114    2681.73004190842    2854.46880173160    2947.77021172908    2843.58809148613    2970.81524997654    2517.75645078039    2665.88205361855    2972.47722717208    2775.93754320540    3230.01088619321    2093.71452074073    2250.27329605820    2456.05859503165    2998.17131690415    2464.61113820404    2014.42482269388    2513.46818136650    2792.53181675715    3174.78812406346    2701.20264878804    2389.85439304729    3289.42797312716    2295.43987736403    2611.53215270973    3740.71494210077    2462.96252295280    3832.67982476584    2645.28910431242    2405.15899417202    2731.28933338260    2855.62677715298    2323.21533050664    2636.33997756180    2503.20033540276    1748.70147375294    3349.86556128063    2497.65649660493    2271.69261389125    2336.03524355220    2473.18519446995    2266.88488232443    2409.51158095881    1734.14451377117    2514.18757679797    1975.25093236641    2958.72678659639    2429.83473700471    2498.28210099667    2055.42730670745    2408.13320127252    2849.86545528969    2079.01473466442    2035.08193677459    2309.55127919543    2846.16370840958    2395.13215085459    2549.68177442072    2765.86512891974    2724.23809140675    2264.77498971179    2439.87393419107    2055.88468587720    3146.12025364587    2648.24057514780    2332.28994336700    2420.02188205959    2748.73933350174    2447.73770315806    2356.97937091099    2381.15677251297    2567.93916714385    2587.53026732683    2667.30106970822    2660.47433323455    2163.50645008963    2309.40075292939    2312.40421976050    2166.40731989119    2082.28556641993    2745.06117055910    3486.90007765939    1987.74834763183    2485.62389820632    2337.31198380922    1901.20002732537    3112.71557200479    2498.59172261308    2984.01432790167    2793.37859308815    2857.77785197779    2571.67750419978    1876.49080511373    2003.31154773529    2517.62947444061    2929.54702726817    3099.39521514734    3849.11548253558    2114.99710879081    2851.38969242251    1770.21298408528    2570.79519973382    2861.78434546229    3136.05338342104    2007.19612886364    1759.16533204181    2521.93259475353    2206.81633306099    2035.72855620751    2017.41126163408    2228.99620986991    2314.02003648875];
[hAx, hLine1, hLine2] = plotyy(x, y1, x, y2);
hAx(1).XGrid = 'on';
hAx(1).YGrid = 'on';
hAx(2).XGrid = 'on';
hAx(2).YGrid = 'on';

enter image description here

1 个答案:

答案 0 :(得分:1)

使用:

plotyy(x, y1, x, y2);
grid on;
ha = findobj(gcf,'type','axes');
set(ha(1),'ytick',linspace(0,5000,5));
set(ha(2),'ytick',linspace(0,1,5));

你可以乱用linspace,我只看了最大值并选择了5个刻度