Search results
Legend properties control the appearance and behavior of a Legend object. By changing property values, you can modify certain aspects of the legend. Use dot notation to refer to a particular object and property:
- Gco
The MATLAB ® software stores the handle of the current...
- Text Properties
Legend text properties control the appearance and behavior...
- GCBO
Tips. The MATLAB ® software stores the handle of the object...
- Uicontextmenu
cm = uicontextmenu creates a context menu in the current...
- Gco
1 sie 2014 · Copy. legend (...,'Location', 'location') allows you to either specify the 'location' as one of a huge number of pre-defined positions e.g 'NorthWest', 'NorthWestOutside' or as a standard 1-by-4 position vector for precise manual positioning.
Specify the number of legend columns using the NumColumns property. x = linspace(0,pi); y1 = cos(x); plot(x,y1) hold on y2 = cos(2*x); plot(x,y2) y3 = cos(3*x); plot(x,y3) y4 = cos(4*x); plot(x,y4) hold off legend({ 'cos(x)' , 'cos(2x)' , 'cos(3x)' , 'cos(4x)' }, ...
23 sie 2016 · If your figure was generated in R2014b or newer you can utilize the undocumented 'PlotChildren' property to manipulate the order of the legend entries without requiring a new legend call. For example: x = 1:10; y1 = x; y2 = 2*x; y3 = 3*x; y4 = x.^2; plot(x, y1, x, y2, x, y3, x, y4); lh = legend('y = x', 'y = 2*x', 'y = 3*x', 'y = x.^2'); Produces:
You can move the legend by pressing the left mouse button while the cursor is over the legend and dragging the legend to a new location. Double clicking on a label allows you to edit the label. Examples
You move the legend by pressing the mouse button while the cursor is over the legend and dragging the legend to a new location. If your mouse has more than one button, you press the left mouse button. Examples. Add a legend to a graph showing a sine and cosine function: x = - pi:pi/20:pi;
11 sie 2018 · Then change its position property to move it outside of the plot. I always recommend using the tight_subplot function from fileexchange to make subplots, especially when you are writing a paper and need to minimize empty space. It also let's you set the right margin so that you can fit the legend.