How to remove what outside the polar coordinate in polarscatter
2 ビュー (過去 30 日間)
古いコメントを表示
I want to remove the lines outside the polar coordinate
For example with this code
th = [0.175 2.50];
r = [30 25];
polarscatter(th,r,9000);
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1081035/image.png)
But what I want is something like this
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1081040/image.png)
0 件のコメント
回答 (1 件)
Poorna
2023 年 8 月 29 日
Hi,
I understand that you would like to clip the markers outside a specific radius. But a marker cannot be directly clipped in MATLAB. However, you can achieve the same effect by plotting the marker as a circle and limiting the radial axis of the polar plot using the “rlim” function.
Below is a sample code that would achieve the required result.
%define centers of the markers
th = [0.175 2.50];
r = [30 25];
%define the radius of the markers required.
marker_radius = 10;
%define the coordinates of the marker circle.
theta = linspace(0,2*pi,100);
[x,y] = pol2cart(theta, marker_radius);
for idx = 1:2
%convert the coordinates from polar to cartesian
[x_c, y_c] = pol2cart(th(idx), r(idx));
[th_points, r_points] = cart2pol(x+x_c, y+y_c);
%plot the marker circle
polarplot(th_points, r_points, "blue");
hold on
end
%limit the radius to clip the marker circles
rlim([0 30]);
hold off
Hope this helps!
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Polar Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!