首页 > 其他 > 详细

使用matlab画半透明椭圆

时间:2014-11-14 21:02:08      阅读:511      评论:0      收藏:0      [点我收藏+]

先上最终效果图:

bubuko.com,布布扣

本来是想直接用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‘)

使用matlab画半透明椭圆

原文:http://www.cnblogs.com/instant7/p/4098115.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!