how to plot a scattered heat map

206 visualizaciones (últimos 30 días)
sani
sani el 29 de En. de 2020
Comentada: Image Analyst el 30 de En. de 2021
Hi,
I have 2 vectors from a table, and I'd like to create chart similar to the one in the picture. I didn't found any matlab of the shelf command for it, is there is a way that I can
  3 comentarios
sani
sani el 29 de En. de 2020
I don't want the hexagonal plotting, just the heatmap coloring on a regular scattered plot (I will replace the image to something more similar to what I need)
Mohammad Sami
Mohammad Sami el 29 de En. de 2020
Editada: Mohammad Sami el 29 de En. de 2020
Yes the scatter function will work for that.
scatter(x,y,size,color).
If you don't have size you can leave it empty.
scatter(x,y,[],color).
Use colormap to change the coloring scheme if you need to.

Iniciar sesión para comentar.

Respuestas (1)

Image Analyst
Image Analyst el 29 de En. de 2020
Mohammad is right. Make a colormap, such as jet or hsv, and build a color table where for each value of your data, you assign the corresponding color from the colormap. Easy. Attach your data if you can't do it and someone will for you. Something like this untested code:
cmap = jet(256);
v = rescale(yourValues, 1, 256); % Nifty trick!
numValues = length(yourValues)
markerColors = zeros(numValues, 3)
% Now assign marker colors according to the value of the data.
for k = 1 : numValues
row = round(v(k));
markerColors(k, :) = cmap(row, :);
end
% Create the scatter plot.
scatter(x, y, [], markerColors);
grid on;
  4 comentarios
Wen Chuan Chong
Wen Chuan Chong el 30 de En. de 2021
Hi!
I have 4 variables (x,y,z,energy) and I would like the colour to be on the energy variable. Can you advise on how I would achieve this?
Best regards,
Jacob
Image Analyst
Image Analyst el 30 de En. de 2021
@Wen Chuan Chong, can you attach your 4 variables in a .mat file in a new question?
save('answers.mat', 'x', 'y', 'z', 'energy');
That way we'll have something to work with. In the meantime, see my attached example.

Iniciar sesión para comentar.

Categorías

Más información sobre Colormaps 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!

Translated by