fill
46 次查看(过去 30 天)
显示 更早的评论
Hi,
Is it possible to automatically alter the transparency of colors using the fill command?
For example, I would want to use:
fill (x,y, 'r');
but make the red color transparent.
Thanks!
回答(2 个)
Matt Fig
2011-5-12
t = (1/16:1/8:1)'*2*pi;
x = sin(t);
y = cos(t);
h = fill(x,y,'r');
% Choose a number between 0 (invisible) and 1 (opaque) for facealpha.
set(h,'facealpha',.5)
Also, see the edgealpha property of h. Look at set(h) to see all the properties you can set.
5 个评论
Matt Fig
2011-5-12
I cannot reproduce the problem. Could you describe the data more? For example, are the black lines the boundaries of one long skinny patch object squeezed between two larger patches? Or are they the boundaries of the larger patch objects? If you can't find a work around, you might be better off setting the edgecolor to none and plotting the edges by using the LINE function. For example:
t = (1/16:1/8:1)'*2*pi;
x = sin(t);
y = cos(t);
h = fill(x,y,'r','edgecolor','none');
set(h,'facealpha',.5)
X = [x;x(1)];
Y = [y;y(1)];
line(X,Y,'color','k','linewidth',3) % Make the edges...
Teja Muppirala
2011-5-12
Just for fun, and because windowbuttonmotionfcns are totally underappreciated:
t = (1/16:1/8:1)'*2*pi;
x = sin(t);
y = cos(t);
h = fill(x,y,'r');
F = @(x) alpha(max(min(x,1),0));
set(gcf,'windowbuttonmotionfcn','F( ([1 0]*get(gca,''currentp'')*[0;1;0] - min(ylim)) / diff(ylim) )')
1 个评论
Matt Fig
2011-5-12
编辑:madhan ravi
2018-11-23
Nice! I prefer symmetry myself:
t = (1/16:1/8:1)'*2*pi;
x = sin(t);
y = cos(t);
h = fill(x,y,'r');
axis square
set(gcf,'windowbuttonmotionfcn','set(h,''facealpha'',min(1,abs(norm(get(gca,''currentpoint''),''fro'')-sqrt(2))))')
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Lighting, Transparency, and Shading 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!