2

I am using Asymptote's graph module. How do I make the horizontal scale different than the vertical scale?

The FAQ tells me to use Linear, but I cannot seem to make it work for me.

Here is an example file. The x-axis and the y-axis have the same distance between 0 and 1; how do I make the x-axis's distance be, say, half that of the y-axis?

include graph;
int picnum = 5;
picture p;
unitsize(p, 1.25cm);

xaxis(p,"$x$",YZero,
      xmin=-1,xmax=6,
      RightTicks(Label("$%.2g$",tickpen),
         new real[]{0,1,2,3,4,5}),  // Step=1,step=1),
             above=false); 
yaxis(p,"Probability",XEquals(-1),ymin=0,ymax=1.1,
      LeftTicks(Label("$%.2g$",tickpen),
        new real[]{0,1}, // Step=1,step=1,
        pTick=black, ptick=linetype("4 4")+grey,
         extend=false));
shipout(format("graph%02d",picnum),p,format="pdf");

1 Answer 1

2

Linear has an optional argument : a multiplicative scaling factor. In your case, I hope that the code is the desired one

include graph; int picnum = 5; picture p; unitsize(p, 1.25cm);

scale(p,Linear,Linear(2));

dot(p,Scale(p,(1,1)),red);

xaxis(p,"$x$",YZero,
      xmin=-1,xmax=6,
      RightTicks(Label("$%.2g$"),
                 new real[]{0,1,2,3,4,5}),  // Step=1,step=1),
      above=false); 
yaxis(p,"Probability",XEquals(-1),ymin=0,ymax=1.1,
      LeftTicks(Label("$%.2g$"),
                new real[]{0,1}, // Step=1,step=1,
                pTick=black, ptick=linetype("4 4")+grey,
                extend=false));



shipout(format("graph%02d",picnum),p,format="pdf");

Notice dot(p,Scale(p,(1,1)),red); to have the point (1,1) well placed.

enter image description here

O.G.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .