Mathematica中文论坛-非官方

标题: 豆粑粑 画不同透明度的圆 [打印本页]

作者: meatball1982    时间: 2016-10-23 09:54
标题: 豆粑粑 画不同透明度的圆
别人的问题,在一个图里画不同透明度的圆。
  1. MinVal = -1;
  2. MaxVal = 1;
  3. MaxRadius = 0.5;
  4. nCircles = 10;
  5. Dimension = 2;
  6. Circles = zeros(nCircles, Dimension);
  7. Radius = zeros(nCircles, 1);
  8. cmap = jet(nCircles);                    %// define colors.
  9. alpha = .1;                              %// define level of transparency

  10. for i = 1 : nCircles
  11.     Circles(i,:) = unifrnd(MinVal, MaxVal, [1, Dimension]);
  12.     Radius(i) = unifrnd(0, MaxRadius, 1);
  13. end

  14. t = 0 : .1 : 2 * pi;

  15. hold on;
  16. for i = 1 : nCircles
  17.     x = Radius(i) * cos(t) + Circles(i,1);
  18.     y = Radius(i) * sin(t) + Circles(i,2);
  19.     patch(x, y, 'none', 'facecolor', cmap(i,:), 'facealpha', alpha*i, ...
  20.         'edgecolor', 'none'); %// plot filled circle with transparency
  21. end

  22. axis equal; %// same aspect ratio in both axes
  23. grid on;
复制代码








fig_circle_alpha_mul.png (71.15 KB, 下载次数: 1332)

fig_circle_alpha_mul.png





欢迎光临 Mathematica中文论坛-非官方 (http://ilovemathematica.com/) Powered by Discuz! X3.2