13

I am trying to create a heat map using MATLAB, but the default function in MATLAB program doesn't any sense to me.

http://www.mathworks.com/help/bioinfo/ref/heatmap.html

Is there anyone who can help me with labeling first, so that I can read through the other function myself after that? Or is there any other program which will have a more user-friendly interface?

HeatMap(Data, ...'RowLabels', RowLabelsValue, ...) 

I have a data set of a 81*2 matrix and my label is a 81*1 cell for x-axis and 1*2 for y-axis. Now I can successfully import the excel data and plot the data using a heat map, but I have a hard time fill in the variable in the HeatMap function.

Thanks so much.

2
  • 1
    HeatMap gets Data which is a matrix. If I understand you correctly, you have only the (x,y) matrix coordinates. try first to build a matrix from your x-y coordinates. Commented Oct 12, 2012 at 3:47
  • Do you mean you want a heatmap that has been clustered? Commented Oct 12, 2012 at 15:32

4 Answers 4

27

HeatMap isn't actually standard function for this, it comes from the Bioinformatics Toolbox. The simple way of drawing a heatmap might be like:

 A = 1:50; % matrix to draw colormap('hot'); % set colormap imagesc(A); % draw image and scale colormap to values range colorbar; % show color scale 

As @natan suggested, you might want to build your matrix first and then draw using image or imagesc. Also you migt want to see article on my blog which shows that some color sets are better for accessibility than others, e.g. for printing in grayscale or in color vision deficiency.

Sign up to request clarification or add additional context in comments.

1 Comment

Simple and elegant, lovely!
2

I'm not sure what you're actually trying to accomplish, but I think you might want to use colormap{}. If you're trying to create a classic "heatmap", then colormap is the function you want. Basically, if you've got x,y position, and a Z value that you want to represent as a color, this is the trick for you.

Comments

0

You can use the Plotly MATLAB API to make a heatmap. Try this:

r = plotly({struct('z',randn(50,50), 'type','heatmap')}) % => https://plot.ly/~matlab_example/18dos(['open ', r.url]) 

this heatmap

You can see the interactive version and installation here.

Disclosure, I am on the Plotly team.

Comments

0

The MATLAB contourf command may by useful to you.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.