Axis and 2D plotting with the package graph_pi
List of pictures
Figure 0001
figure 0001
Figure 0002
figure 0002
Figure 0003
figure 0003
Figure 0004
figure 0004
Figure 0005
figure 0005
Figure 0006
figure 0006
Figure 0007
figure 0007
Figure 0008
figure 0008
Figure 0009
figure 0009
Figure 0010
figure 0010
Figure 0011
figure 0011
Figure 0012
figure 0012
Figure 0013
figure 0013
Figure 0014
figure 0014
Figure 0015
figure 0015
Figure 0016
figure 0016
Figure 0017
figure 0017
Figure 0018
figure 0018
Figure 0019
figure 0019
Figure 0020
figure 0020
Figure 0021
figure 0021
Figure 0001
Figure 0001: fig0010.asy
(Compiled with Asymptote version 1.86svn-r4626)
    
import graph_pi;

graphicrules(yunit=1.5cm, xmin=-3, xmax=3, ymin=-2, ymax=2);
grid();
cartesianaxis(arrow=None);
labeloij(UnFill);

Figure 0002
Figure 0002: fig0020.asy
(Compiled with Asymptote version 1.44svn-r3315)
    
import graph_pi;

graphicrules(yunit=1.5cm, xmin=-3, xmax=3, ymin=-2, ymax=2);
grid(pic=currentpicture,
     xmin=-3, xmax=3,
     ymin=-2, ymax=2,
     xStep=1, xstep=.1,
     yStep=1, ystep=.1,
     pTick=.8red, ptick=.8green,
     above=false);
cartesianaxis(pic=currentpicture,
              Lx=Label(scale(2)*"$x$",align=NW),
              Ly=Label("$y$",align=SE),
              xmin=-3, xmax=3,
              ymin=-2, ymax=2,
              extrawidth=5, extraheight=5,
              p=currentpen,
              xticks=Ticks("%",pTick=1mm+yellow, ptick=grey),
              yticks=NoTicks,
              viewxaxis=true,
              viewyaxis=false,
              above=true,
              arrow=Arrow);
labeloIJ(pic=currentpicture,
         Lo=Label("$O$",NoFill),
         LI=Label("$I$",white,Fill(black)),
         LJ=Label(" "),
         diro=NE, dirI=N, dirJ=E,
         p=blue,
         filltype=NoFill,
         marker=dot(2mm+red));

Figure 0003
Figure 0003: fig0030.asy
(Compiled with Asymptote version 1.86svn-r4626)
    
import graph_pi;
size(200,0);
graphicrules(xmin=-1, xmax=4, ymin=-1, ymax=3);

grid(xstep=0,ystep=0);

cartesianaxis(xticks=Ticks(Label(Fill(white)), NoZero, ptick=invisible),
              yticks=Ticks(Label(Fill(white)), NoZero, ptick=invisible));

labelx("$O$",0,SW);

shipout(bbox(Fill(white)));

Figure 0004
Figure 0004: fig0040.asy
(Compiled with Asymptote version 1.86svn-r4626)
    
import graph_pi;

graphicrules(xunit=2cm, yunit=1.5cm, xmin=-3, xmax=2, ymin=-2, ymax=2);
add(millimeterpaper(p=3bp+orange),(0,0));
cartesianaxis();
labelx(Label("$1$",UnFill), 1);
labely(Label("$1$",UnFill), 1);
labelx("$O$",0,SW);
dot((0,0));

Figure 0005
Figure 0005: fig0050.asy
(Compiled with Asymptote version 1.86svn-r4626)
    
import graph_pi;

graphicrules(xunit=2cm, yunit=1.5cm, xmin=-3, xmax=2, ymin=-2, ymax=2);
add(millimeterpaper(pic=currentpicture, O=(0,0),
                    xmin=-2.5, xmax=1.5,
                    ymin=-1.5, ymax=1.5,
                    p=3bp+orange),
    (0,0));
cartesianaxis();
labelx(Label("$1$",UnFill), 1);
labely(Label("$1$",UnFill), 1);
labelx("$O$",0,SW);
dot((0,0));

Figure 0006
Figure 0006: fig0060.asy
(Compiled with Asymptote version 1.86svn-r4626)
    
import graph_pi;
import patterns;

graphicrules(xunit=2.5cm,yunit=1.5cm, xmin=-1, xmax=4, ymin=-1, ymax=5,
             crop=Crop);

// Définition des fonctions f et g :
real f(real x) {return 4x-x^2+4/(x^2+1)^2;}
real g(real x) {return x-1+4/(x^2+1)^2;}

// Tracé des courbes :
path Cf=graph(f,n=700);
path Cg=graph(g,n=700);
draw(Cf,linewidth(1bp));
draw(Cg,linewidth(1bp));
crop(currentpicture);

