Code covered by the BSD License  

Highlights from
Legend best fit

5.0

5.0 | 1 rating Rate this file 7 Downloads (last 30 days) File Size: 11.76 KB File ID: #30220

Legend best fit

by Kevin J. Delaney

 

29 Jan 2011 (Updated 01 Feb 2011)

Automatically moves legend around inside plot to avoid covering the plotted lines.

| Watch this File

File Information
Description

legend_best_fit automatically positions the existing legend inside the axes to avoid covering the plotted data. I think it does a better job than the "Location", "Best" option in "legend" command.

Example:

  legend_best_fit(axes_handle)
    Will position legend inside if it can, return false if it can not.

  legend_best_fit(axes_handle, 'adjust y limits', true)
    Positions legend if it can with existing y axis limits. If not, slightly expands y axis limits & tries again.

  legend_best_fit(axes_handle, 'location', preferred_location)
    Tries your preferred location (like "NorthEast", etc.) first.

MATLAB release MATLAB 7.11 (2010b)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (1)
29 Jul 2011 Kevin

For the cases I was looking at, this command did a much better job that Matlab's buit-in 'Location', 'Best' options on the legend command.

Thanks for the good work!

Kevin W.

Please login to add a comment or rating.
Updates
31 Jan 2011

Utility program ("nice_tics") now handles limits that straddle the origin.

01 Feb 2011

Bug fixes

Tag Activity for this File
Tag Applied By Date/Time
legend Kevin J. Delaney 31 Jan 2011 09:12:44
best fit Kevin J. Delaney 31 Jan 2011 09:12:44
location Kevin J. Delaney 31 Jan 2011 16:14:21

Contact us at files@mathworks.com