在一个框架中添加更多图片

在一个框架中添加更多图片

我想要制作如下图像: 线性函数图片

但我仍然无法将第三和第四个图表添加到框架中。您能帮我设置正确的代码吗?这是我当前的代码:

//linear function...
   settings.outformat="pdf";
//picture will be reduced to half of its size
   size(11cm,0);
   import graph;

   picture pic1,pic2,pic3,pic4;

 //colour
   pen dBlue1=rgb(66/255, 81/255, 172/255);
   pen dBlue2=rgb(42/255, 44/255, 111/255);
   pen dBlack=rgb(16/255, 15/255, 13/255);
   pen dRed=rgb(237/255, 27/255, 43/255);
   pen dGreen=rgb(68/255, 186/255, 59/255);
 // gray sa do svg nekonvertuje spravne, pouzit treba dGray
   pen dGray=rgb(130/255, 130/255, 130/255);

    defaultpen(0.7bp+dGray+ fontsize(14pt));
  // predvolene
    DefaultHead=HookHead;
    pen pblue=1.1bp+dBlue1; 
    pen pgreen=1.1bp+dGreen; 
    pen pred=1.1bp+dRed; 
    pen pblack=1.1bp+dBlack; 


    real as=3bp;    // velkost sipky
    real margin=5mm;

    real xmin = -3;
    real xmax = 5;
    real ymin = -3;
    real ymax = 10;

    xlimits(xmin,xmax);
    ylimits(ymin,ymax);

    //axis and the grid first picture

    xaxis(pic1, Label("$x$",align=2E),NoTicks,Arrow(as));
    yaxis(pic1, Label("$y$",align=2N),NoTicks,Arrow(as));

    // function y=ax+b a>0
    real f(real x) {return 2*x+3; }
    path g = graph(pic1, f,xmin, xmax);
    draw(pic1,g,pred,L= Label("$y=\textrm{a}x+\textrm{b}$", UnFill, 
    position=Relative(0.9), align=SE));     
    
    real f(real x) {return 2*x-3; }
    path g = graph(pic1, f,xmin, xmax);
    draw(pic1,g,pblue,L= Label("$y=\textrm{a}x-\textrm{b}$", UnFill,            
    position=Relative(0.9), align=SE));
    size(pic1,100,100,point(pic1,SW),point(pic1,NE));
    
    frame f1=pic1.fit();
    add(f1);        
    
    // aading second picture
    xaxis(pic2, Label("$x$",align=2E),Arrow(as));
    yaxis(pic2, Label("$y$",align=2N),Arrow(as));

    real f(real x) {return 2*x-1; }
    path g = graph(pic2, f,xmin, xmax);
    draw(pic2,g,pred,
    L= Label("$y=\textrm{a}x+\textrm{b}$", UnFill,          
    position=Relative(0.9), align=SE));     
    
    real f(real x) {return (-2)*x+5; }
    path g = graph(pic2, f,xmin, xmax);
    draw(pic2,g,pblue,
    L= Label("$y=\textrm{-a}x+\textrm{c}$",
    UnFill, position=Relative(0.9), align=SE));
    //draw(arc((1,3),(3,5),),pblack);

    size(pic2,100,100,point(pic2,SW),point(pic2,NE));

    frame f2=pic2.fit();
    f2=shift(max(f1).x-min(f2).x+margin)*f2;
    add(f2);

    // add third picture
    xaxis(pic3, Label("$x$",align=2E),Arrow(as));
    yaxis(pic3, Label("$y$",align=2N),Arrow(as));

    real f(real x) {return 3*x+1; }
    path g = graph(pic3, f,xmin, xmax);
    draw(pic3, g,pgreen,
    L= Label("$y=x+\textrm{b}$", UnFill,            
    position=Relative(0.7), align=SE), Arrows(as)); 
    real f(real x) {return -2*x+1; }
    path g = graph(pic3, f,xmin, xmax);
    draw(pic3, g,pgreen,
    L= Label("$y=\dfrac{1}{3}x+\textrm{b}$", UnFill,    
    position=Relative(0.7), align=SE), Arrows(as)); 
    
    size(pic3,100,100,point(pic3,SW),point(pic3,NE));

    //frame f3=pic3.fit();
    //f3=shift(0,min(f1).y-max(f3).y-margin)*f3;
    //add(f3); 

    \\add 4th picture
    xaxis(pic4, Label("$x$",align=2E),Arrow(as));
    yaxis(pic4, Label("$y$",align=2N),Arrow(as));

    draw(pic4,(3,ymin-0.25)--(3,ymax+0.25),pred,
    L= Label("$x=\textrm{a}$", UnFill,position=Relative(0.9)));
    draw(pic4,(xmin-0.25,2)--(xmax+0.25,2),pblue,
    L= Label("$y=\textrm{b}$",NW));
    dot(pic4,(3,2),pred);

    label(pic4, "[a,b]",(3,3), NE, pblack);

    size(pic4,100,100,point(pic4,SW),point(pic4,NE));

    //frame f4=pic4.fit();
    //f4=shift(max(f3).x-min(f4).x+margin,min(f2).y-max(f4).y-margin)*f4;
    //add(f4);

答案1

这是一个起点...

size(11cm);

picture pic1, pic2, pic3, pic4;

draw(pic1,Label("$x$",Relative(0.99)),(0,0)--(5,0),Arrow);
draw(pic1,Label("$y$",Relative(0.99)),(0,0)--(0,5),Arrow);
label(pic1,"Asymptote",(2.5,2.5));
add(pic1);

draw(pic2,Label("$x$",Relative(0.99)),(0,0)--(5,0),Arrow);
draw(pic2,Label("$y$",Relative(0.99)),(0,0)--(0,5),Arrow);
label(pic2,"The Vector",(2.5,2.5),(W+E)/2);
add(shift(8,0)*pic2);

draw(pic3,Label("$x$",Relative(0.99)),(0,0)--(5,0),Arrow);
draw(pic3,Label("$y$",Relative(0.99)),(0,0)--(0,5),Arrow);
label(pic3,"Graphics",(2.5,2.5),(N+S)/2);
add(shift(0,-8)*pic3);

draw(pic4,Label("$x$",Relative(0.99)),(0,0)--(5,0),Arrow);
draw(pic4,Label("$y$",Relative(0.99)),(0,0)--(0,5),Arrow);
label(pic4,"Language",(2.5,2.5),(0,0));
add(shift(8,-8)*pic4);

在此处输入图片描述

相关内容