Bug when plotting 3 points in scatter MATLAB R2022a
Show older comments
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")
Accepted Answer
More Answers (0)
Categories
Find more on Scatter Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