// La grille.
grid();
// Les axes.
cartesianaxis(xticks=Ticks(NoZero,ptick=grey),
              yticks=Ticks(NoZero,ptick=grey),arrow=None);
labeloij(UnFill);

label("$\mathscr{C}_f$",(2.25,f(2.25)),2N);
label("$\mathscr{C}_f$",(2.25,g(2.25)),2S);

// Les hachures.
path vline=(1,-1)--(1,5);
add("hachure",hatch(3mm));
fill(buildcycle(vline,graph(f,1,4),graph(g,1,4)),pattern("hachure"));

Figure 0007
Figure 0007: fig0070.asy
(Compiled with Asymptote version 1.86svn-r4626)
    
import graph_pi;

graphicrules(xunit=1cm, yunit=2cm,
             xmin=-2pi, xmax=2pi, ymin=-1, ymax=1);

yaxis("y",LeftRight ,
      Ticks(labelfrac,Step=.5,step=.25, ptick=grey, extend=true));

xaxis("$\theta$",BottomTop,
      Ticks(labelfrac(factor=pi,symbol="\pi",symbolin=false),
            Step=pi/2, step=pi/4, ptick=grey, extend=true));

draw(graph(new real(real x){return sin(x);},-2pi,2pi));
draw(graph(new real(real x){return cos(x);},-2pi,2pi), .8red);

Figure 0008
Figure 0008: fig0080.asy
(Compiled with Asymptote version 1.86svn-r4626)
    
import graph_pi;

graphicrules(xunit=1cm, yunit=3cm,
             xmin=-2pi, xmax=2pi, ymin=-1, ymax=1);

grid(xStep=pi/2, xstep=pi/4, yStep=.5, ystep=.25);

cartesianaxis(xticks=Ticks(Label(Fill(white)),
                           labelfrac(factor=pi,symbol="\pi",symbolin=true,
                                     zero=false),Step=pi/2, step=pi/4, ptick=grey),
              yticks=Ticks(Label(Fill(white)),
                           labelfrac(zero=false),Step=.5,step=.25, ptick=grey), Arrow);

dot("$O$",(0,0),2SW);

shipout(bbox(Fill(white)));

Figure 0009
Figure 0009: fig0090.asy
(Compiled with Asymptote version 1.86svn-r4626)
    
import graph_pi;

real f(real x){return -.8x+3;}

graphicrules(unit=1cm,
             xmin=-2, xmax=6, ymin=-2, ymax=6);

draw(graph(f));
draw(graph(new real(real x){return x;}), grey);
cartesianaxis();
draw(recursivegraph(f,-1.8,n=7),.8red);

Figure 0010
Figure 0010: fig0100.asy
(Compiled with Asymptote version 1.86svn-r4626)
    
import graph_pi;

real f(real x){return -.8x+3;}

graphicrules(unit=1cm,
             xmin=-2, xmax=6, ymin=-2, ymax=6);

draw(graph(f));
draw(graph(new real(real x){return x;}), grey);
cartesianaxis();
draw(recursivegraph(f,-1.8,n=7),
     //This is the default options
     recursiveoption(L="u",
                    labelbegin=true,
                    labelend=true,
                    labelinner=true,
                    labelalternate=false,
                    format="",
                    labelplace=onX,
                    px=nullpen,
                    py=nullpen,
                    startonyaxis=false,
                    circuitarrow=None,
                    automarker=marker(cross(4)),
                    xaxismarker=nomarker,
                    yaxismarker=nomarker,
                    xmarker=nomarker,
                    fmarker=nomarker),
     .8red);

Figure 0011
Figure 0011: fig0110.asy
(Compiled with Asymptote version 1.86svn-r4626)
    
import graph_pi;

real f(real x){return -x^3/8-x^2/4+2x;}

graphicrules(xunit=6cm,yunit=4cm,
             xmin=.9, xmax=2.1, ymin=0, ymax=3);

draw(graph(f));
draw(graph(new real(real x){return x;}), grey);
cartesianaxis(viewyaxis=false);

draw(recursivegraph(f,1,n=5),.8red);

Figure 0012
Figure 0012: fig0120.asy
(Compiled with Asymptote version 1.86svn-r4626)
    
import graph_pi;

real f(real x){return -x^3/8-x^2/4+2x;}

graphicrules(xunit=6cm,yunit=4cm,
             xmin=.9, xmax=2.1, ymin=0, ymax=3);

draw(graph(f));
draw(graph(new real(real x){return x;}), grey);
cartesianaxis(xticks=NoTicks,viewyaxis=false);

draw(recursivegraph(f,1,n=5),
     recursiveoption(Label("v", p=blue),
                     labelinner=false),
     .8red);

Figure 0013
Figure 0013: fig0130.asy
(Compiled with Asymptote version 1.86svn-r4626)
    
import graph_pi;

