Reading in Legend, then displaying, gives different string order - Matlab 2014b

2 ビュー (過去 30 日間)
Ashley Penna
Ashley Penna 2014 年 11 月 19 日
回答済み: Kelly Kearney 2014 年 11 月 19 日
Hi there,
I'm reading in a legend from a figure: h1 = hgload('file.fig'); leg = findobj(h1,'Type','Legend');
Then displaying both the image and legend on a subplot: ax1 = gca; fig1 = get(ax1,'children'); h5 = figure; s1 = subplot(2,3,1); copyobj(fig1,s1); legend(leg.String{:});
When the legend is displayed the names are in a different order than in the original legend, and the last symbol is incorrect.
Am I doing something in my reading in the legend, and writing it out process that could be causing this?
Thank you!

回答 (1 件)

Kelly Kearney
Kelly Kearney 2014 年 11 月 19 日
Nothing immediately jumps out at me as incorrect. Does the loaded figure and the new subplot include the same number of child objects to which the legend is pointing? I suggest explcitly passing the handles of the labeled objects to legend just to be sure.

カテゴリ

Help Center および File ExchangeLegend についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by