How can I plot three columns of a dataset to produce an image or a map?
5 views (last 30 days)
Show older comments
Stephen Tete
on 24 Mar 2023
Commented: Stephen Tete
on 24 Mar 2023
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 Comments
Accepted Answer
Joe Vinciguerra
on 24 Mar 2023
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 Comments
More Answers (0)
See Also
Categories
Find more on Orange 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!