How can I plot three columns of a dataset to produce an image or a map?

조회 수: 5 (최근 30일)
I have the randomly generated data with the final dataset in the Variable 'DATA'
===========================================
D = [66;67;68;69;70;74;75;76;78;83];
Day =repelem(D,11);
timeH = (13:23)'; timeH = repmat(timeH,[10,1]);
xmin=0;
xmax=0.9;
n=110;
x = xmin+rand(1,n)*(xmax-xmin);
x = x';
DATA = [Day,timeH,x];
===========================================
I want to produce an image or map with x-axis Day, y-axis as timeH and z-axis as x.
I have tried with:
imagesc(Day,timeH, x)
but the output I'm getting is more of stripped color lines,
I want a map like the images attached (days on the x axis instead)
or
I would be grateful if i can get help. Thank you

채택된 답변

Joe Vinciguerra
Joe Vinciguerra 2023년 3월 24일
The data needs to be reshaped.
Here are a few different plotting options, depending no how you went to represent the data.
D = [66;67;68;69;70;74;75;76;78;83];
Day =repelem(D,11);
timeH = (13:23)'; timeH = repmat(timeH,[10,1]);
xmin=0;
xmax=0.9;
n=110;
x = xmin+rand(1,n)*(xmax-xmin);
x = x';
DATA = [Day, timeH, x];
% Reshape the data into matrices
d = reshape(DATA(:,1), [11, 10]);
t = reshape(DATA(:,2), [11, 10]);
X = reshape(DATA(:,3), [11, 10]);
% plot as a scaled color image
imagesc(Day, timeH, X)
colorbar()
% plot as a scaled color image with interpolated visualization
imagesc(Day, timeH, X, "Interpolation", "bilinear")
colorbar()
% plot as a filled contour map
contourf(d, t, X, "LineStyle","none")
colorbar()
% plot as a 3D surface, viewed from top with interpolated shadind
surf(d, t, X, "LineStyle","none")
shading(gca, "interp")
colorbar()
view(0, 90)
axis tight
  댓글 수: 3
Joe Vinciguerra
Joe Vinciguerra 2023년 3월 24일
If I understand you, something like xticks(66:83) or xticks(D).

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by