How to represent a 2D plot using color plot
5 次查看(过去 30 天)
显示 更早的评论
I have the following two variables: x (it represent depth of a material from the surface), y (it represnt a variable which changes as the depth of the material increases)
x=[ 0 0.04 0.164 1 2 3 4 5 6 6.052 7 7.965 8 9 10 ]
y=[ 6201.67 8328.37 6201.67 3476.751 2432.011 1820.878 1387.272 1050.941 776.1486 763.13 543.7965 349.14 342.5326 165.0053 6.201674 ]
I have made a plot of y against y. However, it is required to made a color plot like varying color for y (based on its magnitude) as the depth increases ie. x. For high values of y a darker color which decreses as the value of y decreases. An example plot is attached below for illustration only. Please help me
0 个评论
采纳的回答
Rik
2020-8-11
It is a bit more complicated than simply using surf, since you don't have 2D data, just a vector. There are probably other ways to make this, but this is an easy one. If you want to label your axes, note that y is now in the z-direction.
x=[ 0 0.04 0.164 1 2 3 4 5 6 6.052 7 7.965 8 9 10 ] ;
y=[ 6201.67 8328.37 6201.67 3476.751 2432.011 1820.878 1387.272 1050.941 776.1486 763.13 543.7965 349.14 342.5326 165.0053 6.201674 ];
surf([x(:) x(:)],ones(numel(x),2),[y(:) y(:)],...
'EdgeColor','interp')
view(90,0)
xlabel('x')
zlabel('y')
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Surface and Mesh Plots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!