Plot points with different brightness
10 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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?
0 Kommentare
Antworten (3)
Stijn Haenen
am 2 Sep. 2022
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;
0 Kommentare
Star Strider
am 2 Sep. 2022
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
.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Scatter Plots finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!