Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MATLAB rose plot: increasing radial increments?

I am producing many angle histogram plots using rose2.m. I would like the scale showing the number of elements in each bin to range between 0-50, increasing by increments of 10, for all plots, even if the max number of elements on a particular plot is less than 50. Does anyone know how I can do this please? Thanks.

like image 995
Caroline Wallis Avatar asked Jul 01 '26 23:07

Caroline Wallis


2 Answers

This question is the same as this one but you are looking at a special case of rose2.

I was able to lock the max value to 50 with the following code. First I plot an empty point at 50 then hold on to lock the plot. rose2 then uses those bounds.

The code:

x = (rand(100,1)*pi);

maxHistogramValue = 50;

figure(44);
clf
% Set the max value to maxHistogramValue:
polar(0, maxHistogramValue,'-k')
hold on;

% Now use rose2:
rose2(x);
like image 152
Steve Avatar answered Jul 04 '26 21:07

Steve


Here is another example (based on @Steve's idea):

%# data and angular histogram
x = rand(400,1) .* 2*pi;
[t,r] = rose(x);                %# this does not generate a plot

%# set plot's max radial ticks
figure
rMax = 50;
h = polar(0, rMax);
delete(h)
set(gca, 'Nextplot','add')

%# draw patches instead of lines: polar(t,r)
[x,y] = pol2cart(t,r);
h = patch(reshape(x,4,[]), reshape(y,4,[]), 'b');
alpha(h, 0.5)       %# note: this switches to OpenGL renderer

screenshot

This way you get to control the maximum radius, though you can't really control the number of steps (POLAR function always prefers around 5 radial ticks; see the source code).

like image 39
Amro Avatar answered Jul 04 '26 20:07

Amro



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!