How do I create and assign custom color scheme per value on a scatter3 plot?

Plotting a path of latitude, longitude and altitude using scatter3, I want to assign a color scheme for each point based on its air temperature. How do I create a color gradient from the max/min temperatures values and automatically fill in the rest? Thank you.

 Risposta accettata

That seems to be described in the documentation for scatter3:
scatter3(X,Y,Z,S,C) draws each circle with the color specified by C.
  • If C is a vector with length equal to the length of X, Y, and Z, then the values in C are linearly mapped to the colors in the current colormap.

4 Commenti

Ok, so I define c as air temperature values. The default assignment is yellow at the high end and dark blue being the lowest. How do I programmatically dictate the color of the maximum and minimum values? Or perhaps assign color to the lowest value and somehow increment color change/intensity going up?

The colormap (link) function can help you decide on the range and increment you want.

You will probably have to experiment with this to get the result you want.

Accedi per commentare.

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by