From: Michael on
Hello,

I am doing a plot with two axes using subplot. For adding furhter data I assign the handles of the two axes to variables. The input is as following:

clear
t=0:1e-2:10;
subplot(2,1,1)
ax1=gca;
plot(t,sin(t))
subplot(2,1,2)
ax2=gca;
ax2=plot(t,cos(t))

After this I draw an annotation:

annotation('arrow', [0.4, 0.2], [0.7, 0.7])

Now I want to draw an additional data set in the first axis and set this axis as current axis using:

axes(ax1)

At this point my annotation disappears. It seems that it has gone in a layer behind the upper axis. How can I make my annotation visible again?

Michael
From: ImageAnalyst on
clear;
t=0 : 1e-2 : 10;
subplot(2, 1, 1)
plot(t, sin(t), 'b-')
set(gcf, 'Position', get(0,'Screensize')); % Maximize figure.
subplot(2, 1, 2)
plot(t, cos(t))
% After this I draw an annotation arrow:
annotation('arrow', [0.4, 0.2], [0.7, 0.7])
% Now I want to draw an additional data set in the first axis
% and set this axis as current axis.
subplot(2, 1, 1)
hold on;
plot(t, cos(t), 'r-', 'LineWidth', 2)

From: Michael on
ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <5dc8b706-3467-4064-9e33-c5de72fe3b3b(a)c11g2000vbe.googlegroups.com>...
> clear;
> t=0 : 1e-2 : 10;
> subplot(2, 1, 1)
> plot(t, sin(t), 'b-')
> set(gcf, 'Position', get(0,'Screensize')); % Maximize figure.
> subplot(2, 1, 2)
> plot(t, cos(t))
> % After this I draw an annotation arrow:
> annotation('arrow', [0.4, 0.2], [0.7, 0.7])
> % Now I want to draw an additional data set in the first axis
> % and set this axis as current axis.
> subplot(2, 1, 1)
> hold on;
> plot(t, cos(t), 'r-', 'LineWidth', 2)

Thank you for the working solution, unfortunately it does not fit my needs. I want to use the axes handle, because I have to pass the actual axes to a function with the desired plotting commands.

Michael
From: us on
"Michael " <michael.NO.salloker(a)fh-joanneum.SPAM.at> wrote in message <htiq40$i1k$1(a)fred.mathworks.com>...
> ImageAnalyst <imageanalyst(a)mailinator.com> wrote in message <5dc8b706-3467-4064-9e33-c5de72fe3b3b(a)c11g2000vbe.googlegroups.com>...
> > clear;
> > t=0 : 1e-2 : 10;
> > subplot(2, 1, 1)
> > plot(t, sin(t), 'b-')
> > set(gcf, 'Position', get(0,'Screensize')); % Maximize figure.
> > subplot(2, 1, 2)
> > plot(t, cos(t))
> > % After this I draw an annotation arrow:
> > annotation('arrow', [0.4, 0.2], [0.7, 0.7])
> > % Now I want to draw an additional data set in the first axis
> > % and set this axis as current axis.
> > subplot(2, 1, 1)
> > hold on;
> > plot(t, cos(t), 'r-', 'LineWidth', 2)
>
> Thank you for the working solution, unfortunately it does not fit my needs. I want to use the axes handle, because I have to pass the actual axes to a function with the desired plotting commands.
>
> Michael

one of the solutions

t=0:1e-2:10;
clear sh; % <- save old stuff(!)...
sh(1)=subplot(2,1,1);
line(t,sin(t));
sh(2)=subplot(2,1,2);
line(t,cos(t));
annotation('arrow', [0.4, 0.2], [0.7, 0.7]);
axis(sh(1));
line(t,sin(t));

us
From: Michael on
"us " <us(a)neurol.unizh.ch> wrote in message ...
>
one of the solutions
>
> t=0:1e-2:10;
> clear sh; % <- save old stuff(!)...
> sh(1)=subplot(2,1,1);
> line(t,sin(t));
> sh(2)=subplot(2,1,2);
> line(t,cos(t));
> annotation('arrow', [0.4, 0.2], [0.7, 0.7]);
> axis(sh(1));
> line(t,sin(t));
>
> us

Thank you, but in your solution the last command draws a line in the lower subplot, not in the upper one. And I do not understand the statement

axis(sh(1));

Michael
 |  Next  |  Last
Pages: 1 2
Prev: Annotation in figure disapperas
Next: biograph