how to access compass formatting details?

조회 수: 6 (최근 30일)
Angelo Hafner
Angelo Hafner 2020년 3월 3일
답변: Koushik Vemula 2020년 3월 6일
Greetings everyone!
I need to fix the axes and the grid lines.
Is there anything similar to the axis () or xtick () command?
f = 60; omega = 2*pi*f;
deg = pi/180;
h = figure;
r1 = 5;
for t=0:1/60/16:1/60
z = r1 * exp(1j*(omega*t+30*deg));
h = compass(z);
drawnow;
end
Thank's in advance

답변 (1개)

Koushik Vemula
Koushik Vemula 2020년 3월 6일
In MATLAB there is a "polarplot" function that allows you to update the properties of the polar axes. Please see the following documentation pages for reference.
1) Changing the axis limits:
If (x,y) is the data to be plotted and the maximum axis limit is max_lim:
x = [1;3;-2];
y = [-3;-2;1];
% Original compass figure
figure;
compass(x,y);
% Modified compass figure with higher radial limit
figure;
max_lim = 10;
x_fake=[0 max_lim 0 -max_lim];
y_fake=[max_lim 0 -max_lim 0];
h_fake=compass(x_fake,y_fake);
hold on;
h=compass(x,y);
set(h_fake,'Visible','off');
Please note that depending on the value of "max_lim", the actual limit may not be exact. For example, setting "max_lim = 0.14" will produce an axis limit of "0.15". The reason this happens is because the axis automatically rounds the limit to the nearest next minor grid. If this is not sufficiently close for your application, you may try manually changing the tick labels of the radial axis to give the correct appearance. Note that this will require you to adjust your data, so the plot makes sense.
2) Removing/altering the degree-tick labels:
% Using the code above
% Removing the label
set(findall(gcf, 'String', '30', '-or','String','60') ,'String', ' ');
% Altering the angular label
set(findall(gcf, 'String', '0'),'String', ' Zero');
% Altering the radial label
set(findall(gcf, 'String', ' 4'),'String', ' Four');
Notice that in order to change radial ticks two additional spaces are required in the call to "findall" to find the radial strings. In other words, although the radial string appears to be "4", in reality the string is " 4".

카테고리

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

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by