Any idea how to recreate this plot?

조회 수: 7 (최근 30일)
Ajmal Rasheeda Satheesh
Ajmal Rasheeda Satheesh 2023년 3월 26일
댓글: Adam Danz 2023년 4월 9일
I have all the necessary data, windspeed as a function of height and time, wind direction in degrees also a function of height and time. I just cannot figure out how to plot a quiver plot on top of a pcolor plot
Any help would be great
Thanks

채택된 답변

Adam Danz
Adam Danz 2023년 3월 26일
편집: Adam Danz 2023년 4월 9일
> I just cannot figure out how to plot a quiver plot on top of a pcolor plot
Plot the pcolor data and then the quiver data.
I noticed that in your image, all of the quiver arrows look like they have the same magnitude. I assume this is part of your data, otherwise you'll need to adjust the u and v values. The arrows in this demo do not have the same magnitude.
load wind
x = x(:,:,3);
y = y(:,:,3);
u = u(:,:,3);
v = v(:,:,3);
pcolor(x,y,u);
hold on
quiver(x,y,u,v, 'k-','LineWidth',1.5)
Update: rescaling with datetime
Currently quiver does not accept datetime which is why the datetime values are converted to numeric. But the numeric values are very large which causes issues with scaling quiver arrows. I noticed your timestamps only span the course of a day so there's no need to use gigantic x values.
This solution converts your datetime values to minute from midnight. You've got about 1425 minutes and your y values ranges about 2000 so the plot aspect ratio will be more reasonable.
See in-line comments for details.
% Load data
load('test_var.mat');
% Convert numeric timestamps to datetime
timestamps = datetime(T_wind_30min,'ConvertFrom','datenum');
% Shift all timestamps by the stating date
baseDate = dateshift(min(timestamps(:)),'start','day');
timestampsShift = timestamps - baseDate;
% Convert timestamps to minutes from the start of the first day in the data
timeMinutes = minutes(timestampsShift);
% Plot pcolor
f1=figure();
Y=pcolor(timeMinutes,H_wind_30min,dl_wind_out_day.dl_w_30min);
set(Y,'EdgeColor', 'none');
colormap(jet);
ylim([0 2000]);
cl=colorbar;cl=colorbar;
clim([-2,2])
% Add quiver
hold on
Q=quiver(timeMinutes, H_wind_30min, xWind_unit_30min, yWind_unit_30min, 'k-');
% Set xaxis datetime tick labels
baseDate.Format = 'HH:mm';
xt = 0 : 180 : 1400;
xtlab = string(baseDate + minutes(xt));
set(gca, 'XTick', xt, 'XTickLabel', xtlab)
  댓글 수: 14
Ajmal Rasheeda Satheesh
Ajmal Rasheeda Satheesh 2023년 4월 8일
I guessed the range between x and y axis was the issue too, but the thing is my axis is datetime in datenum. Is there any way to get the arrows to show up?, some kind of normalization of the horizontal wind values?
Adam Danz
Adam Danz 2023년 4월 9일
I've updated my answer to show how to rescale your data.

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by