Two colormaps in the same plot
7 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Turbulence Analysis
el 9 de Nov. de 2020
Comentada: Turbulence Analysis
el 1 de Dic. de 2020
Hi,
I am superimposing two images, here, I would like to use different colormap for first and second images. For e.g. jet for image 1 and hot for image 2..
I have tried this, however, at the end, both the images got the colromap defined for image 2. If somebody has gone through this kind of situtaion, please help me with this..
0 comentarios
Respuesta aceptada
Steve Eddins
el 10 de Nov. de 2020
The ColorBar object has an undocumented Colormap property. You can set this property directly to control the colors displayed by the ColorBar. You can use the documented properties such as Limits so that the display corresponds to your original data values.
Just be aware that the ColorBar's behavior with the respect to the Colormap property might change in a future release.
And don't tell anyone that I told you about this. ;-)
8 comentarios
Steve Eddins
el 1 de Dic. de 2020
I see now that it looks like your code is trying to create two different axes objects (ax1 and ax2), but it really only makes 1. The function gca returns the current axes, or it makes one if one does not already exist. So, this line:
ax2=gca;
does not make a second axes. It just returns the first. Because of that, you are not setting the colormaps of two different axes objects; rather, you are just overwriting the colormap of one.
I don't think you'll be able to get this transparent overlay idea to work in two different axes. My best suggestion is still to work in one axes and set the Colormap property of each colorbar directly, as in:
c1.Colormap = jet(256);
c2.Colormap = hot(256);
Más respuestas (1)
Steve Eddins
el 9 de Nov. de 2020
You can't display images with two different colormaps within the same axes. As a workaround, you could convert both images from indexed to rgb, like this:
rgb1 = ind2rgb(X1,jet(256));
rgb2 = ind2rgb(X2,hot(256));
These two images can then be displayed or superimposed together. RGB image display is independent from the colormap.
11 comentarios
Steve Eddins
el 9 de Nov. de 2020
Can you expand a little bit more in your replies? I don't think I'm getting enough information to be able suggest a workaround. Please say more about exactly what you are doing or displaying with the images so that it makes a difference what the CData values are.
Ver también
Categorías
Más información sobre Red 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!