Transparency (MarkerFaceAlpha) in scatter not working

조회 수: 6 (최근 30일)
mootje_3000
mootje_3000 2019년 5월 22일
편집: mootje_3000 2019년 5월 23일
I have the following lines in my code. I'm trying to make certain points transparent, but whatever I do and even when lowering "tr" to 0.00001, the points just do not get transparent. I've also tried it with the t.MarkerFaceAlpha in the code, also does not help. Why does the transparency not work? Is there another way to make it work?
batch = 100;
batcho = 0:batch-1;
for i=1:c_max;
color = cm(i,:)
x = cl{i}(:,1);
y = cl{i}(:,2);
size = (cl{i}(:,3).^1)*2;
tr = (cl{i}(:,3).^5)*1;
for j = 1 : batch : size(cl{i}(:,1),1) - batch + 1
t = scatter(x(j+batcho), y(j+batcho), size(j+batcho), 'MarkerFaceAlpha', tr(j), 'MarkerEdgeColor',color);
t.MarkerFaceAlpha = tr(j)
end
t = scatter(x(j+batch:end), y(j+batch:end), size(j+batch:end),'MarkerFaceAlpha', tr(j), 'MarkerEdgeColor',color);
t.MarkerFaceAlpha = tr(j)
end
I'm using batch in my code because I have 250k points to plot. cl contains different groups that add up to 250k data points
  댓글 수: 8
Adam
Adam 2019년 5월 23일
Within a single scatter plot object all points must have the same transparency. This appears to be what your original code is doing too since you are using a new call to scatter every time round your for loop where your alpha value changes.
mootje_3000
mootje_3000 2019년 5월 23일
편집: mootje_3000 2019년 5월 23일
I've also tried it without using the batches, i.e.
for i=1:c_max;
color = cm(i,:)
x = cl{i}(:,1);
y = cl{i}(:,2);
size = (cl{i}(:,3).^1)*2;
tr = (cl{i}(:,3).^5)*1;
for j = 1 : size(x,1)
t = scatter(x(j), y(j), size(j), 'MarkerEdgeColor',color);
t.MarkerFaceAlpha = tr(j)
end
end
But this takes too long to run for 250k data points. Is there a faster way of making every single data point get a different transparency?

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Scatter Plots에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by