plot3+color
来源:互联网 发布:河北软件学院 编辑:程序博客网 时间:2024/05/16 01:58
Q:I have a [N,4] data set which I want to visualize as 3d line representing the fourth column as a color. Any ideas on how to do this?
A: Simplest solution is to make a scatter plot rather than a line plot:
</pre>% Make some fake datax = linspace(0,1); % x = data(:,1);y = cos(10*x); % y = data(:,2);z = sin(15*x); % z = data(:,3);c = x+y-z; % c = data(:,4);figurescatter3(x,y,z,2,c)colorbarIf, however, you really need lines, you probably need to brute-force it.
figurecmap = colormap;% change c into an index into the colormap% min(c) -> 1, max(c) -> number of colorsc = round(1+(size(cmap,1)-1)*(c - min(c))/(max(c)-min(c)));% make a blank plotplot3(x,y,z,'linestyle','none')% add line segmentsfor k = 1:(length(x)-1) line(x(k:k+1),y(k:k+1),z(k:k+1),'color',cmap(c(k),:))endcolorbarHere I'm using the default colormap for the figure to define the colors. You can specify colors however you want, as long as you have a way to index into them.
Qer: Excelent solution, I would only like to add a change in the colorbar limits
caxis([ min(c) , max(c)]) % colorbar limitsreference:
http://www.mathworks.com/matlabcentral/answers/34750-plot3-color
0 0
- plot3+color
- papa的儿子 matlab plot3 color peaks
- color #
- color
- color
- Color
- color
- color
- color
- Color
- Color
- color
- COLOR
- Color
- color
- color
- Color
- color
- failed to create the java virtual machine
- 模板方法模式
- zhiqiu Blog的第一篇博客
- [转]离职总结 | 如何做个好员工?
- Oracle SID在本机上已经存在,请指定一个不同的SID”的解决办法
- plot3+color
- 暑假第十天,7月15号
- ACM 暑期培训——最短路/最小生成树专题
- 编程小练习2:数组乘积
- ExpandableListView实现方式之SimpleExpandableListView
- UVA 12378 Ball Blasting Game
- 根据屏幕大小设置字体
- poj 3625 Building Roads
- no mapping found for http request with uri