Asked by Sharah
on 13 May 2015

hello, i have been looking around for ages about this. there's a function in excel where i can plot data in circle.

for example i have i have an arra

y of time and force. in excel, i can put the time (x axis in circle and the force will goes in circle.

i tried polar function, compass but it does not turn out like i want to. here's the picture i got from excel.

if you can see from the picture attached, time is written at the outer circle and the force value at each time internal will follow.

anyone?

Answer by Star Strider
on 14 May 2015

I don’t know what data you’re plotting. See if this code can be adapted to do what you want:

th_x = [0 56

10 30

20 11

30 11

40 5

50 3

60 6

70 8

80 14

90 16

100 15

110 7

120 6

130 9

140 7

150 10

160 21

170 39

180 56

190 30

200 11

210 11

220 5

230 3

240 6

250 8

260 14

270 16

280 15

290 7

300 6

310 9

320 7

330 10

340 21

350 39];

xr = [repmat(th_x(:,2)', 10, 1); zeros(1,36)];

xr = [0 reshape(xr, 1, [])];

th = linspace(0, 359, length(xr));

I originally wrote this to be a ‘polar’ version of ‘bar’. The data ‘th_x’ has degrees in the first column and the values to be plotted in the second. It expands the data to span the 10-degree increments to produce the ‘rose’ plot effect.

Sharah
on 14 May 2015

basically what i am trying to do is to plot the x axis in form of circle, where the start point and the end point will meet. the y value will be the same as in normal plot, but obviously it will follow the x axis shape (which is in circle)

do you get what i mean?

Star Strider
on 14 May 2015

I sort of understand.

Can you attach your data (preferably as a .mat file) so I can experiment with it to see if I can reproduce the Excel plot in MATLAB?

Joseph Cheng
on 14 May 2015

so to add onto this you can adjust your x and y to be something like

t = 0 : .01 : 2 * pi;

P = polar(t, 15 * ones(size(t)));

set(P, 'Visible', 'off')

hold on

y = [1 1 1 1 1 1 1 10 10 10 10 10]

y = repmat(y,1,10);

x = 1:numel(y);

x = (360/numel(y)*x+90)*pi/180;

polar(x,y)

where the first one is just to "cheat" and scale the axis. The real issue right now is to change the axis labeling to be what x is actually. it's a difficult task as these are inserted text field and not adjustable using xlim and ylim. one would have to write something like

set(findall(gcf, 'String', '90') ,'String', num2str(0));

set(findall(gcf, 'String', '180') ,'String', num2str(round(numel(y)/4)));

which would then re-label polar label to what it would be in that slice. It would be feasible to wipe out all text labels and then write a loop to create and position txt labels in a circle around the polar plot area but i don't have the time to write it out. Maybe the file exchange has something to relabel polar plots and set tick spacing.

Sign in to comment.

Answer by Rohit Jain
on 15 May 2015

Sign in to comment.

Opportunities for recent engineering grads.

Apply Today
## 4 Comments

## Joseph Cheng (view profile)

## Direct link to this comment

https://it.mathworks.com/matlabcentral/answers/216538-plotting-radar-plot-in-matlab-like-the-one-in-excel#comment_284975

## Sharah (view profile)

## Direct link to this comment

https://it.mathworks.com/matlabcentral/answers/216538-plotting-radar-plot-in-matlab-like-the-one-in-excel#comment_285168

## Honglei Chen (view profile)

## Direct link to this comment

https://it.mathworks.com/matlabcentral/answers/216538-plotting-radar-plot-in-matlab-like-the-one-in-excel#comment_285338

## Rohit Jain (view profile)

## Direct link to this comment

https://it.mathworks.com/matlabcentral/answers/216538-plotting-radar-plot-in-matlab-like-the-one-in-excel#comment_285441

Sign in to comment.