I've been used the following commands to plot a feather plot:
(OBS: u and v are the components of the wind, and the vectors date are: year, month and day)
t = datenum(year,month,day);
feather(u,v)
hold on
plot(t, zeros(size(u)))
datetick('x','dd/mm/yyyy','keepticks', 'keeplimits')
But that isn't working very well.
I'm getting the following figure:
I've been tried to use the quiver plot, with the following commands:
t = datenum(year,month,day);
quiver(t, zeros(size(u)), u, v);
datetick('x','dd/mm/yyyy','keepticks', 'keeplimits')
with that I get the following image (It seems better, but the intensity of the winds are wrong, so I guess that the quiver function don't is correct for the case):
Repare that using the feather function the intensity of the wind is plotted correctly, but the graph and the values of the date in the X axis is wrong, meanwhile, whith the quiver the date is correct and the plot is correct, but the intensity is wrong.
Can someone help me to find the error? Is there another way to plot that information?

댓글 수: 2

Star Strider
Star Strider 2018년 4월 1일
The year values seem wrong. The maximum year in the first plot is 2190, and in the second, 2020.
Are you plotting historical values, or predicting future values?
Robson Passos
Robson Passos 2018년 4월 1일
Yes, they are wrong, I'm plotting historical values, with the first plot the years are completly wrong, the correct time period is from jan/1998 to jan/2018, however, the second one uses the same date vector and the year is plotted correctly. That is one of the problems that I want to solve.

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

 채택된 답변

Star Strider
Star Strider 2018년 4월 1일

3 개 추천

Apparently, feather and datetick don’t work and play well together.
This workaround is the best I can do:
t = datenum([1998 01 01]):datenum([2018 01 01]);
u = rand(size(t));
v = rand(size(t));
figure
feather(u,v)
set(gca, 'XLim',[0 numel(u)]) % Set X-Axis Limits
xt = get(gca,'XTick') % Get X-Tick Values
xt(1) = 1;
txt = t(xt); % Define ‘t’ Using ‘xt’
set(gca, 'XTick',xt, 'XTickLabel',datestr(txt,'dd/mm/yyyy'), 'XTickLabelRotation',30)
I rotated the tick labels so they wouldn’t crash into each other.
Experiment to get the result you want.

댓글 수: 4

Robson Passos
Robson Passos 2018년 4월 1일
편집: Robson Passos 2018년 4월 1일
Thank you very much, It works, I got the following figure:
I couldn't rotate the label because I'm using Matlab 2013a. The last tick of the x axis doesn't appear, do you know how I can fix it?
As always, my pleasure.
I don’t have access to R2013a, so you will need to test this. It works in R2018a:
t = datenum([1998 01 01]):datenum([2018 01 01]);
u = rand(size(t));
v = rand(size(t));
figure
feather(u,v)
set(gca, 'XLim',[0 numel(u)]) % Set X-Axis Limits
% xt = get(gca,'XTick') % Get X-Tick Values
Nt = 7; % Set Number Of X-Ticks
xt = linspace(1, numel(t), Nt); % Create New X-Tick Values
xt = floor(xt); % Use X-Tick Values As Subscripts
txt = t(xt); % Define ‘t’ Using ‘xt’
set(gca, 'XTick',xt, 'XTickLabel',datestr(txt,'dd/mm/yyyy'), 'XTickLabelRotation',30)
It creates a new tick vector that will completely span the ‘t’ vector. You can control the number of ticks with ‘Nt’.
If my Answer helped you solve your problem, please Accept it!
Robson Passos
Robson Passos 2018년 4월 1일
It worked perfectly, thank you very much for your help. :)
Star Strider
Star Strider 2018년 4월 1일
As always, my pleasure!
This is an interesting problem!

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

추가 답변 (1개)

Benjamin Gillard
Benjamin Gillard 2019년 12월 16일

0 개 추천

This code is great!!
it did help me a lot and save me of a potential brain damage.
Work on 2019b.
Thank you very much,

댓글 수: 1

Star Strider
Star Strider 2019년 12월 16일
My pleasure!
A Vote would be appreciated.

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

카테고리

도움말 센터File Exchange에서 Vector Fields에 대해 자세히 알아보기

질문:

2018년 4월 1일

댓글:

2019년 12월 16일

Community Treasure Hunt

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

Start Hunting!

Translated by