vectorgraphics / asymptote

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

Default value of ticks for graph.xaxis may not always be reasonable? #416

Open user202729 opened 6 months ago

user202729 commented 6 months ago

Example:

import graph;
size(4cm);
xaxis("$x$", xmin=1, xmax=10, Ticks());
draw(graph(new real(real x){return x^2/32;}, 1, 10));

Result: no ticks is drawn.

In the documentation, it's stated that "if values like N, n, Step, step are not specified, reasonable defaults will be chosen".

I think it would be useful to add to the documentation something like:

You should draw the axis after all the graphs are drawn, so that the extent can be determined.

(or so it appears. In the code above, if xaxis is moved to the last line, the ticks are indeed reasonably chosen.)

And to add to the source code (the logic to find the tick values to drawn) such that, if none of N, Step is specified, then at least one tick should be drawn.