Effacer les filtres
Effacer les filtres

Plot points with different brightness

5 vues (au cours des 30 derniers jours)
diego solerpolo
diego solerpolo le 2 Sep 2022
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?

Réponses (3)

Stijn Haenen
Stijn Haenen le 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;

KSSV
KSSV le 2 Sep 2022
Read about scatter

Star Strider
Star Strider le 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
See the scatter documentation on Vary Transparency Across Data Points for details.
.

Catégories

En savoir plus sur Scatter Plots dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by