2D heatmap based on weight (not density)
Show older comments
I have an X, Y and X matrix, each N x M of size, where X indicates a location on the x axis, Y indicates the y data point and Z is the weight. Currently, I use scatter in order to plot X and Y with a weight of Z to indicate the "importance" of each X/Y data point.
I'd like to create something like a heatmap instead, where the x/y coordinates are colored, instead of changed in size, based on the Z weight. For example, large Z values could be red, small Z values could be green and the color vector linearly interpolates between red and green as Z changes.
The code below will create an example setup similar to what I am working with.
X = randi(100, [100 1]); X = sort(X);
Y = randi(50, [100 1]);
Z = linspace(100, 1, 100);
figure;
scatter(X, Y, Z, 'k', 'o', 'filled');
I could see one of 3 options:
- something like either "hotspots" where large circles are and decreasing intensity of hotspots as the circles get smaller
- "color spots" for which large circles might start out red and change in color from red to yellow to green as they get smaller
- something like a "segmentation" of the entire background of the plot into "red, yellow, green" zones (e.g. as Z decreases, certain thresholds indicate a change from red to yellow to green, so "patches" could indicate such changes). However, I have no idea how to draw the lines of the patch (e.g. where data points with Z = 90 and above lay could be red, 89 and below could be orange, ..), and maybe smooth them a bit.
Any help will be greatly appreciated.
Accepted Answer
More Answers (0)
Categories
Find more on Color and Styling 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!


