How to change the color of the matlab line (e.g. colormap)?

I have a 2D space in which the value of a function is defined (you can think of it as a variety). Now I have built the value of the function using the path and changed the color code to something softer than the inkjet one. So far it looks good.

Now I want to draw a string representing the state in time in my space. This is also possible with the plot command. But I want some more improvements: there is an additional state that is now hidden (value 0 ... 50). I would like the color of the line to change according to this hidden state. Therefore, in a sense, apply a separate flower map to a line constructed by plot , for example, on a waterfall graph.

Is this possible (or something similar) with matlab?

thanks

+6
source share
3 answers

Take a look at cline.m from file sharing, I think this is exactly what you need.

+2
source

If you want to either use interpolated shading or change colors using a color map, then you want to build your data in a grid and set the edgecolor property edgecolor . Please note that in order to build it as a grid, you need to duplicate it so that it has a size of at least 2 in each direction.

 h = mesh([X(:) X(:)], [Y(:) Y(:)], [Z(:) Z(:)], [C(:) C(:)], ... 'EdgeColor', 'interp', 'FaceColor', 'none'); 

You can also see the MeshStyle property if you want to build multiple lines at once.

This solution is much better than the one used in cline , because it creates only one graphic object, not n .

+7
source

I can recommend Color Record strings from file sharing. It has good feedback and uses a color map to determine the colors displayed, I use it successfully in several projects.

+2
source

Source: https://habr.com/ru/post/904064/


All Articles