Help shifting a movmedian plot along the x-axis

1 次查看(过去 30 天)
Hi, I am having an issue in moving a movmedian plot to align with a line graph, which are very far apart on the x-axis. I have tried a few methods and have been able to move the y axis, but not the x yet for the movmedian. Here is my code:
t = 1:4656;
x = datenum(2006, 01, 01) + t;
str = datestr(x, 'mmm yyyy');
plot(x, Don)
hold on
tick_locations = datenum(2006,01:6:153,1);
set(gca,'XTick',tick_locations);
datetick('x','mmm yyyy','keeplimits', 'keepticks');
set(gca,'XTickLabelRotation',45)
set(gca,'XMinorTick','off','YMinorTick','on')
grid minor;
and the plot im trying to align it with is:
plot(movmedian(Don,7))
I tried calling q = to the above plot and managed to move the y axis up and down:
plot(movmedian(Don,7))
>> hold on
>> plot(t+5,q)
although im unsure how to change this to apply to the x-axis. I've also tried applying the tick_locations for the movmedian plot from my initial plot but this doesnt work.
Any help is greatly appreciated.

回答(1 个)

Sai Sri Pathuri
Sai Sri Pathuri 2020-5-6
The difference in the x locations might be because you are not plotting movmedian(Don,7) against x. You may try the following to overlap both the plots.
plot(x,movmedian(Don,7))

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by