How to include a vertical scale besides of a polar plot ?
이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
이전 댓글 표시
I want to draw a vertical bar besides of a polar plot like in the picture attached. Also the legend in the same position as shown in figure.
Edit: This issue got solved but the i want to allocate ticks and ticklabels by using somecode as shown below. It is not working properly.
a=0:0.1:2*pi;
b=rand(size(a));
c=0.5*rand(size(a));
figure
hold off
polar(a,b,'g-')
hold on
polar(a,c,'r-')
tick = ceil(min(b))-1:0.5:ceil(max(b));
hBar.Ticks = [tick];
hBar.TickLabels = tick;
채택된 답변
This is easy, but you need to use handles if you want the figure to look like the one you show. And also, you have to think of the bar, as the polar plot will have the values on the concentric circles of the polar plot. Anyway, here is the code:
First, some data
% the data
a=0:0.1:2*pi;
b=rand(size(a));
c=0.5*rand(size(a));
Now display it in a figure with polar plot
% create the plots
figure
hold off
polar(a,b,'g-')
hold on
polar(a,c,'r-')
Now add the legend, grab the handle and reposition:
hLegend = legend('a','b','Location','NE');
hLegend.Position = [0.7830 0.8806 0.1036 0.0869];
I would say that the figure looks good so far, but if you want the bar, add it and grab the handles, change the position, the ticks and the labels of the ticks:
% Add the bar, grab handles
hBar = colorbar;
hBar.Position = [ 0.1112 0.1024 0.001 0.8167];
hBar.Ticks = [0.05:0.1:1 ];
hBar.TickLabels = [10 0 -10 -20 -30 -30 -20 -10 0 10 ];
댓글 수: 11
I want to create the ticks and tick labels by means of code as illustrated below, but the tick labels are not getting updated accordingly. Is there any way to do like that ?
tick = ceil(min(b))-1:0.5:ceil(max(b));
hBar.Ticks = 0:0.5:length(tick);
hBar.TickLabels = tick;
To do that, you need to make sure that your two vectors have the same lengths:
>> ceil(min(b))-1:0.5:ceil(max(b))
ans =
0 0.5000 1.0000
>> 0:0.5:length(tick)
ans =
Columns 1 through 5
0 0.5000 1.0000 1.5000 2.0000
Columns 6 through 7
2.5000 3.0000
>>
So, the problem is on the values that you are passing. I still think that the bar is not necessary as the values are included directly in the plot, try the following:
%%
log_b = 10*log(0.1*b);
log_c = 10*log(0.1*c);
% create the plots
hold off
polarplot(a,log_b,'g-')
hold on
polarplot(a,log_c,'r-')
rlim([min([log_b log_c]) max([log_b log_c])])

There you have the values of the two plots in logarithmic scale and in the polar grid.
If this solves your question, please accept the answer. If not, let me know.
Yeah this solves the problem, I have only one last question about how to thicken only the outer radial border of the plot and how can we control the number of radial minor grid lines ?
ax = polaraxes;
ax.LineWidth = 1; % This makes every line thicker
ax.RMinorGrid = 'on'; % Puts more number of radial divisions and making plot to bearly visible
That is a bit more tricky ... you could plot another line that lands exactly on the outer radial border and would visually give your result.
For the grid, you can keep the minor ones, but then make the major ones darker, e.g.
ax.GridAlpha=0.5;
and that gives a good view
I am facing one trouble when i used the location property rather than position as you illustrated. Now i am getting this colormap instead of a simple vertical line as obtained when position property is used. How can i turn off this colormap and making only vertical scale visible ?

Notice that the position property handles the width of the bar:
hBar.Position = [ 0.1112 0.1024 0.001 0.8167];
by using 0.001 the bar becomes very thin and thus has no colours.
but i have to make the bar to be of same length as of polar plot in parallel. This position argument is not helping in achieving what i wanted.
Grab the handle of the axes before plotting, then check the position
h1=axes;
>> polar(a,c,'r-')
>> h1.Position
ans =
0.1300 0.1100 0.7750 0.8150
Then when you create your colorbar you can match the positions:
>> hBar = colorbar;
>> hBar.Position
ans =
0.7568 0.1095 0.0381 0.8167
>>
I didn't get your can you explain it in a detailed manner
This requires some knowlegde of handles, try the following:
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Polar Plots에 대해 자세히 알아보기
참고 항목
2020년 8월 11일
2020년 8월 13일
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)

