
matlab legend函数用法.pdf
3页欢迎您阅读并下载本文档,本文档来源于互联网,如有侵权请联系删除!我们将竭诚为您提供优质的文档! LEGEND(string1,string2,string3, ...) puts a legend on the current plot using the specified strings as labels. LEGEND works on line graphs, bar graphs, pie graphs, ribbon plots, etc. You can label any solid-colored patch or surface object. The fontsize and fontname for the legend strings matches the axes fontsize and fontname. LEGEND(H,string1,string2,string3, ...) puts a legend on the plot containing the handles in the vector H using the specified strings as labels for the corresponding handles. LEGEND(M), where M is a string matrix or cell array of strings, and LEGEND(H,M) where H is a vector of handles to lines and patches also works. LEGEND(AX,...) puts a legend on the axes with handle AX. LEGEND OFF removes the legend from the current axes and deletes the legend handle. LEGEND(AX,'off') removes the legend from the axis AX. LEGEND TOGGLE toggles legend on or off. If no legend exists for the current axes one is created using default strings. The default string for an object is the value of the DisplayName property if it is non-empty and otherwise it is a string of the form 'data1','data2', etc. LEGEND(AX,'toggle') toggles legend for axes AX LEGEND HIDE makes legend invisible. LEGEND(AX,'hide') makes legend on axes AX invisible. LEGEND SHOW makes legend visible. If no legend exists for the current axes one is created using default strings. LEGEND(AX,'show') makes legend on axes AX visible. LEGEND BOXOFF makes legend background box invisible when legend is visible. LEGEND(AX,'boxoff') for axes AX makes legend background box invisible when legend is visible. LEGEND BOXON makes legend background box visible when legend is visible. LEGEND(AX,'boxon') for axes AX making legend background box visible when legend is visible. LEGH = LEGEND returns the handle to legend on the current axes or empty if none exists. 欢迎您阅读并下载本文档,本文档来源于互联网,如有侵权请联系删除!我们将竭诚为您提供优质的文档! LEGEND(...,'Location',LOC) adds a legend in the specified location, LOC, with respect to the axes. LOC may be either a 1x4 position vector or one of the following strings: 'North' inside plot box near top 'South' inside bottom 'East' inside right 'West' inside left 'NorthEast' inside top right (default for 2-D plots) 'NorthWest' inside top left 'SouthEast' inside bottom right 'SouthWest' inside bottom left 'NorthOutside' outside plot box near top 'SouthOutside' outside bottom 'EastOutside' outside right 'WestOutside' outside left 'NorthEastOutside' outside top right (default for 3-D plots) 'NorthWestOutside' outside top left 'SouthEastOutside' outside bottom right 'SouthWestOutside' outside bottom left 'Best' least conflict with data in plot 'BestOutside' least unused space outside plot If the legend does not fit in the 1x4 position vector the position vector is resized around the midpoint to fit the preferred legend size. Moving the legend manually by dragging with the mouse or setting the Position property will set the legend Location property to 'none'. LEGEND(...,'Orientation',ORIENTATION) creates a legend with the legend items arranged in the specified ORIENTATION. Allowed values for ORIENTATION are 'vertical' (the default) and 'horizontal'. [LEGH,OBJH,OUTH,OUTM] = LEGEND(...) returns a handle LEGH to the legend axes; a vector OBJH containing handles for the text, lines, and patches in the legend; a vector OUTH of handles to the lines and patches in the plot; and a cell array OUTM containing the text in the legend. Examples: x = 0:.2:12; plot(x,bessel(1,x),x,bessel(2,x),x,bessel(3,x)); legend('First','Second','Third'); legend('First','Second','Third','Location','NorthEastOutside') b = bar(rand(10,5),'stacked'); colormap(summer); hold on 欢迎您阅读并下载本文档,本文档来源于互联网,如有侵权请联系删除!我们将竭诚为您提供优质的文档! x = plot(1:10,5*rand(10,1),'marker','square','markersize',12,... 'markeredgecolor','y','markerfacecolor',[.6 0 .6],... 'linestyle','-','color','r','linewidth',2); hold off legend([b,x],'Carrots','Peas','Peppers','Green Beans',... 'Cucumbers','Eggplant') Reference page in Help browser doc legend 。












