Monday, March 5, 2012

Inset to create a plot inside a plot in matlab


figure(1)
clf;

x=[0:0.1:20]
y=sin(x)

subplot(1,1,1) ; % main plot

plot(x,y,'b')
xlabel('x','fontsize',18)
ylabel('sin(x)','fontsize',18)

axes('position',[0.5 0.6 0.3 0.2]) ; % inset

plot(x,abs(y),'r')
xlabel('x','fontsize',15)
ylabel('abs(sin(x))','fontsize',15)

from this matlab intro.