vectorgraphics / asymptote

2D & 3D TeX-Aware Vector Graphics Language
https://asymptote.sourceforge.io/
GNU General Public License v3.0
549 stars 90 forks source link

scale command breaks graph output #459

Closed badkey closed 4 months ago

badkey commented 4 months ago

Hi, trying to plot a log-linear graph to a picture I ran into this problem:

import graph;

// some function
real f(real t) {return 1/t;}

picture s;
size(s, 200,200,IgnoreAspect);
//scale(s, Log, Linear);
draw(s, graph(f,1,10000), blue);
xaxis(s, "$x$",BottomTop,LeftTicks);
yaxis(s, "$y$",LeftRight,RightTicks);
add(s.fit());

does nicely work unless one uncomments the scale command. The same does work when working without a picture (e.g. using currentpicture). Any hint is appreciated. Jan-Mark

johncbowman commented 4 months ago

You simply forgot the s argument to graph:

import graph;

// some function
real f(real t) {return 1/t;}

picture s;
size(s, 200,200,IgnoreAspect);
scale(s, Log, Linear);
draw(s, graph(s,f,1,10000), blue);
xaxis(s, "$x$",BottomTop,LeftTicks);
yaxis(s, "$y$",LeftRight,RightTicks);
add(s.fit());
badkey commented 4 months ago

Thanks a lot - I have overseen this one. And also Scale() needs the s as I noticed right now...