필터 지우기
필터 지우기

How do I position the legend window in a Bode plot with phase hidden?

조회 수: 36 (최근 30일)
I generated the following code to create a simple bode plot, and the legend position doesn't seem to be behaving properly. Am I missing something, or is this a bug?
P = bodeoptions; P.FreqUnits = 'Hz'; % Create plot with the options specified by P P.PhaseVisible = 'off';
x1=tf(1,[1/(10*2*pi) 1]); x2=tf(1,[1/(20*2*pi) 1]);
bodeplot(x1, x2, P) legend('tf 10hz', 'tf 20hz','Location', 'NorthEast')

채택된 답변

Namita Vishnubhotla
Namita Vishnubhotla 2014년 7월 21일
The "legend" command places the legend in the CurrentAxis unless an axis handle is explicitly specified as one of the inputs to the command. In your case, the legend is being positioned at the 'NorthEast' location of the lower axis because the lower axis becomes the CurrentAxis by default.
There are two workarounds you can use:
1. Manually click and drag the legend to location you prefer
2. Get the handle to the first axis, and use this handle as an input to the "legend" command.
>> axes_handles = findall(gcf, 'type', 'axes');
>> legend(axes_handles(4),'tf 10hz', 'tf 20hz','Location', 'NorthEast');

추가 답변 (1개)

Gordon Pellegrinetti
Gordon Pellegrinetti 2014년 7월 21일
Thank you. That's precisely what I needed.
G

카테고리

Help CenterFile Exchange에서 Legend에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by