Effacer les filtres
Effacer les filtres

'MarkerFaceColor' according to y value

16 vues (au cours des 30 derniers jours)
aneps
aneps le 13 Nov 2022
Is it possible to set the 'MarkerFaceColor' of the x y plot accroding to y value? I want matlab automatically choose accroding to any scale for eg. lowerst value from blue to highest value to red.

Réponses (2)

Walter Roberson
Walter Roberson le 13 Nov 2022
No it is not possible with any documented method (maybe with undocumented methods).
The workaround is to not place markers in your plot() call, and instead
pointsize=10;
shape = 's';
hold on
scatter(x, y, pointsize, y, shape, 'filled')
hold off
If you want the edge color to be different than the face color then you will need to pass in options.
Note that most markers are drawn completely by edge and setting face color does not affect them.

David Hill
David Hill le 13 Nov 2022
x = linspace(0,3*pi,200);
y = cos(x) + rand(1,200);
sz = 25;
c = y/max(y)*10;
scatter(x,y,sz,c,'filled')
hold on;
plot(x,y)

Catégories

En savoir plus sur 2-D and 3-D Plots dans Help Center et File Exchange

Produits


Version

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by