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!Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の 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)

