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
댓글 수: 0
채택된 답변
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Orange에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!