plot legend disappears after resize
10 views (last 30 days)
Show older comments
the legend of my bodeplot disappears after i resize the figure with my mouse
b = [0 2 3; 1 2 1];
a = [1 0.4 1];
[A,B,C,D] = tf2ss(b,a);
statespace = ss(A,B,C,D) ;
f = figure;
p = bodeplot(statespace(1,1));
setoptions(p,'FreqUnits','Hz','PhaseVisible','off');
legend('test','Location','southwest');
set(f, 'ResizeFcn', @(varargin) legend('test','Location','southwest'))
solves the problem but maybe there is a better solution.
0 Comments
Answers (1)
Sam McDonald
on 16 Nov 2016
A "bodeplot" creates more than one axes and when calling "legend" without specifying the parent axes, MATLAB takes the last active axes which might be an invisible one leading to undesired behavior. Overall it is the best to specify the axes as input to which the legend refers, e.g.
legend(findall(gcf,'type','axes','visible','on'),'test','Location','southwest');
This will keep the legend visible when resizing the figure.
0 Comments
See Also
Categories
Find more on Legend in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!