Create a plot of points on a circumference separated by radii

Hello. I need some help for realizing a plot.
Have you any idea about how to plot a circumference with points and radii as the one in this image?

Réponses (1)

Dyuman Joshi
Dyuman Joshi le 31 Mai 2023
Déplacé(e) : Matt J le 31 Mai 2023
You can use a set of points and polarscatter to achieve this.
What have you attempted yet?

5 commentaires

I tried this but the radii are not between the points but over them
% Parametri del plot
numCircles = 10; % Numero di circonferenze concentriche
numPoints = 20; % Numero di punti tra una corona e l'altra
% Calcola i raggi delle circonferenze concentriche
radii = linspace(0.1, 1, numCircles);
% Calcola gli angoli per i punti su ogni circonferenza
angles = linspace(0, 2*pi, numPoints+1);
angles = angles(1:end-1);
% Inizializza la figura
figure(1);
hold on;
axis equal;
grid on;
% Disegna le circonferenze concentriche
for i = 1:numCircles
r = radii(i);
theta = linspace(0, 2*pi, 100);
x = r * cos(theta);
y = r * sin(theta);
plot(x, y, 'k');
end
% Disegna i punti tra le circonferenze
for i = 1:numCircles-1
r1 = radii(i);
r2 = radii(i+1);
theta1 = linspace(0, 2*pi, numPoints+1);
theta1 = theta1(1:end-1);
theta2 = linspace(0, 2*pi, numPoints+1);
theta2 = theta2(1:end-1);
x1 = r1 * cos(theta1);
y1 = r1 * sin(theta1);
x2 = r2 * cos(theta2);
y2 = r2 * sin(theta2);
midX = (x1 + x2) / 2;
midY = (y1 + y2) / 2;
plot(midX, midY, 'k.', 'LineWidth', 5);
end
% Disegna i raggi che collegano i punti sfasati di un angolo
for i = 1:numCircles-1
r1 = radii(i);
r2 = radii(i+1);
theta1 = linspace(0, 2*pi, numPoints+1);
theta1 = theta1(1:end-1);
theta2 = linspace(0, 2*pi, numPoints+1);
theta2 = theta2(1:end-1);
x1 = r1 * cos(theta1);
y1 = r1 * sin(theta1);
x2 = r2 * cos(theta2);
y2 = r2 * sin(theta2);
angleDiff = (theta2 - theta1) / 2;
newTheta = theta1 + angleDiff;
endX = r2 * cos(newTheta);
endY = r2 * sin(newTheta);
for j = 1:numPoints
plot([x1(j) endX(j)], [y1(j) endY(j)], 'k');
end
end
hold off
xlim([-1 1])
ylim([-1 1])
% Aggiungi titolo e label agli assi
% xlabel('X');
% ylabel('Y');
That seems quite complicated.
Here's a simplified approach -
%Number of points
n=5;
%Range of angles
theta = 0:30:360;
%Range of radii
r = 0:n-1;
%Generating the set of points
[R,THETA]=meshgrid(r, theta);
%plotting the points
polarscatter(deg2rad(THETA), R, [], [0 0 0], 'filled')
%Modify ticks and tick labels as per requirement
thetaticks(15:30:360)
rticklabels([])
Dyuman Joshi
Dyuman Joshi le 1 Juin 2023
Modifié(e) : Dyuman Joshi le 3 Juin 2023
Hello @Lorenzo Lellini, did you check my answer?
@Dyuman Joshi - this seems almost spot on. But you might change the circumferential ticks, to leave each point appear to be inside a region, not on an edge.
%Number of points
n=5;
%Range of angles
theta = 0:30:360;
%Range of radii
r = 0:n-1;
%Generating the set of points
[R,THETA]=meshgrid(r, theta);
%plotting the points
polarscatter(deg2rad(THETA), R, [], [0 0 0], 'filled')
%Modify ticks and tick labels as per requirement
thetaticks(15:30:360)
rticks([1/2:n-1/2]) % Different
I changed only the very last line from what you did.
Dyuman Joshi
Dyuman Joshi le 3 Juin 2023
Modifié(e) : Dyuman Joshi le 3 Juin 2023
@John D'Errico, You are, of course, right that my answer is a bit incomplete.
The thing is, I was not sure if I wanted to do give the full solution and thought OP will figure it out based on my comments, so I left some bits.

Connectez-vous pour commenter.

Catégories

En savoir plus sur MATLAB dans Centre d'aide et File Exchange

Produits

Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by