Specifying color as hex works for plot, but not for scatter
I was caught off-guard that specifying color as a hexadecimal value works for plot(), but not for scatter(). It does seem documented, but I could not think of any fundamental reason why it shouldn’t work.
(I’m not sure this is a question. 😊)
N = 500;
color_hex = ‘#ff0000’;
color_rgb = hex2rgb(color_hex);
x = rand(N,1);
y = rand(N,1);
figure
plot(x,y,’.’,"Color",color_rgb)
figure
plot(x,y,’.’,"Color",color_hex)
figure
scatter(x,y,[],color_rgb)
figure
scatter(x,y,[],color_hex)I was caught off-guard that specifying color as a hexadecimal value works for plot(), but not for scatter(). It does seem documented, but I could not think of any fundamental reason why it shouldn’t work.
(I’m not sure this is a question. 😊)
N = 500;
color_hex = ‘#ff0000’;
color_rgb = hex2rgb(color_hex);
x = rand(N,1);
y = rand(N,1);
figure
plot(x,y,’.’,"Color",color_rgb)
figure
plot(x,y,’.’,"Color",color_hex)
figure
scatter(x,y,[],color_rgb)
figure
scatter(x,y,[],color_hex)Â I was caught off-guard that specifying color as a hexadecimal value works for plot(), but not for scatter(). It does seem documented, but I could not think of any fundamental reason why it shouldn’t work.
(I’m not sure this is a question. 😊)
N = 500;
color_hex = ‘#ff0000’;
color_rgb = hex2rgb(color_hex);
x = rand(N,1);
y = rand(N,1);
figure
plot(x,y,’.’,"Color",color_rgb)
figure
plot(x,y,’.’,"Color",color_hex)
figure
scatter(x,y,[],color_rgb)
figure
scatter(x,y,[],color_hex) scatter, plot, color MATLAB Answers — New Questions
​