|
别人的问题,在一个图里画不同透明度的圆。- MinVal = -1;
- MaxVal = 1;
- MaxRadius = 0.5;
- nCircles = 10;
- Dimension = 2;
- Circles = zeros(nCircles, Dimension);
- Radius = zeros(nCircles, 1);
- cmap = jet(nCircles); %// define colors.
- alpha = .1; %// define level of transparency
- for i = 1 : nCircles
- Circles(i,:) = unifrnd(MinVal, MaxVal, [1, Dimension]);
- Radius(i) = unifrnd(0, MaxRadius, 1);
- end
- t = 0 : .1 : 2 * pi;
- hold on;
- for i = 1 : nCircles
- x = Radius(i) * cos(t) + Circles(i,1);
- y = Radius(i) * sin(t) + Circles(i,2);
- patch(x, y, 'none', 'facecolor', cmap(i,:), 'facealpha', alpha*i, ...
- 'edgecolor', 'none'); %// plot filled circle with transparency
- end
- axis equal; %// same aspect ratio in both axes
- grid on;
复制代码
|
|