I am going to draw a figure such as below picture in the MATLAB R2014b: .
This figure consists of many circles with different (random) colors and random sizes.
How is it possible to plot such this figure in MATLAB R2014b?
I am going to draw a figure such as below picture in the MATLAB R2014b: .
This figure consists of many circles with different (random) colors and random sizes.
How is it possible to plot such this figure in MATLAB R2014b?
The general idea is below. You'll need to modify it to ensure the circle centers and colors are chosen to suit your particular purpose.
% Define parameters
maxAxis = 100;
maxRadius = 10;
nCircles = 20;
% Random centres
xLoc = randi(maxAxis,nCircles);
yLoc = randi(maxAxis,nCircles);
% Random radii
radius = randi(maxRadius,nCircles);
% Random colours
allColours = rand(nCircles,3);
% Transform the data into position = [left bottom width height]
pos = [xLoc(:)-radius(:) yLoc(:)-radius(:) 2*radius(:)*[1 1]];
% Create and format the axes
ha = axes;
hold on;
axis equal;
box on;
set(ha,'XTickLabel',[],'YTickLabel',[]);
% Create the circles (must be done in loop)
for idx = 1:nCircles
rectangle(...
'Position',pos(idx,:),...
'Curvature',[1 1],...
'FaceColor',allColours(idx,:),...
'EdgeColor','none');
end
See
>> doc retangle
for more info.
Without spelling out the code:
[0,0]
and radius 1.r
.sqrt(pos(1)^2+pos(2)^2) + r > 1
) continue with 3.Update: Example
Alright, so I just wanted to try this. I'm sure this is not the best implementation, but: