# Circular bar graph in matlab

31 visualizzazioni (ultimi 30 giorni)
SChow il 27 Lug 2022
Risposto: Chunru il 27 Lug 2022
Hi, I have a table with two columns(headers- Country, Population) and 100 rows. I would like to plot a circular bar graph like in https://www.python-graph-gallery.com/circular-barplot-with-groups . Is there an inbuilt fucntion for it? Any help is appreciated.
##### 1 CommentoMostra -1 commenti meno recentiNascondi -1 commenti meno recenti
Walter Roberson il 27 Lug 2022
Sorry, there is no built-in function for that.

Accedi per commentare.

### Risposte (1)

Chunru il 27 Lug 2022
% Some data
T.Country = string(('A':'Z')');
T.Population = randi([1000 10000], size(T.Country));
T = struct2table(T);
n = height(T);
dtheta = 360/n; % sector for each country
gap = 0.1; % gaps betwen adjacent contries
npoints = 21; % npoints for each sector
figure; hold on;
for i=1:n
theta = linspace((i-1)*dtheta, (i-gap)*dtheta, npoints);
patch([0 T.Population(i)*cosd(theta)], [0 T.Population(i)*sind(theta)], 'b');
rtext = T.Population(i)+300;
text(rtext*cosd((i-.5)*dtheta), rtext*sind((i-.5)*dtheta), T.Country(i));
end
axis equal
axis off
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Categorie

Scopri di più su Labels and Annotations in Help Center e File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by