Bug when plotting 3 points in scatter MATLAB R2022a
Afficher commentaires plus anciens
I have found a bug in the scatter function that I'm not sure how to tackle. If I have a scatter plot with only three elements I get the error: Invalid RGB triplet. Specify a three-element vector of values between 0 and 1. This is because the program thinks I am trying to input an RGB triplet, when I want them to fit within a broader context.
colormap("jet");
X = 1:7;
Y = X;
color_map = X;
scatter(X,Y,45,color_map,"o","filled")
X = 1:3;
Y = X;
color_map = X;
scatter(X,Y,45,color_map,"o","filled")
I can work arround the problem, by plotting each point twice.
X = 1:3;
Y = X;
color_map = X;
if length(X)==3
X = [X,X];
Y = [Y,Y];
color_map = [color_map,color_map];
end
scatter(X,Y,45,color_map,"o","filled")
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Scatter Plots dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



