![]() ![]() This will plot the additional points, but they will not be visible on the plot itself. The updated code above works, but the answer below is only relevant pre-2016b: figure This will plot the additional points, but because the coordinates are at NaN they will not be visible on the plot itself:ĮDIT : My original answer results in greyed out legend entries in 2016b. I do monitor the MatlabCentral FileExchange entry for any issues raised in the comments, but would prefer to track issues on GitHub.This is how I have solved this problem in the past: figure Please also feel free to submit enhancement requests, or to send pull requests (via GitHub) for bug fixes or new features. code/data to reproduce the error or buggy behavior, and the full text of any error messages received.your version of Matlab and all relevant toolboxes (type ver at the Matlab command line to get this info).To report bugs, please submit an issue on GitHub and include: ContributionsĬommunity contributions to this package are welcome! None of these hacks are ideal, but they're the best I've been able to come up with. Other times I generate the legend using a larger font size, then shrink the text back down after it's been positioned. Sometimes generating the legend first, then setting the latex rendering afterwards will help a bit. Rectangle( 'position ', ex, 'parent ', lax( ii), 'edgecolor ', 'r ') īecuase of this, you really need to play around with properties (like padding) in order to get a legendflex legend that uses latex and looks decent. Įnd set( ht( 2, :), 'interpreter ', 'latex ') Set( lax, 'xlim ',, 'ylim ', ) įor ii = 1 : na ht( ii, :) = text( 1 : nt, 1 : nt, txt, 'parent ', lax( ii). Anchor points can be described using either numbers (in a 1 x 2 double array) or directional strings (in a 1 x 2 cell array) as follows: 1 = 'nw' = upper left corner, 2 = 'n' = center of top edge, 3 = 'ne' = upper right corner, 4 = 'e' = center of right edge, 5 = 'se' = bottom right corner, 6 = 's' = center of bottom edge, 7 = 'sw' = bottom left corner, 8 = 'w' = center of left edge,, i.e. anchor: 1 x 2 array specifying which points of the reference object and new legend, respectively, to anchor to each other.If not included, the reference will be to the axis that a normal legend would be associated with (usually the parent axis of the labeled objects, unless objects from multiple axes are passed, in which case it's the parent object of the first labeled object). This can be either a figure or a child object of a figure (and does not need to relate in any way to the objects being labeled). ref: handle of object used to position the legend.nrow: number of rows, or 0 to indicate as many as necessary given the # of labeled objects. ![]() ![]() ncol: number of columns, or 0 to indicate as many as necessary given the # of labeled objects.Optional input variables (passed as parameter/value pairs): If this is an axis handle, all children of the axis will be included in the legend. h: handle of axis or handle(s) of object(s) to be labeled.M: cell array of strings, labels for legend.The position of the legend is determined by these two points and the distance between them, defined in the 'buffer' variable, which by default is measured in pixels. The anchor points refer to the corners and centers of each side of the box surrounding the reference object and the legend itself they can be refered to either as numbers (1-8, clockwise from northwest corner) or strings ('nw', 'n', 'ne', 'e', 'se', 's', 'sw', 'w'). ![]() Unlike in the default legend command, where the legend is positioned relative to the labeled objects' parent axis according to one of 16 location strings, this function positions the legend based on two anchor points (one on either the figure or a child object of a figure, and one on the legend itself) and a buffer (or offset) between these two anchor points. This function should support all types of plot objects.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |