Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
427 views
in Technique[技术] by (71.8m points)

transparency - Semi-transparent markers in Matlab Figures

I want to plot a scatter plot with filled markers and make them semi-transparent so when two or more markers overlap, the overlapping area will be more opaque.

I naively thought

sg = scatter(rand(1000,1),rand(1000,1), 'filled');
alpha(0.5)

would work, but it doesn't. Also

set(get(sg, 'Children'), 'FaceAlpha', 0.2)

doesn't work. Any ideas?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Here's some sample matlab code that makes transparent scatterplot points with patch objects:

x=randn(5000,1)*20;
y= randn(5000,1)*20;
t= 0:pi/10:2*pi;
figure();
for i=1:size(x)
    pb=patch((sin(t)+ x(i)),(cos(t)+y(i)),'b','edgecolor','none');
    alpha(pb,.1);
end

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...