Consider the following example code:
load sumsin;
s = sumsin+10; % example data series
time = linspace(0,5*24,1000);
figure(1);
subplot(311);
plot(time,s,'k');
subplot(312);
plot(time,s,'k');
hold on;
[s_denoised,~, ~] = wden(s,'minimaxi','s','sln',1,'db4');
plot(time,s_denoised,'r');
subplot(313);
plot(time,s,'k');
hold on;
plot(time,s_denoised,'r');
xlim([20 40]);
Resulting in
I would like to alter this plot by inserting lines between subplot 2 and 3 to show that subplot 3 is a portion of subplot2. For example:
How can this be achieved in matlab?
Edit:
I was thinking of something along the lines of generating a invisible axes over the entire figure, obtain the position of each subplot, the location of 20 and 40 will be a certain percentage of the subplot width so I could use the annotation command from here to start a line and then apply the same method to the third subplot to connect the lines with the desired location. I have trying this, but no solution so far.
Just for the sake of the answer, you could use annotation objects
to get the effect that you're looking for, as correctly suggested in a comment. Note that their coordinates have to be normalized to the [0, 1] range with respect to the figure window, so it might be quite tedious to adjust them.
This does get the job done, but it's horrible. Don't do it this way.
Since I don't have your original data, I'll draw something of my own (but similar to yours):
t = linspace(0, 120, 1000);
s_denoised = sin(t / 2);
s = s_denoised + 0.2 * randn(size(s_denoised));
subplot(3, 1, 1), plot(t, s, 'k')
subplot(3, 1, 2), plot(t, s, 'k', t, s_denoised, 'r')
subplot(3, 1, 3), plot(t, s, 'k', t, s_denoised, 'r'), xlim([20 40])
Now let's add "annotation" lines like you want:
annotation('doublearrow', [.26 .39], [.38 .38]); %// Top double-arrow line
annotation('doublearrow', [.13 .9], [.34 .34]); %// Bottom double-arrow line
annotation('line', [.325 .325], [.38 .37]); %// Top little connector
annotation('line', [.515 .515], [.35 .34]); %// Bottom little connector
annotation('line', [.325 .515], [.37 .35]); %// Line
Result:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With