Is it possible to write
plot(x,y,color)
where x, y and color are all arrays of the same length. color is an array to set a color for all points drawn by x and y arrays, i.e. coordinate (x(i), y(i)) has a color: color(i). It's easy to write in the component form in a for loop, but I'd like to write in the vector form.

 채택된 답변

KSSV
KSSV 2018년 12월 19일

0 개 추천

Read about scatter . Also check the below option:
x = 0:.05:2*pi;
y = sin(x);
z = zeros(size(x));
col = x; % This is the color, vary with x in this case.
surface([x;x],[y;y],[z;z],[col;col],...
'facecol','no',...
'edgecol','interp',...
'linew',2);

댓글 수: 1

a a
a a 2018년 12월 19일
편집: a a 2018년 12월 20일
Thank you. What does [x;x] etc mean? Why not just surface(x,y,col), as in scatter(x,y,10,col)?
I need col to be a color string.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Scatter Plots에 대해 자세히 알아보기

태그

질문:

a a
2018년 12월 19일

편집:

a a
2018년 12월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by