using colormap in plot3d

4 次查看(过去 30 天)
Hello everyone,
I have a matrix of 500x3 in which columns are x,y,z values of a single point respectively. I am plotting this with scatter3 function and use the Z values as the colormap. But now, I want the every Z value increase in some interval(for ex. from 5 to 6) but X and Y are constant for every point. So I used to have 500 points in the plot but now I want to have 500 lines instead of points(with constant x,y and changing z means line to me). I realized I can do that with plot3d but I cant use the Z values as colormap in that.
Is there any other way to do this?
Thank for you answers

采纳的回答

Adam Danz
Adam Danz 2020-4-21
编辑:Adam Danz 2020-4-21
plot3(x,y,z) will produce 1 line object for each column of the inputs. Each line object can have its own color. So, all you have to do is arrange the data properly.
h = plot3([x(:).'.*[1;1]], [y(:).'.*[1;1]]), [z1(:).', z2(:).'], '-');
set(h, {'Color'}, mat2cell(jet(numel(x)),ones(numel(x),1),3));
The syntax [x(:).'.*[1;1]] produces two rows of identical x values.
The mat2cell() syntax converts your color matrix to cell array of 1x3 values.
  4 个评论
Umut Ege Ulucay
Umut Ege Ulucay 2020-4-25
Sorry for late answer. It totally worked. Thanks a lot!
Adam Danz
Adam Danz 2020-4-26
Glad I could help!

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Color and Styling 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by