real f(real x){return -x^3/8-x^2/4+2x;}

graphicrules(xunit=6cm,yunit=4cm,
             xmin=.9, xmax=2.1, ymin=0, ymax=3);

draw(graph(f));
draw(graph(new real(real x){return x;}), grey);
cartesianaxis(xticks=NoTicks,viewyaxis=false);

draw(recursivegraph(f,1,n=5),
     recursiveoption(Label(scale(.75)*"v"),
                     labelinner=false,
                     format="=%.2f"),
     .8red);

Figure 0014
Figure 0014: fig0140.asy
(Compiled with Asymptote version 1.86svn-r4626)
    
import graph_pi;

real f(real x){return -x^3/8-x^2/4+2x;}

graphicrules(unit=2cm,
             xmin=-5, xmax=.25, ymin=-5, ymax=0);

draw(graph(f));
cartesianaxis();
draw(graph(new real(real x){return x;}), grey);

draw(recursivegraph(f,-1.5,n0=1,n=12),
     recursiveoption(Label(scale(.8)*"\alpha",align=2N),
                     px=dashed,
                     xaxismarker=scale(2)*MarkFill[0],
                     automarker=nomarker,
                     circuitarrow=Arrow(position=Relative(.5))),
     .8red);

Figure 0015
Figure 0015: fig0150.asy
(Compiled with Asymptote version 1.86svn-r4626)
    
import graph_pi;

real k=3.2;
real f(real x){return k*x*(1-x);}
graphicrules(unit=8cm,
             xmin=0, xmax=1, ymin=0, ymax=1);

draw(graph(f));
cartesianaxis();
draw(graph(new real(real x){return x;}), grey);

draw(recursivegraph(f,.1,n=12),
     recursiveoption(Label("%"),
                     labelplace=onXY,
                     px=dashed+grey,
                     py=dashed+grey,
                     automarker=nomarker,
                     circuitarrow=Arrow(position=Relative(.5),size=2mm)),
     .8red);

Figure 0016
Figure 0016: fig0160.asy
(Compiled with Asymptote version 1.86svn-r4626)
    
import graph_pi;

real k=1.5;
real f(real x){return k*x*(1-x);}
graphicrules(xunit=40cm, yunit=20cm,
             xmin=0, xmax=.35, ymin=0, ymax=.35);

draw(graph(f));
cartesianaxis();
draw(graph(new real(real x){return x;}), grey);

draw(recursivegraph(f,.05,n=10),
     recursiveoption(Label("",UnFill),
                     labelalternate=true,
                     px=dashed+grey,
                     format="%.2f"),
     .8red);

Figure 0017
Figure 0017: fig0170.asy
(Compiled with Asymptote version 1.86svn-r4626)
    
import graph_pi;

texpreamble("\usepackage{amsmath}");
real k=3.2;
real f(real x){return k*x*(1-x);}
real g(real x){return f(f(x));}
graphicrules(unit=8cm,
             xmin=0, xmax=1, ymin=0, ymax=1);

draw(graph(f),legend="$f:x\longmapsto 3.2x(1-x)$");
draw(graph(g),blue,legend="$g:x\longmapsto{}(f\circ f)(x)$");
cartesianaxis();
draw(graph(new real(real x){return x;}), grey);

draw(recursivegraph(g,.12,n=12),
     recursiveoption(Label("u",align=2S),
                     labelplace=onX,
                     labelinner=false,
                     px=dashed+lightgrey,
                     xmarker=nomarker,
                     circuitarrow=Arrow(position=Relative(.5),size=2mm)),
     .8red, legend="$u_{n+1}=g(u_{n})\;\text{et}\;u_{0}=0.12$");
draw(recursivegraph(g,.6,n=12),
     recursiveoption(Label("v",align=2W),
                     labelplace=onY,
                     labelinner=false,
                     py=dashed+lightgrey,
                     xmarker=nomarker,
                     circuitarrow=Arrow(position=Relative(.5),size=2mm)),
     .8green, legend="$v_{n+1}=g(v_{n})\;\text{et}\;v_{0}=0.6$");
attach(legend(), point(S), 5S);

Figure 0018
Figure 0018: fig0180.asy
(Compiled with Asymptote version 1.86svn-r4626)
    
/* Example posted by Olivier Guibé */

import graph_pi;
texpreamble("\usepackage{amsmath}");

real g(real x){return (x^3-1)/5;}
graphicrules(unit=1cm,
             xmin=-1, xmax=4, ymin=-2, ymax=5,
             ycrop=Crop);
draw(graph(g),legend="$g:x\longmapsto (x^3-1)/5$");
cartesianaxis();
draw(graph(new real(real x){return x;}), grey);

