Adding a marker to Data Marker to Heatmap (via imagesc)
Show older comments
Hello, i have a matrix Ib
2.29 2.29 2.29 2.29 1.89 1.89 1.89 1.89 1.77
2.29 2.29 2.29 2.29 1.89 1.89 1.89 1.89 1.77
1.77 1.77 1.77 1.77 1.89 1.89 1.89 1.89 0
1.77 1.77 1.77 1.77 1.89 1.89 1.89 1.89 0
2.81 2.81 2.81 2.81 1.89 1.89 1.89 1.89 0
2.81 2.81 2.81 2.81 1.89 1.89 1.89 1.89 0
0 0 0 0 2.50 2.50 2.50 2.50 0
I want to view as a heat map, so use imagesc to do this:
subplot(7,6,[22,23,24]);
imagesc(Ib2); colorbar; title('Std Background el','FontSize',8)
axis off
This gives me:

I want to be able to highlight any zeros visually and so wanted to either colour that data with a green colour, or if thats too difficuly just plot a green cross superimposed.
I have tried this:
[row,col]=find(Ib==0)
subplot(7,6,[22,23,24]); hold on;
plot(col,row,'gx')
But this just creates a new plot over the top.
Any suggestions please.
Thanks
Jason
2 Comments
Adam
on 21 Feb 2019
Where are you defining the colourmap since hot is not the default colourmap? It looks, from the colourbar, to be a very coarse colourmap of maybe just 10 points?
You can edit a colourmap, such as hot, if you wish as e.g.
mycmap = hot( 10 );
mycmap( 1,: ) = [0 1 0];
colourmap( hAxes, mycmap );
where hAxes is the handle of the axes you want to apply it to.
Jason
on 22 Feb 2019
Accepted Answer
More Answers (2)
Krishna Zanwar
on 27 Feb 2019
0 votes
Hey Jason,
The second subplot command is creating another plot over the top of your original plot. Just remove the second subplot command and your code should work fine.
2 Comments
Jason
on 27 Feb 2019
Krishna Zanwar
on 28 Feb 2019
Hey Jason,
As a work around you can remove the colorbar from the previos image and it will work.
Walter Roberson
on 28 Feb 2019
temp = hot(10);
cmap = repelem(temp, 409, 1);
cmap(1,:) = [0 1 0];
colormap(cmap)
This is not exactly correct as it creates a 4090 entry colormap instead of 4096.
Categories
Find more on White in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!