Plot points with different brightness

15 ビュー (過去 30 日間)
diego solerpolo
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
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 Center および File ExchangeScatter Plots についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by