How to show values on heatmap belonging to a different dataset.

I have a torque and RPM dataset and i am plotting %torque using heatmap. but the value(text) in each grid of %torque heatmap i want to display some other data set number. The reason i am doing this is so that in the background i can see %torque heatmap and see the color and on top of it will have the value of the other data set which me help me compare the value. Can this be done in matlab??
Thanks

5 Comments

Probably, however I understand what you mean. Do you want the colors of the heatmap grid to be independent of the values displayed in the heatmap grid? If this is the case, then I'd use another function that provides more flexibility, like imagesc combined with text.
Can you draw a sketch and/or provide some data?
ok so if you look at the heatmap its showing the values for what its plotted against. but what i need is show the heat map of these values but to display the text of some other dataset. (independent of heatmap)
I understand. I would definitely skip heatmap and go for imagesc + text. It's quite straightforward and you do not have to deal with the heatmap object which is not very flexible. I can give you some code if you upload some data.
Hey! Jonas. really appreciate your help but unfortunately i wont be able to upload any data due to confidentiality concerns. However i am dealing with two matrix both of the order of 13 rows and 25 columns. you can prob make two separate rand matrix of that dimension and share your code. I can look into it and share my results with you. let me know if you would need more info about the data.
Thats fine! Ill do it tonight if no one beat me to it :)

Sign in to comment.

 Accepted Answer

Here's an example using imagesc and text
% Grid
[X,Y]=meshgrid(1:10,1:10);
% Two data sets to compare
A=rand(10,10);
B=-10.*rand(10,10);
% Plot grid
figure;
h=imagesc(X(:),Y(:),A)
% Text
txt=sprintfc('%.1f',B(:))
text(X(:),Y(:),txt,'horizontalalignment','center','verticalalignment','middle')
colorbar
You can of course easily change the grid dimensions if you want something more meaningful on the axes.

3 Comments

Thanks a ton jonas. I just made few changes to the code as per my data requirements. it worked beautifully. thank you very much really appreciate all your help.
Is it possible to do this with a heatmap() plot?

Sign in to comment.

More Answers (0)

Categories

Asked:

on 10 Sep 2018

Commented:

on 22 Oct 2023

Community Treasure Hunt

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

Start Hunting!