Draw a colored error map based on the measurement error

Hello,
I'm evaluating a positioning system. What the image shows is a battery of measurements at different points in a plane (different coordinates). The blue points are each of the positions delivered by the system, and the red cross is the average of those blue points in each coordinate.
This system depends on the position of some beacons so that the position in the centre has less dispersion than in the corners.
I would like that in this image a color map can be made, highlighting the areas with more error and with less error.
How could I do this?
Thank you very much.

6 Comments

I've never tried it--wonder if can overlay a heatmap.
Otherwise, compute the error for each location and modify the color to suit...scaled to the error range.
Alternatively, an interpolated surface fit to the error values...
As usual, if you provided the dataset as an attached .mat file it would make it easier for folks to play with rather than having to also generate a dataset of their own...
Hello,
Thanks for the ideas, even though I've been trying and I'm not able to do it.
I didn't pass the .mat for not complicating it because there are so many variables. But I will pass it, and I also put the matlab function that represents the graph of the question.
%-----------------------------------------------------------------------------
figure (3)
title('Entorno 2D --> Nube de estimaciones')
for T = 1:(N_traget_X*N_traget_Y)
for i=1:NM
x=ESTIMS(i,1,T);
y=ESTIMS(i,2,T);
plot(x,y, "b.")
hold on
xlabel('x')
ylabel('y')
end
plot(PosT_GN(T,1),PosT_GN(T,2), "+r", 'LineWidth',2)
hold on
end
On the other hand, I have calculated the RMS error (Square root of the mean difference of the squared error). I think this is what you meant by quantifying the error, but I am not able to associate it with a heat map.
%-----------------------------------------------------------------------------------
% Error RMS
m_aux = zeros(100,3);
figure (5)
for T = 1:(N_traget_X*N_traget_Y)
aux1 = ESTIMS(:,:,T);
for i=1:100
m_aux(i,:) = P(:,T);
end
RMSE(T) = sqrt(mean((aux1(:)-m_aux(:)).^2))
plot(P(1,T),P(2,T), "+r", 'LineWidth',1)
hold on
x=P(1,T)
y=P(2,T)
r=RMSE(T)
hold on
th = 0:pi/50:2*pi;
xunit = r * cos(th) + x;
yunit = r * sin(th) + y;
h = plot(xunit, yunit);
hold on
end
I attach the .mat with the data.
Thank you very much.
Got sidetracked by farm chores, sorry...
hHM=heatmap(reshape(RMSE,6,6));
hHM.CellLabelColor='none';
is kinda' interesting, though.
Unfortunately,
>> hold on
Error using hold (line 54)
Using hold with heatmap is not supported.
>>
threw cold water on that idea directly...and,
>> heatmap(reshape(RMSE,6,6));
Error using heatmap (line 83)
Adding HeatmapChart to axes is not supported. Turn hold off.
>>
doesn't work directly on the original plot. Doesn't mean one couldn't patch it in, though.
Have to run at the moment...
OBTW. I didn't look to see if the RMSE values are in the proper sequence compared to the plotting order used; may need to transpose to put the right RMSE value in the right location if choose to use a heatmap and figure out something else for displaying the scatter...
RMSE(T) = sqrt(mean((aux1(:)-m_aux(:)).^2))
I wonder since the data apparently are all 2D planar observations if shouldn't not include Z data in the RMS measurement as being more accurate representation of the actual measurement discrepancy. As done, all those zeros are going to reduce the computed error noticeably.
Just a thought...
Hello again,
I have a problem with this solution. Since the Y-axis starts at the bottom left with the number 6 and ends with 1 (I'm talking about the indexes).
This is confusing since I am representing an error in coordinates and therefore I need the order to be inverse, that is, starting at 1 (bottom left) and going up to 6.
How can I solve this?
Thank you very much.
Look into your options with axis:
axis ij % Origin at top left
axis xy % Origin at bottom left

Sign in to comment.

 Accepted Answer

More than one way to skin a cat... :)
hHM=heatmap(reshape(RMSE,6,6)); % draw the heatmap; fixup some to draw on top later...
hHM.CellLabelColor='none'; % make the HM cell values invisible
hHM.XDisplayLabels=repmat({' '},1,6); % clear HM data labels
hHM.YDisplayLabels=repmat({' '},1,6); % clear HM data labels
hHM.ColorbarVisible='off'; % and forego the colorbar
hAx=axes('Position',hHM.Position,'Color','none'); % create new axes on top transparent so HM shows
hold on % get ready for the plot
arrayfun(@(i) scatter(ESTIMS(:,1,i),ESTIMS(:,2,i),3,'b',"filled"),[1:size(ESTIMS,3)]); % put scatter
...
results in
Can go ahead with the rest of the additions of the red cross, etc., etc., ...
Changing colormap for the heatmap might help some for better contrast, but the idea can be made to work it appears; why TMW chose to not let do it directly is anybody's guess -- again "big brother knows best" syndrome I suppose just couldn't imagine somebody would want to do.

3 Comments

Thanks, IA! :) Did turn out kinda' interesting didn't it?
Seems a good way to present OP's data, I think.
The interpolant idea is an alternative but didn't have time to fiddle further...
Many thanks, your answer is very correc

Sign in to comment.

More Answers (1)

If you want a more continuous heat map, you can use scatteredInterpolant(). I've attaching a demo.

Categories

Community Treasure Hunt

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

Start Hunting!