vectorgraphics / asymptote

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

Tick Label Font Size #339

Closed abrombo closed 2 years ago

abrombo commented 2 years ago

I am trying to reduce the font size of the y-axis tick labels. On the internet I found this code -

yaxis(tmp,rotate(0)*Label(ylab),0.0,max(fm.Y),Ticks(max(fm.Y)/4,beginlabel=false,font("cmr8",8)));

but it has no effect on the yaxis tick label size. I use the max(fm.Y)/4 for the first argument in Ticks to reduce the number of ticks on the axis. For user-defined ticks I just scale the label which works fine. It would be nice if I could just apply scale to ticks.

While I am at it is there a way to get the values and labels for the ticks generated by Asymptote to use in my code?

johncbowman commented 2 years ago

It's better to post questions like this (as opposed to bug reports) on the Asymptote Forum, where your question will get more exposure.

Anyway, the Ticks function takes a Label argument for formatting the tick label: Ticks(Label(font("cmr8",8)),beginlabel=false);

The signature of Ticks is:

ticks Ticks(int sign, Label F="", ticklabel ticklabel=null,
            bool beginlabel=true, bool endlabel=true,
            real[] Ticks=new real[], real[] ticks=new real[], int N=1,
            bool begin=true, bool end=true,
            real Size=0, real size=0, bool extend=false,
            pen pTick=nullpen, pen ptick=nullpen)

Did you intend max(fm.Y)/4 to be passed as the int N= argument or the real Size= argument? For the former case you would want to use integer division: N=max(fm.y)#4