|
沙发
楼主 |
发表于 2022-4-1 09:57:34
|
只看该作者
更新一下,通过设置第二个图为透明,直接显示第一个图中的线。
效果同附件。
- clear all
- clc
- clf
- %% outline
- % zoom in with line cross different axis
- %% main
- x=linspace(0,3*pi,1000);
- rnd = rand(size(x));
- y=x+exp(sin(2*x))+exp(x./3)+exp(x).*rnd/100;
- seedm(3)
- zoom =[3.8 4.3 8 14]
- pos1 = [0.1 0.15 0.85 0.7];
- pos2 = [0.2 0.4 0.3 0.25];
- % find line1 ends
- tm = x-zoom(1);
- [va,inbeg] = min(abs(tm));
- tm = x-zoom(2);
- [va,inend] = min(abs(tm));
- h=figure(1)
- set(h, 'Position', [1000, 1000, 550, 500]);
- ax11=axes('position',pos1);
- hold on
- plot(x,y,'.-')
- axis([0 10 -20 200])
- set(gca,'fontsize',14,'linewidth',2)
- % % % line : from corner to corner -----------------------------------------
- % lin1_x = [zoom(1) (0.2-0.1)/0.85 * (10-0)];
- % lin1_y = [zoom(3) (0.4-0.15)/0.7 * (200-(-20))-20];
- % lin2_x = [zoom(2) (0.2+0.3-0.1)/0.85*(10-0)];
- % lin2_y = [zoom(3) (0.4-0.15)/0.7 * (200-(-20))-20];
- % % line : from line to line -----------------------------------------
- lin1_x = [zoom(1) (0.2-0.1)/0.85 * (10-0)];
- lin1_y = [y(inbeg) ((y(inbeg)-8)*0.25/(14-8)+(0.4-0.15))/0.7 * (200-(-20))-20 ];
- lin2_x = [zoom(2) (0.2+0.3-0.1)/0.85*(10-0)];
- lin2_y = [y(inend) ((y(inend)-8)*0.25/(14-8)+(0.4-0.15))/0.7 * (200-(-20))-20];
- plot(lin1_x,lin1_y,'r-','linewidth',2)
- plot(lin2_x,lin2_y,'g-','linewidth',2)
- axis([0 10 -20 200])
- % axis off
- box on
- rectangle('Position',[zoom(1) zoom(3) zoom(2)-zoom(1) zoom(4)-zoom(3)],'linewidth',2)
- ax11=axes('position',pos2);
- plot(x,y,'.-','linewidth',2,'markersize',12)
- axis(zoom)
- set(gca,'linewidth',2)
- set(gcf, 'Color','none')
- set(gca,'color','none')
- % ax11=axes('position',pos1);
- % hold on
- % plot(lin1_x,lin1_y,'r-','linewidth',2)
- % plot(lin2_x,lin2_y,'g-','linewidth',2)
- % axis([0 10 -20 200])
- % axis off
复制代码
|
|