How to represent a 2D plot using color plot

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

 Réponse acceptée

Rik
Rik le 11 Août 2020
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')

Plus de réponses (0)

Catégories

En savoir plus sur Contour Plots dans Centre d'aide et File Exchange

Produits

Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by