diff --git a/src/axes.typ b/src/axes.typ index 1080921..eea8521 100644 --- a/src/axes.typ +++ b/src/axes.typ @@ -247,6 +247,13 @@ $#round(value, digits)$ } + let format-log(value, base: 10) = { + let exponent = if value != 0 { + calc.log(calc.abs(value), base: base) + } else {0} + return $#base^#exponent$ + } + let format-sci(value, digits) = { let exponent = if value != 0 { calc.floor(calc.log(calc.abs(value), base: 10)) @@ -278,6 +285,8 @@ value = (format)(value) } else if format == "sci" { value = format-sci(value, tic-options.at("decimals", default: 2)) + } else if format == "log" { + value = format-log(value, base: tic-options.at("base", default: 10)) } else { value = format-float(value, tic-options.at("decimals", default: 2)) } @@ -349,7 +358,7 @@ let n-minor = range(1, 10) for t-minor in n-minor { - + let place = t + calc.log(t-minor, base: 10) if ( place > axis.max){ continue } diff --git a/tests/axes/log-mode/test.typ b/tests/axes/log-mode/test.typ index 2bb04fb..516e21c 100644 --- a/tests/axes/log-mode/test.typ +++ b/tests/axes/log-mode/test.typ @@ -15,14 +15,14 @@ axis-style: "scientific", y-mode: "log", y-grid: "both", - y-format: "sci", + y-format: "log", y-tick-step: 1, y-minor-tick-step: 1, y-min: 0, y-max: 4, x-mode: "log", x-grid: "both", - x-format: "sci", + x-format: "log", x-tick-step: 1, x-minor-tick-step: 1, x-min: 0.00001, x-max: 4,