Color map a surface plot based on a 4th variable

7 visualizzazioni (ultimi 30 giorni)
MRR
MRR il 20 Mag 2020
Commentato: MRR il 20 Mag 2020
Hi
I have 2 surface plots: surf(X,Y,Z1) and surf(X,Y,Z2). Now I am trying to color map both the surface plots according to a 4th variable W. To elaborate, though Z1 > Z2, but W1 < W2 and I am trying to include this information on my surface plots by means of color maping.
If the colormap was done based on variable Z, then figure 1 would give a warmer surface than figure 2 since Z1>Z2. But I am expecting a colder surface for figure 1 (since W1 is smaller) and a warmer surface for figure 2 (as W2 is larger) so that the Z axis height shows that Z1>Z2 but at the same time, color map represents the fact that W1 < W2.
Any help/suggestion is greatly appreciated.
Thanks again,
-Muhammad
  3 Commenti
David Goodmanson
David Goodmanson il 20 Mag 2020
Hi Muhammad,
Would help to have an example as darova has suggested. WIthout getting into the interpretation of warm vs cold (which could depend on the colormap and colorbar), It sounds like you want a result B with the colors reversed compared to result A.
However, just the condition W1 < W2 is not enough to get that result. By default Matlab scales the fourth surf input to cover the entire range of the colormap. So scale changes or level changes to the fourth input don't do anything. If you try the following code (featuring our venerable friend peaks(40) ), even though W1 < W2, all of the first three plots are exactly the same.
In the last plot, the fourth input to surf has a change of sign of the variation of z, and the colors are reversed.
[x y z] = peaks(40)
w2 = z-1;
w1 = z-3; % w1 < w2
figure(1)
surf(x,y,z,z) % same as default, surf(x,y,z)
figure(2)
surf(x,y,z,w1)
figure(3)
surf(x,y,z,w2)
figure(4)
surf(x,y,z,-z)
MRR
MRR il 20 Mag 2020
Hi
Thanks for your reply and sorry for any possible confusions. Attached a data set that I intend to plot in a 3D surface. As the headers of the columns of the data sheet, I need the three axes of the surface plot to represent X, Y and Z but the the color map needs to be according to the fourth column Q.
Thereby, if a row with any Z but smaller Q (say, row 1) the color map would be colder (lower level of the color bar) since Q is smaller, and if Q is larger (say last row of the xlsx file), it should have a warmer (upper level of the color bar) color.
Thanks for your help.

Accedi per commentare.

Risposte (0)

Prodotti


Release

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by