# Plot points with different brightness

조회 수: 6 (최근 30일)
diego solerpolo 2022년 9월 2일
답변: Star Strider 2022년 9월 2일
I have an array with different points, [a, b; c, d;...] (for each row, the entries are the (x,y) coordinates of a points, so that I have a point with coordinates (a,b), another one with coordinates (c,d), etc). I want to plot all these points, each of them with a different brightness. Imagine I have a function brightness=f(x,y). How do I plot all points (for example, square-shaped) each of them with the corresponding brightness I want?

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

### 답변 (3개)

Stijn Haenen 2022년 9월 2일
That is possible by making a RGB matrix, for each point you need one row with RGB values. In the example below i used gray scales, so R=G=B, and i used the function for brightness: f(x)=1/x.
x=[1,2,3];
color_100=[1,1,1]; %100 brightness, white color
color_map=color_100./x';
f=scatter(x,x,"filled");
f.CData=color_map;

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

KSSV 2022년 9월 2일
##### 댓글 수: 0이전 댓글 -2개 표시이전 댓글 -2개 숨기기

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

Star Strider 2022년 9월 2일
I am not certain what ‘brightness’ means, however there is a way to vary the transparency (alpha value) of points —
x = 1:10;
y = randi(9, 5, 10);
N = size(y,1);
cm = colormap(turbo(size(y,1)));
figure
hold on
for k = 1:N
p = scatter(x, y(k,:), 75, cm(k,:), 's', 'filled');
p.MarkerFaceAlpha = k/(N+1);
end
hold off
grid
See the scatter documentation on Vary Transparency Across Data Points for details.
.

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

### 카테고리

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