How do I draw contour?

조회 수: 1 (최근 30일)
민제 강
민제 강 2021년 6월 2일
댓글: 민제 강 2021년 6월 3일
I want to draw a contour for the difference between Y and kriging in Sample.xlsx
Red if the error is big. Blue if the error is small.
As shown in the picture

채택된 답변

Walter Roberson
Walter Roberson 2021년 6월 2일
편집: Walter Roberson 2021년 6월 2일
data = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/639450/Sample.xlsx');
ux1 = unique(data.x1);
nx1 = length(ux1);
X1 = reshape(data.x1, [], nx1);
X2 = reshape(data.x2, [], nx1);
Y = reshape(data.Y, [], nx1);
K = reshape(data.Kriging, [], nx1);
kerr = Y - K;
contourf(X1, X2, abs(kerr), 20);
colormap turbo
xlabel('x1')
ylabel('x2')
title('kriging absolute err')
colorbar
You could interpolate to get a smoother looking plot.
N = 200;
F = griddedInterpolant(X1.', X2.', kerr.'); %must be ndgrid format
x1q = linspace(ux1(1), ux1(end), N);
x2q = linspace(min(data.x2), max(data.x2), N+1);
[X1Q, X2Q] = ndgrid(x1q, x2q);
KQ = F(X1Q, X2Q);
%contourf(X1Q, X2Q, abs(KQ), 20)
h = pcolor(X1Q, X2Q, abs(KQ));
h.EdgeColor = 'none';
colormap turbo
xlabel('x1 smoothed')
ylabel('x2 smoothed')
title('smoothed kriging absolute error')
I am not sure where the bright lines are coming from; it is likely to be an artifact as the number of boxes looks to be 1 less than the number of original values in each direction.
  댓글 수: 2
민제 강
민제 강 2021년 6월 3일
Thank you so much.
I have one more question.
When I put in other experimental values, the right bar (level) value is changed.
Can we fix it?
민제 강
민제 강 2021년 6월 3일
I found! caxis :)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Colormaps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by