time | Calls | line |
---|
| | 299 | function make_legend(ha,argin,version_flag,clamp)
|
| | 300 |
|
0.006 | 8 | 301 | leg = find_legend(ha);
|
< 0.001 | 8 | 302 | ch = [];
|
< 0.001 | 8 | 303 | strings = {};
|
| | 304 |
|
| | 305 | % Always create a new legend if the user has requested a compatible legned
|
| | 306 | % or if the existing legend is a compatible legend
|
< 0.001 | 8 | 307 | if strcmp(version_flag,'on') || strcmp(get(leg,'version'),'on')
|
| | 308 | delete(leg)
|
| | 309 | leg = [];
|
< 0.001 | 8 | 310 | end
|
| | 311 |
|
< 0.001 | 8 | 312 | new_legend = false;
|
< 0.001 | 8 | 313 | if isempty(leg)
|
< 0.001 | 8 | 314 | new_legend = true;
|
0.254 | 8 | 315 | leg = matlab.graphics.illustration.Legend;
|
0.003 | 8 | 316 | leg.doPostSetup(version_flag);
|
< 0.001 | 8 | 317 | leg.Visible = 'off';
|
< 0.001 | 8 | 318 | if(clamp)
|
| | 319 | leg.LimitMaxLegendEntries = true;
|
< 0.001 | 8 | 320 | else
|
0.009 | 8 | 321 | leg.LimitMaxLegendEntries = false;
|
< 0.001 | 8 | 322 | end
|
| | 323 | else
|
| | 324 | % For existing legends, make sure the ALM is dirty as a result of this
|
| | 325 | % legend call. We don't need to do this if the legend is in a layout
|
| | 326 | if ~isa(leg.Parent, 'matlab.graphics.layout.Layout')
|
| | 327 | hManager = matlab.graphics.shape.internal.AxesLayoutManager.getManager(leg.Axes);
|
| | 328 | doMarkDirty(hManager);
|
| | 329 | end
|
< 0.001 | 8 | 330 | end
|
| | 331 |
|
< 0.001 | 8 | 332 | try
|
| | 333 | % process input args
|
0.234 | 8 | 334 | [propargs, ch, strings] = process_inputs(leg,ha,argin, new_legend); %#ok
|
| | 335 | catch ME
|
| | 336 | throwAsCaller(ME);
|
< 0.001 | 8 | 337 | end
|
| | 338 |
|
< 0.001 | 8 | 339 | if new_legend
|
< 0.001 | 8 | 340 | try
|
< 0.001 | 8 | 341 | fig = ancestor(ha,'figure');
|
< 0.001 | 8 | 342 | parent = get(ha,'Parent');
|
| | 343 |
|
< 0.001 | 8 | 344 | if strcmp(get(ha,'color'),'none')
|
| | 345 | leg.Color_I = get(fig,'Color');
|
< 0.001 | 8 | 346 | else
|
0.001 | 8 | 347 | leg.Color_I = get(ha,'Color');
|
< 0.001 | 8 | 348 | end
|
0.003 | 8 | 349 | leg.TextColor_I = get(parent,'DefaultTextColor');
|
0.006 | 8 | 350 | leg.EdgeColor_I = get(parent,'DefaultAxesXColor');
|
| | 351 |
|
| | 352 | % apply 3D default
|
0.003 | 8 | 353 | if ~lcl_is2D(getGraphicsAxes(leg,ha))
|
| | 354 | leg.Location = 'northeastoutside';
|
< 0.001 | 8 | 355 | elseif isa(ha, 'matlab.graphics.axis.PolarAxes')
|
| | 356 | leg.Location = 'eastoutside';
|
< 0.001 | 8 | 357 | end
|
| | 358 |
|
| | 359 | % set the peer axes
|
0.205 | 8 | 360 | leg.Axes = ha;
|
| | 361 |
|
| | 362 | % disable AutoUpdate for plotyy
|
< 0.001 | 8 | 363 | if matlab.graphics.illustration.internal.isplotyyaxes(ha)
|
| | 364 | % Make sure the discovered plotyy children don't get
|
| | 365 | % overwritten by the autoUpdateCallback during the update
|
| | 366 | % triggered by setting AutoUpdate to 'off';
|
| | 367 | % The callback can only see children of the primary axes.
|
| | 368 | leg.PlotChildrenSpecified = leg.PlotChildren_I;
|
| | 369 | leg.AutoUpdate = 'off';
|
< 0.001 | 8 | 370 | end
|
| | 371 | catch
|
| | 372 | leg.Axes = [];
|
| | 373 | delete(leg);
|
| | 374 | return
|
< 0.001 | 8 | 375 | end
|
< 0.001 | 8 | 376 | end
|
| | 377 |
|
| | 378 | % set DisplayNames
|
0.008 | 8 | 379 | setDisplayNames(ch,strings);
|
| | 380 |
|
| | 381 | % set user-specified PV pairs
|
< 0.001 | 8 | 382 | if ~isempty(propargs)
|
0.016 | 8 | 383 | set(leg,propargs{:});
|
< 0.001 | 8 | 384 | end
|
| | 385 |
|
| | 386 | % always make legend visible
|
| | 387 | % the purpose of make_legend is to put a legend on the figure
|
0.001 | 8 | 388 | set(leg,'Visible','on');
|
Other subfunctions in this file are not included in this listing.