Generate data from plot - colormap
6 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I have a colormap MATLAB figure and have to get the data from that colormap so that I can edit it. All I need to do is remove two rows from the colormap. Right now the colormap has rows 1-6, and I want it to show data only from rows 1-4. 

8 comentarios
Walter Roberson
el 8 de En. de 2021
A colormap is an n x 3 array of data.
There is more than one way that colormaps can be used.
In one mode, the input is expected to be non-negative integers, and the (value plus 1) is used as the index into the colormap to determine which color to output corresponding to the location.
In another, more common mode, with the default settings, the maximum and minimum of the data to be presented are calculated, and floor((data - minimum)./(maximum minus minimum) * (number of colors)) + 1 is calculated and used as the index into the colormap -- so the smallest data value is mapped to the first color in the map, and the largest value is mapped to the last color in the map, and everything between is mapped linearly -- half way through the data range would be mapped to half way through the color map for example. When I look at the colorbar, I believe this kind of color mapping is what has been done for this figure.
You can reduce the number of colors in a colormap by using colormap() with a smaller map. For example,
cmap = colormap(); %fetch current
colormap(cmap(1:4,:)) %use only the first four colors
I doubt that is what you want, however. It looks to me as if you only want the first four
values, which is a very very different matter, probably most easily handled by using ylim.
values, which is a very very different matter, probably most easily handled by using ylim.
Cris LaPierre
el 8 de En. de 2021
Respuestas (0)
Ver también
Categorías
Más información sobre Color and Styling en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!