draw(recursivegraph(g,2.45,n=4),
     recursiveoption(Label(scale(.8)*"w",UnFill,align=2N),
                     px=dashed,
                     labelinner=false,
                     automarker=nomarker,
                     //              xaxismarker=scale(.2)*MarkFill[0],
                     circuitarrow=Arrow(position=Relative(.5))),.8green,
     legend="$w_{n+1}=g(z_{n})\;\text{et}\;w_{0}=2.45$");

attach(legend(), point(S), N);

Figure 0019
Figure 0019: fig0190.asy
(Compiled with Asymptote version 1.86svn-r4626)
    
import graph_pi;

size(10cm,0);

real f(real x){return x^2;};

xlimits(-2, 2);
ylimits(0, 4.25);

draw(graph(f, -2, 2));

/*MODgraph_pi.asy.html#graphpoint(...)MOD*/
graphpoint(Label("$M$",align=NW), f, 1.5);
graphpoint("$P$", f, 1, extendy=true, px=Dotted+red, py=Dotted+blue);
graphpoint("$N$", f, -1, draw=onX, px=Dotted+red);
graphpoint("$Q$", f, sqrt(3), extendx=true);

xaxis(BottomTop(), LeftTicks());
yaxis(Ticks());
yaxis(LeftRight(), Ticks());

Figure 0020
Figure 0020: fig0200.asy
(Compiled with Asymptote version 1.86svn-r4626)
    
import graph_pi;

unitsize(x=2cm,y=4cm);
real f(real x){return abs(sin(x));};
real g(real x){return cos(x);};
real x;

xlimits(-.25, 8);
ylimits(-1.25, 1.25);
xaxis(LeftTicks);
yaxis(Ticks);
path Cf=graph(f, 0, 8,500);
path Cg=graph(g, 0, 8,500);
draw(Cf,bp+red);
draw(Cg,bp+blue);

x=pi/4;
/*MODgraph_pi.asy.html#addtangentMOD*/
addtangent(Cf, x, .5yellow, drawleft=false);
addtangent(Cg, x, .5yellow, drawright=false);
dot((x,f(x))^^(x,g(x)));

x=3*pi/4;
path tg=tangent(Cf, x);
draw(tg);
addtangent(Cg, x);
pair M=intersectionpoint(tg,Cg);
dot("$M$",M,E);
addtangent(Cg, M.x, size=3cm,p=red);
draw((x,f(x))--(x,g(x)),scale(2)*MarkFill[0]);

x=pi;
addtangent(Cg, x, size=2cm,.8(green+blue));
dot((x,g(x)));

x=5*pi/4;
addtangent(Cf, x, size=2cm, v=(1,.25/sin(x)),
            drawright=false, p=red, arrow=Arrow(5mm,NoFill));
addtangent(Cf, x, size=2cm, drawleft=false, red);
dot((x,f(x)));

x=2*pi;
addtangent(Cf, x, size=4cm,p=.8green,differentiable=false);
dot((x,f(x)));

Figure 0021
Figure 0021: fig0210.asy
(Compiled with Asymptote version 1.86svn-r4626)
    
import graph_pi;

unitsize(x=3cm,y=3cm);
// All marks will have this size. Default=sqrt(2)*dotsize(currentpen);
graphmarksize=4mm;

real f(real x){return sin(x);};
path Cf=graph(f, .5, 2);
transform T=shift((0,-.5));
// ---------------------------------
// * definition of ArcMarkerExtrem *
// marker ArcMarkerExtrem(real radius=graphmarksize(), real angle=180,
//                        bool begin=true, bool end=true,
//                        pen p=currentpen, bool put=Above)

draw(Cf, ArcMarkerExtrem());
draw(T*Cf, red, ArcMarkerExtrem(angle=270, begin=false));
draw(T^2*Cf, blue, ArcMarkerExtrem(radius=-graphmarksize, blue));

// ----------------------------------
// * Definition of Hookmarkerextrem *
// marker HookMarkerExtrem(real height=graphmarksize(), real width=height/2,
//                         bool begin=true, bool end=true,
//                         pen p=currentpen, bool put=Above)

draw(T^3*Cf,HookMarkerExtrem);//Without brackets values returns to default
draw(T^4*Cf, green, HookMarkerExtrem(height=2*graphmarksize, width=-graphmarksize*2,green));

// ------------------------------------
// * Definition of CircleMarkerExtrem *
// marker CircleMarkerExtrem(real radius=graphmarksize(), real angle=90,
//                           bool begin=true, bool end=true,
//                           pen p=currentpen, filltype filltype=NoFill,
//                           bool put=Above)

draw(T^5*Cf, green, CircleMarkerExtrem(green));
draw(T^6*Cf, green+blue, CircleMarkerExtrem(radius=graphmarksize,filltype=FillDraw(blue),p=2mm+green+blue));

Dernière modification/Last modified: Sun Sep 20 18:48:39 CEST 2009
Philippe Ivaldi

Valide XHTML