使用matlab画半透明椭圆

先上最终效果图:

本来是想直接用scatter和alpha来画的,结果在尝试以下代码后,发现无法显示透明效果

scatter(rand(1000,1),rand(1000,1), 'filled');

alpha(0.5)

具体原因可以参考stackoverflow(http://stackoverflow.com/questions/6366404/semi-transparent-markers-in-matlab-figures)

 

无奈,只能自己用patch来画了,代码如下:

clear all
close all

x=rand([500,1])*0.5;
y= rand([500,1])*1;
s = rand([500,1])*0.03;
t= 0:pi/10:2*pi;
figure();
grid on
for i=1:size(x)
pb=patch((s(i)*sin(t)*0.5+ x(i)),(s(i)*cos(t)+y(i)),'b','edgecolor','k');
alpha(pb,.3);
end
hold on
saveas(gcf,'D:\\alphaEllipse.jpg')

posted @ 2014-11-14 20:42  KevinHwang  阅读(1229)  评论(0)    收藏  举报