- Run the code to produce 1 figure
- Look into the data and find position within the matix where the values should indicate white areas of the plot. The function find() will come in handy.
- Then find those location on the plot to confirm that they aren't white. If you use imagesc() note that the y-axis is reversed by default (as it is in Heatmap). If you'd like to flip it to normal: set(gca, 'YDir', 'Normal')
- Then repeat the process for the 2nd plot and so on. If you find values that represent white, those areas should be white on your plot.
Heatmap plotting incorrect, black lines on X and Y axis outside the figure itself
15 views (last 30 days)
Show older comments
I implemented the minutia heat map presented in this paper (page 7): https://arxiv.org/pdf/1909.09901.pdf
For this, the following code is implemented: (X, Y, and A data is attached in a .dat file)
function HeatMapCreator()
% Start plotting minutia
[X, Y, A] = GetMinData("TestData");
% Count Minutiea
n = length(X);
% set Width and Hight
W = 600; H = 750; K = 6;
% Create the matixes
MM = cell(K, 1);
M = zeros(H,W);
% Define the gussian paramater
GP = 2*2^2;
% Go through each pixel
for k = 1:6
for j = 1 : H
for i = 1 : W
Hijk = 0;
for t = 1 : n
Xt = X(t);
Yt = Y(t);
At = A(t);
%Calculate Cs
ED = sqrt((i-Xt)^2+(j-Yt)^2);
Cs = exp(-ED/GP);
%Calculate Co
DO = At - (2 * k * pi / K);
if (DO < -pi) || (DO > pi)
DO = 2 * pi - DO;
end
Co = exp(-DO/GP);
Hijk = Hijk + (Cs * Co);
end
M(j,i) = Hijk;
end
end
MM{k} = M;
end
% Show the 6 figures
for k = 1:6
figure(k)
heatmap(MM{k},'Colormap',gray,'GridVisible','off');
end
end
The following bugs does not make sense:
1- I am getting Black lines in the X and Y axis when plotting:
2- According to the paper, all 6 heatmaps should look different, as here:
But im my code, the matrixes are different from each other, but the heatmap is the same for all the 6 figues. I wonder weather the heat map function have anything to do regarding this error ?
All my figures looks like the first image.
0 Comments
Accepted Answer
Adam Danz
on 28 Oct 2019
Edited: Adam Danz
on 29 Dec 2020
Problem 1: the black lines
Those black lines are merely 100s of tick labels (or, the equivalent of axis ticks in Heatmap) . Your data seems to be a matrix with size [750, 600] which means there are a few hundred ticks on each axis, all squished together. Notice the layers of ticks become thicker as ticks move from 1s to 10s to 100s. The problem can be recreated with this line of code:
heatmap(rand(750,600))
To remove the axis ticks,
h = heatmap(rand(600,750));
hs = struct(h); % See warning in command window
hs.XAxis.TickValues = [];
hs.YAxis.TickValues = [];
Alternatively, (better than the version above; added Dec 29, 2020)
h = heatmap(rand(600,750));
h.XDisplayData = [];
h.YDisplayData = [];
Or to show every 50 ticks (added Dec 29, 2020)
h = heatmap(rand(600,750));
h.YDisplayData = h.YDisplayData([1,50:50:end]);
h.YDisplayData = h.YDisplayData([1,50:50:end]);
Problem 2: All plots look the same
It's tough to troubleshoot that one without seeing the data, your plots, or stepping through your code. If I were you, I'd follow these steps:
More Answers (0)
See Also
Categories
Find more on Data Distribution Plots 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!