Plot points with different brightness

10 次查看(过去 30 天)
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
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
KSSV 2022-9-2
Read about scatter

Star Strider
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